diff --git a/src/bitcoinapi/bitcoinapi.cpp b/src/bitcoinapi/bitcoinapi.cpp index 6ed22ec..71b7c8f 100644 --- a/src/bitcoinapi/bitcoinapi.cpp +++ b/src/bitcoinapi/bitcoinapi.cpp @@ -30,6 +30,11 @@ using std::map; using std::string; using std::vector; +#ifdef _OMNI_SUPPORT_ +#define OMNI_TYPE_SIMPLE_SEND 0 +#define OMNI_TYPE_SEND_ALL 4 +#endif + BitcoinAPI::BitcoinAPI(const string& user, const string& password, const string& host, int port, int httpTimeout) : httpClient(new HttpClient("http://" + user + ":" + password + "@" + host + ":" + IntegerToString(port))), @@ -38,6 +43,13 @@ BitcoinAPI::BitcoinAPI(const string& user, const string& password, const string& httpClient->SetTimeout(httpTimeout); } +BitcoinAPI::BitcoinAPI(const string& user, const string& password, const string& host, int port, const string& wallet, int httpTimeout) +: httpClient(new HttpClient("http://" + user + ":" + password + "@" + host + ":" + IntegerToString(port) + "/wallet/" + wallet)), + client(new Client(*httpClient, JSONRPC_CLIENT_V1)) +{ + httpClient->SetTimeout(httpTimeout); +} + BitcoinAPI::~BitcoinAPI() { delete client; @@ -130,7 +142,7 @@ vector BitcoinAPI::getaddednodeinfo(bool dns) { result = sendcommand(command, params); for (ValueIterator it1 = result.begin(); it1 != result.end(); it1++) { - Value val1 = (*it1); + Value &val1 = (*it1); nodeinfo_t node; node.addednode = val1["addednode"].asString(); @@ -139,7 +151,7 @@ vector BitcoinAPI::getaddednodeinfo(bool dns) { node.connected = val1["connected"].asBool(); for (ValueIterator it2 = val1["addresses"].begin(); it2 != val1["addresses"].end(); it2++) { - Value val2 = (*it2); + Value &val2 = (*it2); netaddress_t net; net.address = val2["address"].asString(); @@ -166,7 +178,7 @@ vector BitcoinAPI::getaddednodeinfo(bool dns, const std::string& nod result = sendcommand(command, params); for (ValueIterator it1 = result.begin(); it1 != result.end(); it1++) { - Value val1 = (*it1); + Value &val1 = (*it1); nodeinfo_t node; node.addednode = val1["addednode"].asString(); @@ -175,7 +187,7 @@ vector BitcoinAPI::getaddednodeinfo(bool dns, const std::string& nod node.connected = val1["connected"].asBool(); for (ValueIterator it2 = val1["addresses"].begin(); it2 != val1["addresses"].end(); it2++) { - Value val2 = (*it2); + Value &val2 = (*it2); netaddress_t net; net.address = val2["address"].asString(); @@ -206,7 +218,7 @@ vector BitcoinAPI::getpeerinfo() { result = sendcommand(command, params); for(ValueIterator it = result.begin(); it != result.end(); it++){ - Value val = (*it); + Value &val = (*it); peerinfo_t peer; peer.addr = val["addr"].asString(); @@ -359,6 +371,24 @@ string BitcoinAPI::getnewaddress(const string& account) { return result.asString(); } +getaddressinfo_t BitcoinAPI::getaddressinfo(const string& bitcoinaddress) { + string command = "getaddressinfo"; + Value params, result; + getaddressinfo_t ret; + + params.append(bitcoinaddress); + result = sendcommand(command, params); + + ret.address = result["address"].asString(); + ret.scriptPubKey = result["scriptPubKey"].asString(); + ret.ismine = result["ismine"].asBool(); + ret.isscript = result["isscript"].asBool(); + ret.iswatchonly = result["iswatchonly"].asBool(); + ret.iswitness = result["iswitness"].asBool(); + + return ret; +} + validateaddress_t BitcoinAPI::validateaddress(const string& bitcoinaddress) { string command = "validateaddress"; Value params, result; @@ -373,6 +403,7 @@ validateaddress_t BitcoinAPI::validateaddress(const string& bitcoinaddress) { ret.isscript = result["isscript"].asBool(); ret.pubkey = result["pubkey"].asString(); ret.iscompressed = result["iscompressed"].asBool(); + ret.iswatchonly = result["iswatchonly"].asBool(); return ret; } @@ -399,6 +430,17 @@ double BitcoinAPI::estimatefee(int blocks) { return result.asDouble(); } +smartfee_t BitcoinAPI::estimatesmartfee(int blocks) { + string command = "estimatesmartfee"; + Value params, result; + smartfee_t ret; + params.append(blocks); + result = sendcommand(command, params); + ret.feerate = result["feerate"].asDouble(); + ret.blocks = result["blocks"].asInt(); + return ret; +} + string BitcoinAPI::signmessage(const std::string& bitcoinaddress, const std::string& message) { string command = "signmessage"; Value params, result; @@ -476,7 +518,7 @@ vector BitcoinAPI::listreceivedbyaccount(int minconf, bool includ result = sendcommand(command, params); for (ValueIterator it = result.begin(); it != result.end(); it++) { - Value val = (*it); + Value &val = (*it); accountinfo_t acct; acct.account = val["account"].asString(); acct.amount = val["amount"].asDouble(); @@ -541,7 +583,7 @@ gettransaction_t BitcoinAPI::gettransaction(const string& tx, bool watch) { for (ValueIterator it = result["details"].begin(); it != result["details"].end(); it++) { - Value val = (*it); + Value &val = (*it); transactiondetails_t tmp; tmp.account = val["account"].asString(); tmp.address = val["address"].asString(); @@ -566,13 +608,14 @@ vector BitcoinAPI::listtransactions() { result = sendcommand(command, params); for (ValueIterator it = result.begin(); it != result.end(); it++) { - Value val = (*it); + Value &val = (*it); transactioninfo_t tmp; tmp.account = val["account"].asString(); tmp.address = val["address"].asString(); tmp.category = val["category"].asString(); tmp.amount = val["amount"].asDouble(); + tmp.fee = val["fee"].asDouble(); tmp.confirmations = val["confirmations"].asInt(); tmp.blockhash = val["blockhash"].asString(); tmp.blockindex = val["blockindex"].asInt(); @@ -604,13 +647,14 @@ vector BitcoinAPI::listtransactions(const string& account, in result = sendcommand(command, params); for (ValueIterator it = result.begin(); it != result.end(); it++) { - Value val = (*it); + Value &val = (*it); transactioninfo_t tmp; tmp.account = val["account"].asString(); tmp.address = val["address"].asString(); tmp.category = val["category"].asString(); tmp.amount = val["amount"].asDouble(); + tmp.fee = val["fee"].asDouble(); tmp.confirmations = val["confirmations"].asInt(); tmp.blockhash = val["blockhash"].asString(); tmp.blockindex = val["blockindex"].asInt(); @@ -673,7 +717,7 @@ map BitcoinAPI::listaccounts(int minconf) { result = sendcommand(command, params); for(ValueIterator it = result.begin(); it != result.end(); it++){ - Value val = (*it); + // Value &val = (*it); std::pair tmp; tmp.first = it.key().asString(); @@ -691,11 +735,11 @@ vector< vector > BitcoinAPI::listaddressgroupings() { result = sendcommand(command, params); for(ValueIterator it1 = result.begin(); it1 != result.end(); it1++){ - Value val1 = (*it1); + Value &val1 = (*it1); vector tmp1; for(ValueIterator it2 = val1.begin(); it2 != val1.end(); it2++){ - Value val2 = (*it2); + Value &val2 = (*it2); addressgrouping_t tmp2; tmp2.address = val2.operator []((uint)0).asString(); @@ -834,17 +878,26 @@ string BitcoinAPI::sendmany(const string& fromaccount, const map& return result.asString(); } -vector BitcoinAPI::listunspent(int minconf, int maxconf) { +vector BitcoinAPI::listunspent(int minconf, int maxconf, const vector& addresses) { + string command = "listunspent"; Value params, result; vector ret; params.append(minconf); params.append(maxconf); + if (addresses.size() > 0) { + Value addressesParam(Json::arrayValue); + for(vector::const_iterator it = addresses.begin(); it != addresses.end(); it++){ + Value val; + addressesParam.append((*it)); + } + params.append(addressesParam); + } result = sendcommand(command, params); for(ValueIterator it = result.begin(); it != result.end(); it++){ - Value val = (*it); + Value &val = (*it); unspenttxout_t tmp; tmp.txid = val["txid"].asString(); @@ -854,6 +907,7 @@ vector BitcoinAPI::listunspent(int minconf, int maxconf) { tmp.scriptPubKey = val["scriptPubKey"].asString(); tmp.amount = val["amount"].asDouble(); tmp.confirmations = val["confirmations"].asInt(); + tmp.spendable = val["spendable"].asBool(); ret.push_back(tmp); } @@ -861,6 +915,11 @@ vector BitcoinAPI::listunspent(int minconf, int maxconf) { return ret; } +vector BitcoinAPI::listunspent(int minconf, int maxconf) { + std::vector addresses; + return this->listunspent(minconf, maxconf, addresses); +} + vector BitcoinAPI::listlockunspent() { string command = "listlockunspent"; Value params, result; @@ -868,7 +927,7 @@ vector BitcoinAPI::listlockunspent() { result = sendcommand(command, params); for(ValueIterator it = result.begin(); it != result.end(); it++){ - Value val = (*it); + Value &val = (*it); txout_t tmp; tmp.txid = val["txid"].asString(); @@ -1003,23 +1062,26 @@ mininginfo_t BitcoinAPI::getmininginfo() { } -txsinceblock_t BitcoinAPI::listsinceblock(const string& blockhash, int target_confirmations) { +txsinceblock_t BitcoinAPI::listsinceblock(const string& blockhash, int target_confirmations, bool includewatchonly) { string command = "listsinceblock"; Value params, result; txsinceblock_t ret; params.append(blockhash); params.append(target_confirmations); + params.append(includewatchonly); result = sendcommand(command, params); for(ValueIterator it = result["transactions"].begin(); it != result["transactions"].end(); it++){ - Value val = (*it); + Value &val = (*it); transactioninfo_t tmp; + tmp.involvesWatchonly = val["involvesWatchonly"].asBool(); tmp.account = val["account"].asString(); tmp.address = val["address"].asString(); tmp.category = val["category"].asString(); tmp.amount = val["amount"].asDouble(); + tmp.fee = val["fee"].asDouble(); tmp.confirmations = val["confirmations"].asInt(); tmp.blockhash = val["blockhash"].asString(); tmp.blockindex = val["blockindex"].asInt(); @@ -1061,7 +1123,7 @@ getrawtransaction_t BitcoinAPI::getrawtransaction(const string& txid, int verbos ret.locktime = result["locktime"].asInt(); for (ValueIterator it = result["vin"].begin(); it != result["vin"].end(); it++) { - Value val = (*it); + Value &val = (*it); vin_t input; input.txid = val["txid"].asString(); input.n = val["vout"].asUInt(); @@ -1073,7 +1135,7 @@ getrawtransaction_t BitcoinAPI::getrawtransaction(const string& txid, int verbos for (ValueIterator it = result["vout"].begin(); it != result["vout"].end(); it++) { - Value val = (*it); + Value &val = (*it); vout_t output; output.value = val["value"].asDouble(); @@ -1112,7 +1174,7 @@ decodescript_t BitcoinAPI::decodescript(const std::string& hexString) { ret.p2sh = result["p2sh"].asString(); for (ValueIterator it = result["addresses"].begin(); it != result["addresses"].end(); it++) { - Value val = (*it); + Value &val = (*it); ret.addresses.push_back(val.asString()); } @@ -1132,7 +1194,7 @@ decoderawtransaction_t BitcoinAPI::decoderawtransaction(const string& hexString) ret.locktime = result["locktime"].asInt(); for (ValueIterator it = result["vin"].begin(); it != result["vin"].end(); it++) { - Value val = (*it); + Value &val = (*it); vin_t input; input.txid = val["txid"].asString(); input.n = val["vout"].asUInt(); @@ -1144,7 +1206,7 @@ decoderawtransaction_t BitcoinAPI::decoderawtransaction(const string& hexString) for (ValueIterator it = result["vout"].begin(); it != result["vout"].end(); it++) { - Value val = (*it); + Value &val = (*it); vout_t output; output.value = val["value"].asDouble(); @@ -1361,3 +1423,274 @@ utxosetinfo_t BitcoinAPI::gettxoutsetinfo() { return ret; } + +#ifdef _OMNI_SUPPORT_ + +omni_transaction_t BitcoinAPI::omni_gettransaction(const std::string& txid) +{ + string command = "omni_gettransaction"; + Value params, result; + omni_transaction_t ret; + + params.append(txid); + + result = sendcommand(command, params); + + ret.txid = result["txid"].asString(); + ret.sendingaddress = result["sendingaddress"].asString(); + ret.referenceaddress = result["referenceaddress"].asString(); + ret.ismine = result["ismine"].asBool(); + ret.confirmations = result["confirmations"].asInt(); + ret.fee = stod(result["fee"].asString()); + ret.blocktime = result["blocktime"].asUInt(); + ret.valid = result["valid"].asBool(); + ret.positioninblock = result["positioninblock"].asUInt(); + ret.version = result["version"].asInt(); + ret.type_int = result["type_int"].asInt(); + ret.type = result["type"].asString(); + ret.blockhash = result["blockhash"].asString(); + ret.block = result["block"].asUInt(); + + if(ret.type_int == OMNI_TYPE_SIMPLE_SEND) + { + ret.propertyid = result["propertyid"].asInt(); + ret.amount = stod(result["amount"].asString()); + } + else if (ret.type_int == OMNI_TYPE_SEND_ALL) + { + for(ValueIterator it2 = result["subsends"].begin(); it2 != result["subsends"].end(); it2++) + { + omni_subsend_t tmp2; + Value &val2 = (*it2); + tmp2.propertyid = val2["propertyid"].asInt(); + tmp2.divisible = val2["divisible"].asBool(); + tmp2.amount = stod(val2["amount"].asString()); + ret.subsends.push_back(tmp2); + } + } + else + { + ret.propertyid = result["propertyid"].asInt(); + // let's just try to parse + try{ + ret.amount = stod(result["amount"].asString()); + } + catch (std::invalid_argument e) { + ret.amount = 0; + } + } + + return ret; +} + +std::string BitcoinAPI::omni_send(const std::string& fromaddress, const std::string& toaddress, int propertyid, double amount) +{ + string command = "omni_send"; + Value params, result; + + params.append(fromaddress); + params.append(toaddress); + params.append(propertyid); + params.append(std::to_string(amount)); + + result = sendcommand(command, params); + return result.asString(); +} + +std::string BitcoinAPI::omni_funded_send(const std::string& fromaddress, const std::string& toaddress, int propertyid, double amount, const std::string& feeaddress) +{ + string command = "omni_funded_send"; + Value params, result; + + params.append(fromaddress); + params.append(toaddress); + params.append(propertyid); + params.append(std::to_string(amount)); + params.append(feeaddress); + + result = sendcommand(command, params); + return result.asString(); +} + +std::string BitcoinAPI::omni_funded_sendall(const std::string& fromaddress, const std::string& toaddress, int ecosystem, const std::string& feeaddress) +{ + string command = "omni_funded_sendall"; + Value params, result; + + params.append(fromaddress); + params.append(toaddress); + params.append(ecosystem); + params.append(feeaddress); + + result = sendcommand(command, params); + return result.asString(); +} + +std::vector BitcoinAPI::omni_getwalletaddressbalances(bool includewatchonly) +{ + string command = "omni_getwalletaddressbalances"; + Value params, result; + vector ret; + + params.append(includewatchonly); + result = sendcommand(command, params); + + for(ValueIterator it = result.begin(); it != result.end(); it++){ + omni_address_balance_t tmp; + Value &val = (*it); + tmp.address = val["address"].asString(); + + for(ValueIterator it2 = val["balances"].begin(); it2 != val["balances"].end(); it2++){ + omni_detailed_balance_t tmp2; + Value &val2 = (*it2); + + tmp2.balance = stod(val2["balance"].asString()); + tmp2.reserved = stod(val2["reserved"].asString()); + tmp2.frozen = stod(val2["frozen"].asString()); + tmp2.name = val2["name"].asString(); + tmp2.propertyid = val2["propertyid"].asInt(); + + tmp.balances.push_back(tmp2); + } + ret.push_back(tmp); + } + + return ret; +} + + +std::vector BitcoinAPI::omni_getwalletbalances(bool includewatchonly) +{ + string command = "omni_getwalletbalances"; + Value params, result; + vector ret; + + params.append(includewatchonly); + result = sendcommand(command, params); + + for(ValueIterator it = result.begin(); it != result.end(); it++){ + omni_detailed_balance_t tmp; + Value &val = (*it); + + tmp.balance = stod(val["balance"].asString()); + tmp.reserved = stod(val["reserved"].asString()); + tmp.frozen = stod(val["frozen"].asString()); + tmp.name = val["name"].asString(); + tmp.propertyid = val["propertyid"].asInt(); + + ret.push_back(tmp); + } + + return ret; +} + +omni_balance_t BitcoinAPI::omni_getbalance(const std::string& address, int propertyid) +{ + string command = "omni_getbalance"; + Value params, result; + omni_balance_t ret; + + params.append(address); + params.append(propertyid); + + result = sendcommand(command, params); + + ret.balance = stod(result["balance"].asString()); + ret.reserved = stod(result["reserved"].asString()); + ret.frozen = stod(result["frozen"].asString()); + + return ret; +} + +omni_transaction_t omni_parsetransaction(const ValueIterator& it) +{ + omni_transaction_t tmp; + Value &val = (*it); + tmp.txid = val["txid"].asString(); + tmp.sendingaddress = val["sendingaddress"].asString(); + tmp.referenceaddress = val["referenceaddress"].asString(); + tmp.ismine = val["ismine"].asBool(); + tmp.fee = stod(val["fee"].asString()); + tmp.version = val["version"].asInt(); + tmp.type_int = val["type_int"].asInt(); + tmp.type = val["type"].asString(); + + tmp.confirmations = val["confirmations"].isInt() ? val["confirmations"].asInt() : 0; + tmp.blocktime = val["blocktime"].isUInt() ? val["blocktime"].asUInt() : 0; + tmp.valid = val["valid"].isBool() ? val["valid"].asBool() : false; + tmp.positioninblock = val["positioninblock"].isUInt() ? val["positioninblock"].asUInt() : 0; + tmp.blockhash = val["blockhash"].isString() ? val["blockhash"].asString() : ""; + tmp.block = val["block"].isUInt() ? val["block"].asUInt() : 0; + + if(tmp.type_int == OMNI_TYPE_SIMPLE_SEND) + { + tmp.propertyid = val["propertyid"].isInt() ? val["propertyid"].asInt() : 0; + tmp.amount = val["amount"].isString() ? stod(val["amount"].asString()) : 0; + } + else if (tmp.type_int == OMNI_TYPE_SEND_ALL) + { + for(ValueIterator it2 = val["subsends"].begin(); it2 != val["subsends"].end(); it2++) + { + omni_subsend_t tmp2; + Value &val2 = (*it2); + tmp2.propertyid = val2["propertyid"].isInt() ? val2["propertyid"].asInt() : 0; + tmp2.divisible = val2["divisible"].isBool() ? val2["divisible"].asBool() : false; + tmp2.amount = val2["amount"].isString() ? stod(val2["amount"].asString()) : 0; + tmp.subsends.push_back(tmp2); + } + } + else + { + tmp.propertyid = val["propertyid"].isInt() ? val["propertyid"].asInt() : 0; + // let's just try to parse + try{ + tmp.amount = stod(val["amount"].asString()); + } + catch (std::invalid_argument e) { + tmp.amount = 0; + } + } + + return tmp; +} + +std::vector BitcoinAPI::omni_listtransactions(const std::string& txid, int count, int skip, int startblock, int endblock) +{ + string command = "omni_listtransactions"; + Value params, result; + vector ret; + + params.append(txid); + params.append(count); + params.append(skip); + params.append(startblock); + params.append(endblock); + result = sendcommand(command, params); + + for(ValueIterator it = result.begin(); it != result.end(); it++){ + omni_transaction_t tmp = omni_parsetransaction(it); + ret.push_back(tmp); + } + + return ret; +} + + +std::vector BitcoinAPI::omni_listpendingtransactions(const std::string& address) +{ + string command = "omni_listpendingtransactions"; + Value params, result; + vector ret; + + params.append(address); + result = sendcommand(command, params); + + for(ValueIterator it = result.begin(); it != result.end(); it++){ + omni_transaction_t tmp = omni_parsetransaction(it); + ret.push_back(tmp); + } + + return ret; +} + +#endif diff --git a/src/bitcoinapi/bitcoinapi.h b/src/bitcoinapi/bitcoinapi.h index fdd17a5..610eb9b 100644 --- a/src/bitcoinapi/bitcoinapi.h +++ b/src/bitcoinapi/bitcoinapi.h @@ -11,6 +11,8 @@ #ifndef BITCOIN_API_H #define BITCOIN_API_H +#define _OMNI_SUPPORT_ + #include "types.h" #include "exception.h" @@ -26,8 +28,23 @@ class BitcoinAPI public: /* === Constructor and Destructor === */ BitcoinAPI(const std::string& user, const std::string& password, const std::string& host, int port, int httpTimeout = 50000); + BitcoinAPI(const std::string& user, const std::string& password, const std::string& host, int port, const std::string& wallet, int httpTimeout = 50000); ~BitcoinAPI(); + #ifdef _OMNI_SUPPORT_ + std::string omni_send(const std::string& fromaddress, const std::string& toaddress, int propertyid, double amount); + std::string omni_funded_sendall(const std::string& fromaddress, const std::string& toaddress, int ecosystem, const std::string& feeaddress); + std::string omni_funded_send(const std::string& fromaddress, const std::string& toaddress, int propertyid, double amount, const std::string& feeaddress); + std::vector omni_getwalletbalances(bool includewatchonly); + std::vector omni_getwalletaddressbalances(bool includewatchonly); + + omni_balance_t omni_getbalance(const std::string& address, int propertyid); + omni_transaction_t omni_gettransaction(const std::string& txid); + std::vector omni_listtransactions(const std::string& txid = "*", int count = 10, int skip = 0, int startblock = 0, int endblock = 999999999); + std::vector omni_listpendingtransactions(const std::string& address = ""); + + #endif + /* === Auxiliary functions === */ Json::Value sendcommand(const std::string& command, const Json::Value& params); @@ -60,10 +77,12 @@ class BitcoinAPI multisig_t createmultisig(int nrequired, const std::vector& keys); std::string getnewaddress(const std::string& account = ""); validateaddress_t validateaddress(const std::string& bitcoinaddress); + getaddressinfo_t getaddressinfo(const std::string& bitcoinaddress); void keypoolrefill(); bool settxfee(double amount); double estimatefee(int blocks); + smartfee_t estimatesmartfee(int blocks); std::string signmessage(const std::string& bitcoinaddress, const std::string& message); bool verifymessage(const std::string& bitcoinaddress, const std::string& signature, const std::string& message); @@ -82,7 +101,7 @@ class BitcoinAPI std::vector listreceivedbyaccount(int minconf = 1, bool includeempty = false); std::vector listreceivedbyaddress(int minconf = 1, bool includeempty = false); - + gettransaction_t gettransaction(const std::string& tx, bool watch); std::vector listtransactions(); std::vector listtransactions(const std::string& account, int count = 10, int from = 0); @@ -113,6 +132,7 @@ class BitcoinAPI utxosetinfo_t gettxoutsetinfo(); std::vector listunspent(int minconf = 1, int maxconf = 999999); + std::vector listunspent(int minconf, int maxconf, const std::vector& addresses); std::vector listlockunspent(); bool lockunspent(bool unlock, const std::vector& outputs); @@ -133,7 +153,7 @@ class BitcoinAPI workdata_t getwork(); bool getwork(const std::string& data); - txsinceblock_t listsinceblock(const std::string& blockhash = "", int target_confirmations = 1); + txsinceblock_t listsinceblock(const std::string& blockhash = "", int target_confirmations = 1, bool includewatchonly = false); /* === Low level calls === */ diff --git a/src/bitcoinapi/exception.h b/src/bitcoinapi/exception.h index ccdbc3d..dfd1ee3 100644 --- a/src/bitcoinapi/exception.h +++ b/src/bitcoinapi/exception.h @@ -40,7 +40,7 @@ class BitcoinException: public std::exception /* Authentication error */ }else if(errcode == Errors::ERROR_RPC_INTERNAL_ERROR && message.size() == 18){ this->code = errcode; - this->msg = "Failed to authenticate successfully"; + this->msg = "Failed to authenticate successfully. " + message; /* Miscellaneous error */ }else{ this->code = parseCode(message); diff --git a/src/bitcoinapi/types.h b/src/bitcoinapi/types.h index 92fa6fa..c7650b9 100644 --- a/src/bitcoinapi/types.h +++ b/src/bitcoinapi/types.h @@ -77,6 +77,7 @@ }; struct transactioninfo_t: accountinfo_t{ + bool involvesWatchonly; std::string address; std::string category; std::string blockhash; @@ -86,6 +87,7 @@ std::vector walletconflicts; int time; int timereceived; + double fee; }; struct multisig_t{ @@ -101,6 +103,40 @@ std::string pubkey; bool iscompressed; std::string account; + bool iswatchonly; + }; + + struct getaddressinfo_t { + std::string address; + std::string scriptPubKey; + bool ismine; + bool iswatchonly; + bool isscript; + bool iswitness; + /* + double witness_version; + std::string witness_program; + std::string script; + std::string hex; + std::vector pubkeys; + double sigsrequired; + std::string pubkey; + "embedded" : {...}, (object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known. It includes all getaddressinfo output fields for the embedded address, excluding metadata ("timestamp", "hdkeypath", "hdseedid") and relation to the wallet ("ismine", "iswatchonly", "account"). + "iscompressed" : true|false, (boolean) If the address is compressed + "label" : "label" (string) The label associated with the address, "" is the default account + "account" : "account" (string) DEPRECATED. This field will be removed in V0.18. To see this deprecated field, start bitcoind with -deprecatedrpc=accounts. The account associated with the address, "" is the default account + "timestamp" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT) + "hdkeypath" : "keypath" (string, optional) The HD keypath if the key is HD and available + "hdseedid" : "" (string, optional) The Hash160 of the HD seed + "hdmasterkeyid" : "" (string, optional) alias for hdseedid maintained for backwards compatibility. Will be removed in V0.18. + "labels" (object) Array of labels associated with the address. + [ + { (json object of label data) + "name": "labelname" (string) The label + "purpose": "string" (string) Purpose of address ("send" for sending address, "receive" for receiving address) + },... + ] + */ }; struct addressgrouping_t{ @@ -209,6 +245,11 @@ /* === Other === */ + + struct smartfee_t{ + double feerate; + int blocks; + }; struct utxoinfo_t{ std::string bestblock; int confirmations; @@ -232,10 +273,59 @@ std::string address; std::string account; std::string scriptPubKey; + bool spendable; double amount; int confirmations; }; + #ifdef _OMNI_SUPPORT_ + + struct omni_subsend_t { + int propertyid; + bool divisible; + double amount; + }; + + struct omni_transaction_t { + std::string txid; + std::string sendingaddress; + std::string referenceaddress; + int propertyid; + bool ismine; + int confirmations; + double amount; + std::string blockhash; + unsigned int block; + double fee; + unsigned int blocktime; + bool valid; + unsigned int positioninblock; + int version; + int type_int; + std::string type; + std::vector subsends; + }; + + + + struct omni_balance_t { + double balance; + double reserved; + double frozen; + }; + + struct omni_detailed_balance_t: omni_balance_t{ + int propertyid; + std::string name; + }; + + struct omni_address_balance_t{ + std::string address; + std::vector balances; + }; + + #endif + /* === Unused yet === */ struct blockinfo_t{