Fetch addresses

This commit is contained in:
Aditya Kulkarni
2019-10-18 10:48:36 -07:00
parent aa2248ea5a
commit 547f566e05
3 changed files with 14 additions and 34 deletions

View File

@@ -254,31 +254,31 @@ void Controller::refreshAddresses() {
return noConnection();
auto newzaddresses = new QList<QString>();
auto newtaddresses = new QList<QString>();
zrpc->fetchZAddresses([=] (json reply) {
for (auto& it : reply.get<json::array_t>()) {
zrpc->fetchAddresses([=] (json reply) {
auto zaddrs = reply["z_addresses"].get<json::array_t>();
for (auto& it : zaddrs) {
auto addr = QString::fromStdString(it.get<json::string_t>());
newzaddresses->push_back(addr);
}
model->replaceZaddresses(newzaddresses);
// Refresh the sent and received txs from all these z-addresses
refreshSentZTrans();
refreshReceivedZTrans(model->getAllZAddresses());
});
auto newtaddresses = new QList<QString>();
zrpc->fetchTAddresses([=] (json reply) {
for (auto& it : reply.get<json::array_t>()) {
auto taddrs = reply["t_addresses"].get<json::array_t>();
for (auto& it : taddrs) {
auto addr = QString::fromStdString(it.get<json::string_t>());
if (Settings::isTAddress(addr))
newtaddresses->push_back(addr);
}
model->replaceTaddresses(newtaddresses);
// Refresh the sent and received txs from all these z-addresses
refreshSentZTrans();
refreshReceivedZTrans(model->getAllZAddresses());
});
}
// Function to create the data model and update the views, used below.

View File

@@ -20,32 +20,13 @@ bool LiteInterface::haveConnection() {
return conn != nullptr;
}
void LiteInterface::fetchTAddresses(const std::function<void(json)>& cb) {
void LiteInterface::fetchAddresses(const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
// json payload = {
// {"jsonrpc", "1.0"},
// {"id", "someid"},
// {"method", "getaddressesbyaccount"},
// {"params", {""}}
// };
// conn->doRPCWithDefaultErrorHandling(payload, cb);
conn->doRPCWithDefaultErrorHandling("addresses", "", cb);
}
void LiteInterface::fetchZAddresses(const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
// json payload = {
// {"jsonrpc", "1.0"},
// {"id", "someid"},
// {"method", "z_listaddresses"},
// };
// conn->doRPCWithDefaultErrorHandling(payload, cb);
}
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) {
if (conn == nullptr)

View File

@@ -30,8 +30,7 @@ public:
void fetchUnspent (const std::function<void(json)>& cb);
void fetchTransactions (const std::function<void(json)>& cb);
void fetchZAddresses (const std::function<void(json)>& cb);
void fetchTAddresses (const std::function<void(json)>& cb);
void fetchAddresses (const std::function<void(json)>& cb);
void fetchReceivedZTrans(QList<QString> zaddrs, const std::function<void(QString)> usedAddrFn,
const std::function<void(QList<TransactionItem>)> txdataFn);