|
|
@ -104,25 +104,34 @@ void RPC::setConnection(Connection* c) { |
|
|
|
refresh(true); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getTAddresses(const std::function<void(json)>& cb) { |
|
|
|
json RPC::makePayload(std::string method, std::string params) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "getaddressesbyaccount"}, |
|
|
|
{"params", {""}} |
|
|
|
{"id", "42" }, |
|
|
|
{"method", method }, |
|
|
|
{"params", {params}} |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
return payload; |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getZAddresses(const std::function<void(json)>& cb) { |
|
|
|
json RPC::makePayload(std::string method) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "z_listaddresses"}, |
|
|
|
{"id", "42" }, |
|
|
|
{"method", method }, |
|
|
|
}; |
|
|
|
return payload; |
|
|
|
} |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
void RPC::getTAddresses(const std::function<void(json)>& cb) { |
|
|
|
std::string method = "getaddressesbyaccount"; |
|
|
|
std::string params = ""; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method, std::string("")), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getZAddresses(const std::function<void(json)>& cb) { |
|
|
|
std::string method = "z_listaddresses"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getTransparentUnspent(const std::function<void(json)>& cb) { |
|
|
@ -159,35 +168,19 @@ void RPC::newZaddr(bool sapling, const std::function<void(json)>& cb) { |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::newTaddr(const std::function<void(json)>& cb) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "getnewaddress"}, |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
std::string method = "getnewaddress"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getZPrivKey(QString addr, const std::function<void(json)>& cb) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "z_exportkey"}, |
|
|
|
{"params", { addr.toStdString() }}, |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
std::string method = "z_exportkey"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method, addr.toStdString()), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getTPrivKey(QString addr, const std::function<void(json)>& cb) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "dumpprivkey"}, |
|
|
|
{"params", { addr.toStdString() }}, |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
std::string method = "dumpprivkey"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method, addr.toStdString()), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::importZPrivKey(QString privkey, bool rescan, const std::function<void(json)>& cb) { |
|
|
@ -232,15 +225,7 @@ void RPC::importTPrivKey(QString privkey, bool rescan, const std::function<void( |
|
|
|
|
|
|
|
void RPC::validateAddress(QString address, const std::function<void(json)>& cb) { |
|
|
|
QString method = address.startsWith("z") ? "z_validateaddress" : "validateaddress"; |
|
|
|
|
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", method.toStdString() }, |
|
|
|
{"params", { address.toStdString() } }, |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method.toStdString(), address.toStdString()), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getBalance(const std::function<void(json)>& cb) { |
|
|
@ -255,13 +240,8 @@ void RPC::getBalance(const std::function<void(json)>& cb) { |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::getTransactions(const std::function<void(json)>& cb) { |
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "listtransactions"} |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, cb); |
|
|
|
std::string method = "listtransactions"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method), cb); |
|
|
|
} |
|
|
|
|
|
|
|
void RPC::sendZTransaction(json params, const std::function<void(json)>& cb, |
|
|
@ -565,14 +545,9 @@ void RPC::getInfoThenRefresh(bool force) { |
|
|
|
if (conn == nullptr) |
|
|
|
return noConnection(); |
|
|
|
|
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "getinfo"} |
|
|
|
}; |
|
|
|
|
|
|
|
static bool prevCallSucceeded = false; |
|
|
|
conn->doRPC(payload, [=] (const json& reply) { |
|
|
|
std::string method = "getinfo"; |
|
|
|
conn->doRPC(makePayload(method), [=] (const json& reply) { |
|
|
|
prevCallSucceeded = true; |
|
|
|
// Testnet?
|
|
|
|
if (!reply["testnet"].is_null()) { |
|
|
@ -640,7 +615,8 @@ void RPC::getInfoThenRefresh(bool force) { |
|
|
|
{"method", "getnetworksolps"} |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCIgnoreError(payload, [=](const json& reply) { |
|
|
|
std::string method = "getnetworksolps"; |
|
|
|
conn->doRPCIgnoreError(makePayload(method), [=](const json& reply) { |
|
|
|
qint64 solrate = reply.get<json::number_unsigned_t>(); |
|
|
|
|
|
|
|
ui->numconnections->setText(QString::number(connections)); |
|
|
@ -662,13 +638,9 @@ void RPC::getInfoThenRefresh(bool force) { |
|
|
|
ui->localservices->setText(localservices); |
|
|
|
}); |
|
|
|
|
|
|
|
payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "getwalletinfo"} |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCIgnoreError(payload, [=](const json& reply) { |
|
|
|
std::string method2 = "getwalletinfo"; |
|
|
|
conn->doRPCIgnoreError(makePayload(method2), [=](const json& reply) { |
|
|
|
int txcount = reply["txcount"].get<json::number_integer_t>(); |
|
|
|
ui->txcount->setText(QString::number(txcount)); |
|
|
|
}); |
|
|
@ -1185,13 +1157,8 @@ void RPC::shutdownZcashd() { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
json payload = { |
|
|
|
{"jsonrpc", "1.0"}, |
|
|
|
{"id", "someid"}, |
|
|
|
{"method", "stop"} |
|
|
|
}; |
|
|
|
|
|
|
|
conn->doRPCWithDefaultErrorHandling(payload, [=](auto) {}); |
|
|
|
std::string method = "stop"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method), [=](auto) {}); |
|
|
|
conn->shutdown(); |
|
|
|
|
|
|
|
QDialog d(main); |
|
|
@ -1199,8 +1166,8 @@ void RPC::shutdownZcashd() { |
|
|
|
Ui_ConnectionDialog connD; |
|
|
|
connD.setupUi(&d); |
|
|
|
connD.topIcon->setBasePixmap(QIcon(":/icons/res/icon.ico").pixmap(256, 256)); |
|
|
|
connD.status->setText(QObject::tr("Please wait for SilentDragon to exit")); |
|
|
|
connD.statusDetail->setText(QObject::tr("Waiting for hushd to exit")); |
|
|
|
connD.status->setText(QObject::tr("Please enhance your calm and wait for SilentDragon to exit")); |
|
|
|
connD.statusDetail->setText(QObject::tr("Waiting for hushd to exit, y'all")); |
|
|
|
|
|
|
|
QTimer waiter(main); |
|
|
|
|
|
|
|