blockchain , sdchain cpp sdk and demo
Dependencies: EthernetInterface mbed-rtos mbed uniqueCPUID
Fork of bcsdk by
Diff: Account.cpp
- Revision:
- 12:1b24ea479a59
- Parent:
- 10:aabd720e632c
- Child:
- 14:59412fcf8fa2
diff -r 6d9cefb14158 -r 1b24ea479a59 Account.cpp --- a/Account.cpp Wed May 16 12:00:23 2018 +0000 +++ b/Account.cpp Wed May 16 13:46:01 2018 +0000 @@ -45,15 +45,14 @@ val["root_xpubs"][i] = "62b33131fff6493ce37cf86396984902932baaf08eb5260cc17a4138f0403e4f261a0569c75aeddfd8f09548b891b360a8e72a514c082826920d3f87e325ea9b"; //val["root_xpubs"][i] = m_Keys.getRootXpub(); } - Uuid u; + //Uuid u; //GUID guid = u.CreateGuid(); //string strUuid = u.GuidToString(guid); - string strUuid = u.getUuid(); // GUID guid = CreateGuid(); // string strUuid = GuidToString(guid); - val["client_token"] = strUuid;//"17e48179-3500-48db-9335-b69d9af1117f"; +// val["client_token"] = strUuid;"17e48179-3500-48db-9335-b69d9af1117f"; //serialize it into a JSON string vals[0] = val; @@ -113,4 +112,109 @@ client.http_post(strUrl,strJson,strRep); return strJson; -} \ No newline at end of file +} + +string Account::getBalance() +{ + //https://rest-beta.sdchain.io/v1/accounts/balances/6faLUhmp9gNgS9jXS3rAWbg8hFfi9PbWH5 + string strRep = ""; + string strWallet = "69Hu8QsnEZUP4f3AVYSW7rkpLVm6DAEq9y"; + string strUrl = "/v1/accounts/balances/" + strWallet; + client.http_get(strUrl, "", strRep); + string content = client.get_content(strRep); + return content; +} + +string Account::getWallet() +{ + //https://rest-beta.sdchain.io/v1/accounts/balances/6faLUhmp9gNgS9jXS3rAWbg8hFfi9PbWH5 + string strRep = ""; + string strUrl = "/v1/wallet/new"; + //string strUrl = "https://rest-beta.sdchain.io/v1/wallet/new"; + client.http_get(strUrl, "", strRep); + string content = client.get_content(strRep); + return content; +} + +string Account::getParseMbedJson(MbedJSONValue& out, const char * pos) +{ + string err = parse(out, pos); + return err; +} + +bool Account::getRequestRet(MbedJSONValue& in) +{ + bool bRet = in["success"].get <bool>(); + return bRet; +} + +string Account::getKeyValue(MbedJSONValue& in, string Key1, string Key2) +{ + string sValue = in[Key1][Key2].get<string>(); + return sValue; +} + +int Account::getKeyValueInt(MbedJSONValue& in, string Key1, string Key2) +{ + int sValue = in[Key1][Key2].get<int>(); + return sValue; +} + +double Account::getKeyValuedouble(MbedJSONValue& in, string Key1, string Key2) +{ + double sValue = in[Key1][Key2].get<double>(); + return sValue; +} + +string Account::getKeyValue(MbedJSONValue& in, string Key1) +{ + string sValue = in[Key1].get<string>(); + return sValue; +} + +bool Account::getKeyValueBool(MbedJSONValue& in, string Key1,string Key2) +{ + bool bRet = in[Key1][Key2].get <bool>(); + return bRet; +} + +bool Account::getKeyValueBool(MbedJSONValue& in, string Key1) +{ + bool bRet = in[Key1].get <bool>(); + return bRet; +} +int Account::getLedger(MbedJSONValue& in) +{ + int iLedger = in["ledger"].get<int>(); + return iLedger; +} + +int Account::getBalanceSize(MbedJSONValue& in,string Key1) +{ + int iCurrenciesNum = in[Key1].size(); + return iCurrenciesNum; +} + +int Account::getBalanceSize(MbedJSONValue& in, string Key1,string Key2) +{ + int iCurrenciesNum = in[Key1][Key2].size(); + return iCurrenciesNum; +} + +string Account::getBalanceArray(MbedJSONValue& in, string Key1, int i, string Key2) +{ + string sValue = in[Key1][i][Key2].get<string>(); + return sValue; +} + +string Account::getBalanceArray(MbedJSONValue& in, string Key1, string Key2,int i,string Key3) +{ + string sValue = in[Key1][Key2][i][Key3].get<string>(); + return sValue; +} + +string Account::getBalanceArray(MbedJSONValue& in, string Key1,string Key2, string Key3,int i,string Key4) +{ + string sValue = in[Key1][Key2][Key3][i][Key4].get<string>(); + return sValue; +}