blockchain , sdchain cpp sdk and demo

Dependencies:   EthernetInterface mbed-rtos mbed uniqueCPUID

Fork of bcsdk by SDchain C Plus Plus Team

Committer:
MrAI
Date:
Wed May 16 13:46:01 2018 +0000
Revision:
12:1b24ea479a59
??14???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MrAI 12:1b24ea479a59 1 #include "Payment.h"
MrAI 12:1b24ea479a59 2 string Payment::PostPayment(MbedJSONValue& in, string sUrl, string sAddr, string otherInfo)
MrAI 12:1b24ea479a59 3 {
MrAI 12:1b24ea479a59 4 string strRep = "";
MrAI 12:1b24ea479a59 5 string strUrl = sUrl + sAddr + otherInfo;
MrAI 12:1b24ea479a59 6 string strJson = in.serialize();
MrAI 12:1b24ea479a59 7 client.http_post(strUrl, strJson, strRep);
MrAI 12:1b24ea479a59 8 string content = client.get_content(strRep);
MrAI 12:1b24ea479a59 9 return content;
MrAI 12:1b24ea479a59 10 }
MrAI 12:1b24ea479a59 11
MrAI 12:1b24ea479a59 12 bool Payment::SetJsonBody(MbedJSONValue& out, string secretIn, string src_accIn, string dst_accIn, string amt_In, string memtypeIn, string memdataIn)
MrAI 12:1b24ea479a59 13 {
MrAI 12:1b24ea479a59 14 MbedJSONValue val;
MrAI 12:1b24ea479a59 15 val["secret"] = secretIn;
MrAI 12:1b24ea479a59 16 val["payment"]["source_account"] = src_accIn;
MrAI 12:1b24ea479a59 17 val["payment"]["destination_account"] = dst_accIn;
MrAI 12:1b24ea479a59 18 val["payment"]["amount"] = amt_In;
MrAI 12:1b24ea479a59 19 val["payment"]["memos"][0]["MemoType"] = memtypeIn;
MrAI 12:1b24ea479a59 20 val["payment"]["memos"][0]["MemoData"] = memdataIn;
MrAI 12:1b24ea479a59 21 out = val;
MrAI 12:1b24ea479a59 22 return true;
MrAI 12:1b24ea479a59 23 }
MrAI 12:1b24ea479a59 24
MrAI 12:1b24ea479a59 25 bool Payment::SetJsonBody(MbedJSONValue& out, string src_accIn, string dst_accIn, string direction, int start_ledger, int end_ledger, int per_page, int page)
MrAI 12:1b24ea479a59 26 {
MrAI 12:1b24ea479a59 27 MbedJSONValue val;
MrAI 12:1b24ea479a59 28 val["source_account"] = src_accIn;
MrAI 12:1b24ea479a59 29 val["destination_account"] = dst_accIn;
MrAI 12:1b24ea479a59 30 val["direction"] = direction;
MrAI 12:1b24ea479a59 31 val["start_ledger"] = start_ledger;
MrAI 12:1b24ea479a59 32 val["end_ledger"] = end_ledger;
MrAI 12:1b24ea479a59 33 val["per_page"] = per_page;
MrAI 12:1b24ea479a59 34 val["page"] = page;
MrAI 12:1b24ea479a59 35 out = val;
MrAI 12:1b24ea479a59 36 return true;
MrAI 12:1b24ea479a59 37 }
MrAI 12:1b24ea479a59 38
MrAI 12:1b24ea479a59 39 string Payment::GetPaymentInfo(string sUrl, string sAddr, string otherInfo)
MrAI 12:1b24ea479a59 40 {
MrAI 12:1b24ea479a59 41 string strRep = "";
MrAI 12:1b24ea479a59 42 string strUrl = sUrl + sAddr + otherInfo;
MrAI 12:1b24ea479a59 43 client.http_get(strUrl, "", strRep);
MrAI 12:1b24ea479a59 44 string content = client.get_content(strRep);
MrAI 12:1b24ea479a59 45 return content;
MrAI 12:1b24ea479a59 46 }