blockchain , sdchain cpp sdk and demo

Dependencies:   EthernetInterface mbed-rtos mbed uniqueCPUID

Fork of bcsdk by SDchain C Plus Plus Team

Committer:
webmaster
Date:
Wed Aug 08 09:32:47 2018 +0800
Revision:
16:50646cf2e9a0
Parent:
14:59412fcf8fa2
delete unused files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
webmaster 10:aabd720e632c 1 #include "Account.h"
webmaster 10:aabd720e632c 2 #include "Uuid.h"
webmaster 10:aabd720e632c 3
webmaster 10:aabd720e632c 4
webmaster 10:aabd720e632c 5 Account::Account()
webmaster 10:aabd720e632c 6 {
MrAI 14:59412fcf8fa2 7 cout<<"Account Construction begin..."<<endl;
webmaster 10:aabd720e632c 8 this->id = "";
webmaster 10:aabd720e632c 9 this->alias = "";
webmaster 10:aabd720e632c 10 //this->tags = "{}";
webmaster 10:aabd720e632c 11 this->quorum = 1;
MrAI 14:59412fcf8fa2 12 cout<<"Account Construction end..."<<endl;
webmaster 10:aabd720e632c 13 }
webmaster 10:aabd720e632c 14
webmaster 10:aabd720e632c 15 Account::Account(Key &key)
webmaster 10:aabd720e632c 16 {
webmaster 10:aabd720e632c 17 this->id = "";
webmaster 10:aabd720e632c 18 this->alias = "";
webmaster 10:aabd720e632c 19 //this->tags = "{}";
webmaster 10:aabd720e632c 20 this->quorum = 1;
webmaster 10:aabd720e632c 21 this->m_Keys = key;
webmaster 10:aabd720e632c 22 }
webmaster 10:aabd720e632c 23
webmaster 10:aabd720e632c 24 Account::~Account()
webmaster 10:aabd720e632c 25 {
webmaster 10:aabd720e632c 26
webmaster 10:aabd720e632c 27 }
webmaster 10:aabd720e632c 28
webmaster 8:f2a567ee3a46 29
webmaster 10:aabd720e632c 30 // ����
webmaster 10:aabd720e632c 31 // ע���˺�json�Ǹ�����[]
webmaster 10:aabd720e632c 32 string Account::createAccount()
webmaster 10:aabd720e632c 33 {
webmaster 10:aabd720e632c 34 string strJson = "";
webmaster 10:aabd720e632c 35
webmaster 10:aabd720e632c 36 return id;
webmaster 10:aabd720e632c 37 }
webmaster 10:aabd720e632c 38
webmaster 10:aabd720e632c 39 string Account::listAccounts()
webmaster 8:f2a567ee3a46 40 {
webmaster 10:aabd720e632c 41 string strJson = "";
webmaster 10:aabd720e632c 42
webmaster 10:aabd720e632c 43 return strJson;
MrAI 12:1b24ea479a59 44 }
MrAI 12:1b24ea479a59 45
MrAI 12:1b24ea479a59 46 string Account::getBalance()
MrAI 12:1b24ea479a59 47 {
MrAI 12:1b24ea479a59 48 //https://rest-beta.sdchain.io/v1/accounts/balances/6faLUhmp9gNgS9jXS3rAWbg8hFfi9PbWH5
MrAI 12:1b24ea479a59 49 string strRep = "";
MrAI 12:1b24ea479a59 50 string strWallet = "69Hu8QsnEZUP4f3AVYSW7rkpLVm6DAEq9y";
MrAI 12:1b24ea479a59 51 string strUrl = "/v1/accounts/balances/" + strWallet;
MrAI 12:1b24ea479a59 52 client.http_get(strUrl, "", strRep);
MrAI 12:1b24ea479a59 53 string content = client.get_content(strRep);
MrAI 12:1b24ea479a59 54 return content;
MrAI 12:1b24ea479a59 55 }
MrAI 12:1b24ea479a59 56
MrAI 12:1b24ea479a59 57 string Account::getWallet()
MrAI 12:1b24ea479a59 58 {
MrAI 12:1b24ea479a59 59 //https://rest-beta.sdchain.io/v1/accounts/balances/6faLUhmp9gNgS9jXS3rAWbg8hFfi9PbWH5
MrAI 14:59412fcf8fa2 60 cout<<"Account::getWallet()"<<endl;
MrAI 12:1b24ea479a59 61 string strRep = "";
MrAI 12:1b24ea479a59 62 string strUrl = "/v1/wallet/new";
MrAI 12:1b24ea479a59 63 //string strUrl = "https://rest-beta.sdchain.io/v1/wallet/new";
MrAI 12:1b24ea479a59 64 client.http_get(strUrl, "", strRep);
MrAI 12:1b24ea479a59 65 string content = client.get_content(strRep);
MrAI 12:1b24ea479a59 66 return content;
MrAI 12:1b24ea479a59 67 }
MrAI 12:1b24ea479a59 68
MrAI 12:1b24ea479a59 69 string Account::getParseMbedJson(MbedJSONValue& out, const char * pos)
MrAI 12:1b24ea479a59 70 {
MrAI 12:1b24ea479a59 71 string err = parse(out, pos);
MrAI 12:1b24ea479a59 72 return err;
MrAI 12:1b24ea479a59 73 }
MrAI 12:1b24ea479a59 74
MrAI 12:1b24ea479a59 75 bool Account::getRequestRet(MbedJSONValue& in)
MrAI 12:1b24ea479a59 76 {
MrAI 12:1b24ea479a59 77 bool bRet = in["success"].get <bool>();
MrAI 12:1b24ea479a59 78 return bRet;
MrAI 12:1b24ea479a59 79 }
MrAI 12:1b24ea479a59 80
MrAI 12:1b24ea479a59 81 string Account::getKeyValue(MbedJSONValue& in, string Key1, string Key2)
MrAI 12:1b24ea479a59 82 {
MrAI 12:1b24ea479a59 83 string sValue = in[Key1][Key2].get<string>();
MrAI 12:1b24ea479a59 84 return sValue;
MrAI 12:1b24ea479a59 85 }
MrAI 12:1b24ea479a59 86
MrAI 12:1b24ea479a59 87 int Account::getKeyValueInt(MbedJSONValue& in, string Key1, string Key2)
MrAI 12:1b24ea479a59 88 {
MrAI 12:1b24ea479a59 89 int sValue = in[Key1][Key2].get<int>();
MrAI 12:1b24ea479a59 90 return sValue;
MrAI 12:1b24ea479a59 91 }
MrAI 12:1b24ea479a59 92
MrAI 12:1b24ea479a59 93 double Account::getKeyValuedouble(MbedJSONValue& in, string Key1, string Key2)
MrAI 12:1b24ea479a59 94 {
MrAI 12:1b24ea479a59 95 double sValue = in[Key1][Key2].get<double>();
MrAI 12:1b24ea479a59 96 return sValue;
MrAI 12:1b24ea479a59 97 }
MrAI 12:1b24ea479a59 98
MrAI 12:1b24ea479a59 99 string Account::getKeyValue(MbedJSONValue& in, string Key1)
MrAI 12:1b24ea479a59 100 {
MrAI 12:1b24ea479a59 101 string sValue = in[Key1].get<string>();
MrAI 12:1b24ea479a59 102 return sValue;
MrAI 12:1b24ea479a59 103 }
MrAI 12:1b24ea479a59 104
MrAI 12:1b24ea479a59 105 bool Account::getKeyValueBool(MbedJSONValue& in, string Key1,string Key2)
MrAI 12:1b24ea479a59 106 {
MrAI 12:1b24ea479a59 107 bool bRet = in[Key1][Key2].get <bool>();
MrAI 12:1b24ea479a59 108 return bRet;
MrAI 12:1b24ea479a59 109 }
MrAI 12:1b24ea479a59 110
MrAI 12:1b24ea479a59 111 bool Account::getKeyValueBool(MbedJSONValue& in, string Key1)
MrAI 12:1b24ea479a59 112 {
MrAI 12:1b24ea479a59 113 bool bRet = in[Key1].get <bool>();
MrAI 12:1b24ea479a59 114 return bRet;
MrAI 12:1b24ea479a59 115 }
MrAI 12:1b24ea479a59 116 int Account::getLedger(MbedJSONValue& in)
MrAI 12:1b24ea479a59 117 {
MrAI 12:1b24ea479a59 118 int iLedger = in["ledger"].get<int>();
MrAI 12:1b24ea479a59 119 return iLedger;
MrAI 12:1b24ea479a59 120 }
MrAI 12:1b24ea479a59 121
MrAI 12:1b24ea479a59 122 int Account::getBalanceSize(MbedJSONValue& in,string Key1)
MrAI 12:1b24ea479a59 123 {
MrAI 12:1b24ea479a59 124 int iCurrenciesNum = in[Key1].size();
MrAI 12:1b24ea479a59 125 return iCurrenciesNum;
MrAI 12:1b24ea479a59 126 }
MrAI 12:1b24ea479a59 127
MrAI 12:1b24ea479a59 128 int Account::getBalanceSize(MbedJSONValue& in, string Key1,string Key2)
MrAI 12:1b24ea479a59 129 {
MrAI 12:1b24ea479a59 130 int iCurrenciesNum = in[Key1][Key2].size();
MrAI 12:1b24ea479a59 131 return iCurrenciesNum;
MrAI 12:1b24ea479a59 132 }
MrAI 12:1b24ea479a59 133
MrAI 12:1b24ea479a59 134 string Account::getBalanceArray(MbedJSONValue& in, string Key1, int i, string Key2)
MrAI 12:1b24ea479a59 135 {
MrAI 12:1b24ea479a59 136 string sValue = in[Key1][i][Key2].get<string>();
MrAI 12:1b24ea479a59 137 return sValue;
MrAI 12:1b24ea479a59 138 }
MrAI 12:1b24ea479a59 139
MrAI 12:1b24ea479a59 140 string Account::getBalanceArray(MbedJSONValue& in, string Key1, string Key2,int i,string Key3)
MrAI 12:1b24ea479a59 141 {
MrAI 12:1b24ea479a59 142 string sValue = in[Key1][Key2][i][Key3].get<string>();
MrAI 12:1b24ea479a59 143 return sValue;
MrAI 12:1b24ea479a59 144 }
MrAI 12:1b24ea479a59 145
MrAI 12:1b24ea479a59 146 string Account::getBalanceArray(MbedJSONValue& in, string Key1,string Key2, string Key3,int i,string Key4)
MrAI 12:1b24ea479a59 147 {
MrAI 12:1b24ea479a59 148 string sValue = in[Key1][Key2][Key3][i][Key4].get<string>();
MrAI 12:1b24ea479a59 149 return sValue;
MrAI 12:1b24ea479a59 150 }