Skip to content

Commit

Permalink
handle empty lists on unspent address queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Sol committed Aug 11, 2020
1 parent 9f976f8 commit 82aa00a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>
return;
}

auto callnum = new int;
// A special function that will call the callback when two lists have been added
auto holder = new QPair<int, QList<QPair<QString, QString>>>();
holder->first = 0; // This is the number of times the callback has been called, initialized to 0
Expand All @@ -290,7 +291,7 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>

// And if the caller has been called twice, do the parent callback with the
// collected list
if (holder->first == 2) {
if (holder->first == 3) {
// Sort so z addresses are on top
std::sort(holder->second.begin(), holder->second.end(),
[=] (auto a, auto b) { return a.first > b.first; });
Expand All @@ -310,7 +311,12 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>
addrs.push_back(addr.toString());
}

// Then, do a batch request to get all the private keys
if (addrs.isEmpty()){
holder->first++;
return;
}

// Then, do a batch request to get all the private keys
conn->doBatchRPC<QString>(
addrs,
[=] (auto addr) {
Expand Down Expand Up @@ -361,8 +367,8 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>
};

fnDoBatchGetPrivKeys(payloadT, "dumpprivkey");
fnDoBatchGetPrivKeys(payloadZ, "z_exportkey");
fnDoBatchGetPrivKeys(payloadU, "dumpprivkey");
fnDoBatchGetPrivKeys(payloadZ, "z_exportkey");


}
Expand Down

0 comments on commit 82aa00a

Please sign in to comment.