Merge branch 'bug/336-exception-parse-json' into 'develop'
#336 exception parse json See merge request PBSA/peerplays!95
This commit is contained in:
commit
d7c654500e
1 changed files with 709 additions and 590 deletions
|
|
@ -41,6 +41,7 @@ bitcoin_rpc_client::bitcoin_rpc_client(std::string _ip, uint32_t _rpc, std::stri
|
||||||
std::string bitcoin_rpc_client::addmultisigaddress(const uint32_t nrequired, const std::vector<std::string> public_keys) {
|
std::string bitcoin_rpc_client::addmultisigaddress(const uint32_t nrequired, const std::vector<std::string> public_keys) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"addmultisigaddress\", "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"addmultisigaddress\", "
|
||||||
"\"method\": \"addmultisigaddress\", \"params\": [");
|
"\"method\": \"addmultisigaddress\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string params = std::to_string(nrequired) + ", [";
|
std::string params = std::to_string(nrequired) + ", [";
|
||||||
std::string pubkeys = "";
|
std::string pubkeys = "";
|
||||||
for (std::string pubkey : public_keys) {
|
for (std::string pubkey : public_keys) {
|
||||||
|
|
@ -71,11 +72,16 @@ std::string bitcoin_rpc_client::addmultisigaddress(const uint32_t nrequired, con
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::combinepsbt(const vector<std::string> &psbts) {
|
std::string bitcoin_rpc_client::combinepsbt(const vector<std::string> &psbts) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"combinepsbt\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"combinepsbt\", \"method\": "
|
||||||
"\"combinepsbt\", \"params\": [[");
|
"\"combinepsbt\", \"params\": [[");
|
||||||
|
try {
|
||||||
std::string params = "";
|
std::string params = "";
|
||||||
for (std::string psbt : psbts) {
|
for (std::string psbt : psbts) {
|
||||||
if (!params.empty()) {
|
if (!params.empty()) {
|
||||||
|
|
@ -105,11 +111,16 @@ std::string bitcoin_rpc_client::combinepsbt(const vector<std::string> &psbts) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::createmultisig(const uint32_t nrequired, const std::vector<std::string> public_keys) {
|
std::string bitcoin_rpc_client::createmultisig(const uint32_t nrequired, const std::vector<std::string> public_keys) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"createmultisig\", "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"createmultisig\", "
|
||||||
"\"method\": \"createmultisig\", \"params\": [");
|
"\"method\": \"createmultisig\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string params = std::to_string(nrequired) + ", [";
|
std::string params = std::to_string(nrequired) + ", [";
|
||||||
std::string pubkeys = "";
|
std::string pubkeys = "";
|
||||||
for (std::string pubkey : public_keys) {
|
for (std::string pubkey : public_keys) {
|
||||||
|
|
@ -140,11 +151,16 @@ std::string bitcoin_rpc_client::createmultisig(const uint32_t nrequired, const s
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::createpsbt(const std::vector<btc_txout> &ins, const fc::flat_map<std::string, double> outs) {
|
std::string bitcoin_rpc_client::createpsbt(const std::vector<btc_txout> &ins, const fc::flat_map<std::string, double> outs) {
|
||||||
std::string body("{\"jsonrpc\": \"1.0\", \"id\":\"createpsbt\", "
|
std::string body("{\"jsonrpc\": \"1.0\", \"id\":\"createpsbt\", "
|
||||||
"\"method\": \"createpsbt\", \"params\": [");
|
"\"method\": \"createpsbt\", \"params\": [");
|
||||||
|
try {
|
||||||
body += "[";
|
body += "[";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const auto &entry : ins) {
|
for (const auto &entry : ins) {
|
||||||
|
|
@ -184,11 +200,16 @@ std::string bitcoin_rpc_client::createpsbt(const std::vector<btc_txout> &ins, co
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::createrawtransaction(const std::vector<btc_txout> &ins, const fc::flat_map<std::string, double> outs) {
|
std::string bitcoin_rpc_client::createrawtransaction(const std::vector<btc_txout> &ins, const fc::flat_map<std::string, double> outs) {
|
||||||
std::string body("{\"jsonrpc\": \"1.0\", \"id\":\"createrawtransaction\", "
|
std::string body("{\"jsonrpc\": \"1.0\", \"id\":\"createrawtransaction\", "
|
||||||
"\"method\": \"createrawtransaction\", \"params\": [");
|
"\"method\": \"createrawtransaction\", \"params\": [");
|
||||||
|
try {
|
||||||
body += "[";
|
body += "[";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const auto &entry : ins) {
|
for (const auto &entry : ins) {
|
||||||
|
|
@ -228,13 +249,17 @@ std::string bitcoin_rpc_client::createrawtransaction(const std::vector<btc_txout
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::createwallet(const std::string &wallet_name) {
|
std::string bitcoin_rpc_client::createwallet(const std::string &wallet_name) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"createwallet\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"createwallet\", \"method\": "
|
||||||
"\"createwallet\", \"params\": [\"" +
|
"\"createwallet\", \"params\": [\"" +
|
||||||
wallet_name + "\"] }");
|
wallet_name + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -256,13 +281,17 @@ std::string bitcoin_rpc_client::createwallet(const std::string &wallet_name) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::decodepsbt(std::string const &tx_psbt) {
|
std::string bitcoin_rpc_client::decodepsbt(std::string const &tx_psbt) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"decodepsbt\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"decodepsbt\", \"method\": "
|
||||||
"\"decodepsbt\", \"params\": [\"" +
|
"\"decodepsbt\", \"params\": [\"" +
|
||||||
tx_psbt + "\"] }");
|
tx_psbt + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -284,13 +313,17 @@ std::string bitcoin_rpc_client::decodepsbt(std::string const &tx_psbt) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::decoderawtransaction(std::string const &tx_hex) {
|
std::string bitcoin_rpc_client::decoderawtransaction(std::string const &tx_hex) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"decoderawtransaction\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"decoderawtransaction\", \"method\": "
|
||||||
"\"decoderawtransaction\", \"params\": [\"" +
|
"\"decoderawtransaction\", \"params\": [\"" +
|
||||||
tx_hex + "\"] }");
|
tx_hex + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -312,13 +345,17 @@ std::string bitcoin_rpc_client::decoderawtransaction(std::string const &tx_hex)
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::encryptwallet(const std::string &passphrase) {
|
std::string bitcoin_rpc_client::encryptwallet(const std::string &passphrase) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"encryptwallet\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"encryptwallet\", \"method\": "
|
||||||
"\"encryptwallet\", \"params\": [\"" +
|
"\"encryptwallet\", \"params\": [\"" +
|
||||||
passphrase + "\"] }");
|
passphrase + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -340,13 +377,17 @@ std::string bitcoin_rpc_client::encryptwallet(const std::string &passphrase) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t bitcoin_rpc_client::estimatesmartfee(uint16_t conf_target) {
|
uint64_t bitcoin_rpc_client::estimatesmartfee(uint16_t conf_target) {
|
||||||
const auto body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"estimatesmartfee\", "
|
const auto body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"estimatesmartfee\", "
|
||||||
"\"method\": \"estimatesmartfee\", \"params\": [" +
|
"\"method\": \"estimatesmartfee\", \"params\": [" +
|
||||||
std::to_string(conf_target) + std::string("] }"));
|
std::to_string(conf_target) + std::string("] }"));
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -377,13 +418,17 @@ uint64_t bitcoin_rpc_client::estimatesmartfee(uint16_t conf_target) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return 20000;
|
return 20000;
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return 20000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::finalizepsbt(std::string const &tx_psbt) {
|
std::string bitcoin_rpc_client::finalizepsbt(std::string const &tx_psbt) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"finalizepsbt\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"finalizepsbt\", \"method\": "
|
||||||
"\"finalizepsbt\", \"params\": [\"" +
|
"\"finalizepsbt\", \"params\": [\"" +
|
||||||
tx_psbt + "\"] }");
|
tx_psbt + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -403,13 +448,17 @@ std::string bitcoin_rpc_client::finalizepsbt(std::string const &tx_psbt) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::getaddressinfo(const std::string &address) {
|
std::string bitcoin_rpc_client::getaddressinfo(const std::string &address) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getaddressinfo\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getaddressinfo\", \"method\": "
|
||||||
"\"getaddressinfo\", \"params\": [\"" +
|
"\"getaddressinfo\", \"params\": [\"" +
|
||||||
address + "\"] }");
|
address + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -431,13 +480,17 @@ std::string bitcoin_rpc_client::getaddressinfo(const std::string &address) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::getblock(const std::string &block_hash, int32_t verbosity) {
|
std::string bitcoin_rpc_client::getblock(const std::string &block_hash, int32_t verbosity) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getblock\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getblock\", \"method\": "
|
||||||
"\"getblock\", \"params\": [\"" +
|
"\"getblock\", \"params\": [\"" +
|
||||||
block_hash + "\", " + std::to_string(verbosity) + "] }");
|
block_hash + "\", " + std::to_string(verbosity) + "] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -459,12 +512,16 @@ std::string bitcoin_rpc_client::getblock(const std::string &block_hash, int32_t
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::getnetworkinfo() {
|
std::string bitcoin_rpc_client::getnetworkinfo() {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getnetworkinfo\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getnetworkinfo\", \"method\": "
|
||||||
"\"getnetworkinfo\", \"params\": [] }");
|
"\"getnetworkinfo\", \"params\": [] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -485,12 +542,16 @@ std::string bitcoin_rpc_client::getnetworkinfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::getrawtransaction(const std::string &txid, const bool verbose) {
|
std::string bitcoin_rpc_client::getrawtransaction(const std::string &txid, const bool verbose) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getrawtransaction\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getrawtransaction\", \"method\": "
|
||||||
"\"getrawtransaction\", \"params\": [");
|
"\"getrawtransaction\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string params = "\"" + txid + "\", " + (verbose ? "true" : "false");
|
std::string params = "\"" + txid + "\", " + (verbose ? "true" : "false");
|
||||||
body = body + params + "] }";
|
body = body + params + "] }";
|
||||||
|
|
||||||
|
|
@ -513,12 +574,16 @@ std::string bitcoin_rpc_client::getrawtransaction(const std::string &txid, const
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::gettransaction(const std::string &txid, const bool include_watch_only) {
|
std::string bitcoin_rpc_client::gettransaction(const std::string &txid, const bool include_watch_only) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"gettransaction\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"gettransaction\", \"method\": "
|
||||||
"\"gettransaction\", \"params\": [");
|
"\"gettransaction\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string params = "\"" + txid + "\", " + (include_watch_only ? "true" : "false");
|
std::string params = "\"" + txid + "\", " + (include_watch_only ? "true" : "false");
|
||||||
body = body + params + "] }";
|
body = body + params + "] }";
|
||||||
|
|
||||||
|
|
@ -541,12 +606,16 @@ std::string bitcoin_rpc_client::gettransaction(const std::string &txid, const bo
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::getblockchaininfo() {
|
std::string bitcoin_rpc_client::getblockchaininfo() {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getblockchaininfo\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"getblockchaininfo\", \"method\": "
|
||||||
"\"getblockchaininfo\", \"params\": [] }");
|
"\"getblockchaininfo\", \"params\": [] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -568,12 +637,16 @@ std::string bitcoin_rpc_client::getblockchaininfo() {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitcoin_rpc_client::importaddress(const std::string &address_or_script, const std::string &label, const bool rescan, const bool p2sh) {
|
void bitcoin_rpc_client::importaddress(const std::string &address_or_script, const std::string &label, const bool rescan, const bool p2sh) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"importaddress\", "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"importaddress\", "
|
||||||
"\"method\": \"importaddress\", \"params\": [");
|
"\"method\": \"importaddress\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string params = "\"" + address_or_script + "\", " +
|
std::string params = "\"" + address_or_script + "\", " +
|
||||||
"\"" + label + "\", " +
|
"\"" + label + "\", " +
|
||||||
(rescan ? "true" : "false") + ", " +
|
(rescan ? "true" : "false") + ", " +
|
||||||
|
|
@ -596,12 +669,15 @@ void bitcoin_rpc_client::importaddress(const std::string &address_or_script, con
|
||||||
} else if (json.count("error") && !json.get_child("error").empty()) {
|
} else if (json.count("error") && !json.get_child("error").empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitcoin_rpc_client::importmulti(const std::vector<multi_params> &address_or_script_array, const bool rescan) {
|
void bitcoin_rpc_client::importmulti(const std::vector<multi_params> &address_or_script_array, const bool rescan) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"importmulti\", "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"importmulti\", "
|
||||||
"\"method\": \"importmulti\", \"params\": [");
|
"\"method\": \"importmulti\", \"params\": [");
|
||||||
|
try {
|
||||||
std::string argument_1 = "[";
|
std::string argument_1 = "[";
|
||||||
for (const auto ¶m : address_or_script_array) {
|
for (const auto ¶m : address_or_script_array) {
|
||||||
argument_1 += "{\"scriptPubKey\": ";
|
argument_1 += "{\"scriptPubKey\": ";
|
||||||
|
|
@ -647,6 +723,9 @@ void bitcoin_rpc_client::importmulti(const std::vector<multi_params> &address_or
|
||||||
} else if (json.count("error") && !json.get_child("error").empty()) {
|
} else if (json.count("error") && !json.get_child("error").empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<btc_txout> bitcoin_rpc_client::listunspent(const uint32_t minconf, const uint32_t maxconf) {
|
std::vector<btc_txout> bitcoin_rpc_client::listunspent(const uint32_t minconf, const uint32_t maxconf) {
|
||||||
|
|
@ -654,9 +733,9 @@ std::vector<btc_txout> bitcoin_rpc_client::listunspent(const uint32_t minconf, c
|
||||||
"\"listunspent\", \"params\": [" +
|
"\"listunspent\", \"params\": [" +
|
||||||
std::to_string(minconf) + "," + std::to_string(maxconf) + "] }");
|
std::to_string(minconf) + "," + std::to_string(maxconf) + "] }");
|
||||||
|
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
|
||||||
|
|
||||||
std::vector<btc_txout> result;
|
std::vector<btc_txout> result;
|
||||||
|
try {
|
||||||
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
|
|
@ -683,6 +762,10 @@ std::vector<btc_txout> bitcoin_rpc_client::listunspent(const uint32_t minconf, c
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<btc_txout> bitcoin_rpc_client::listunspent_by_address_and_amount(const std::string &address, double minimum_amount, const uint32_t minconf, const uint32_t maxconf) {
|
std::vector<btc_txout> bitcoin_rpc_client::listunspent_by_address_and_amount(const std::string &address, double minimum_amount, const uint32_t minconf, const uint32_t maxconf) {
|
||||||
|
|
@ -695,9 +778,11 @@ std::vector<btc_txout> bitcoin_rpc_client::listunspent_by_address_and_amount(con
|
||||||
body += std::to_string(minimum_amount);
|
body += std::to_string(minimum_amount);
|
||||||
body += std::string("} ] }");
|
body += std::string("} ] }");
|
||||||
|
|
||||||
|
std::vector<btc_txout> result;
|
||||||
|
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
std::vector<btc_txout> result;
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -723,13 +808,17 @@ std::vector<btc_txout> bitcoin_rpc_client::listunspent_by_address_and_amount(con
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::loadwallet(const std::string &filename) {
|
std::string bitcoin_rpc_client::loadwallet(const std::string &filename) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"loadwallet\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"loadwallet\", \"method\": "
|
||||||
"\"loadwallet\", \"params\": [\"" +
|
"\"loadwallet\", \"params\": [\"" +
|
||||||
filename + "\"] }");
|
filename + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -751,13 +840,17 @@ std::string bitcoin_rpc_client::loadwallet(const std::string &filename) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::sendrawtransaction(const std::string &tx_hex) {
|
std::string bitcoin_rpc_client::sendrawtransaction(const std::string &tx_hex) {
|
||||||
const auto body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"sendrawtransaction\", "
|
const auto body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"sendrawtransaction\", "
|
||||||
"\"method\": \"sendrawtransaction\", \"params\": [") +
|
"\"method\": \"sendrawtransaction\", \"params\": [") +
|
||||||
std::string("\"") + tx_hex + std::string("\"") + std::string("] }");
|
std::string("\"") + tx_hex + std::string("\"") + std::string("] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -777,6 +870,10 @@ std::string bitcoin_rpc_client::sendrawtransaction(const std::string &tx_hex) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::signrawtransactionwithwallet(const std::string &tx_hash) {
|
std::string bitcoin_rpc_client::signrawtransactionwithwallet(const std::string &tx_hash) {
|
||||||
|
|
@ -785,6 +882,7 @@ std::string bitcoin_rpc_client::signrawtransactionwithwallet(const std::string &
|
||||||
std::string params = "\"" + tx_hash + "\"";
|
std::string params = "\"" + tx_hash + "\"";
|
||||||
body = body + params + std::string("]}");
|
body = body + params + std::string("]}");
|
||||||
|
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -804,13 +902,17 @@ std::string bitcoin_rpc_client::signrawtransactionwithwallet(const std::string &
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::unloadwallet(const std::string &filename) {
|
std::string bitcoin_rpc_client::unloadwallet(const std::string &filename) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"unloadwallet\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"unloadwallet\", \"method\": "
|
||||||
"\"unloadwallet\", \"params\": [\"" +
|
"\"unloadwallet\", \"params\": [\"" +
|
||||||
filename + "\"] }");
|
filename + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -832,12 +934,16 @@ std::string bitcoin_rpc_client::unloadwallet(const std::string &filename) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::walletlock() {
|
std::string bitcoin_rpc_client::walletlock() {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletlock\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletlock\", \"method\": "
|
||||||
"\"walletlock\", \"params\": [] }");
|
"\"walletlock\", \"params\": [] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -859,13 +965,17 @@ std::string bitcoin_rpc_client::walletlock() {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string bitcoin_rpc_client::walletprocesspsbt(std::string const &tx_psbt) {
|
std::string bitcoin_rpc_client::walletprocesspsbt(std::string const &tx_psbt) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletprocesspsbt\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletprocesspsbt\", \"method\": "
|
||||||
"\"walletprocesspsbt\", \"params\": [\"" +
|
"\"walletprocesspsbt\", \"params\": [\"" +
|
||||||
tx_psbt + "\"] }");
|
tx_psbt + "\"] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -885,13 +995,17 @@ std::string bitcoin_rpc_client::walletprocesspsbt(std::string const &tx_psbt) {
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bitcoin_rpc_client::walletpassphrase(const std::string &passphrase, uint32_t timeout) {
|
bool bitcoin_rpc_client::walletpassphrase(const std::string &passphrase, uint32_t timeout) {
|
||||||
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletpassphrase\", \"method\": "
|
std::string body = std::string("{\"jsonrpc\": \"1.0\", \"id\":\"walletpassphrase\", \"method\": "
|
||||||
"\"walletpassphrase\", \"params\": [\"" +
|
"\"walletpassphrase\", \"params\": [\"" +
|
||||||
passphrase + "\", " + std::to_string(timeout) + "] }");
|
passphrase + "\", " + std::to_string(timeout) + "] }");
|
||||||
|
try {
|
||||||
const auto reply = send_post_request(body, debug_rpc_calls);
|
const auto reply = send_post_request(body, debug_rpc_calls);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
|
|
@ -911,6 +1025,10 @@ bool bitcoin_rpc_client::walletpassphrase(const std::string &passphrase, uint32_
|
||||||
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
wlog("Bitcoin RPC call ${function} with body ${body} failed with reply '${msg}'", ("function", __FUNCTION__)("body", body)("msg", ss.str()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} catch (const boost::exception &ex) {
|
||||||
|
wlog("Bitcoin RPC call ${function} with body ${body} generate exception: '${exception}'", ("function", __FUNCTION__)("body", body)("exception", boost::diagnostic_information(ex)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::http::reply bitcoin_rpc_client::send_post_request(std::string body, bool show_log) {
|
fc::http::reply bitcoin_rpc_client::send_post_request(std::string body, bool show_log) {
|
||||||
|
|
@ -929,6 +1047,7 @@ fc::http::reply bitcoin_rpc_client::send_post_request(std::string body, bool sho
|
||||||
ilog("### Request URL: ${url}", ("url", url));
|
ilog("### Request URL: ${url}", ("url", url));
|
||||||
ilog("### Request: ${body}", ("body", body));
|
ilog("### Request: ${body}", ("body", body));
|
||||||
std::stringstream ss(std::string(reply.body.begin(), reply.body.end()));
|
std::stringstream ss(std::string(reply.body.begin(), reply.body.end()));
|
||||||
|
ilog("### Response status: ${status}", ("status", reply.status));
|
||||||
ilog("### Response: ${ss}", ("ss", ss.str()));
|
ilog("### Response: ${ss}", ("ss", ss.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue