Merge #803: getwalletpakinfo: Use offline counter when reporting lookahead

76fbb4bad getwalletpakinfo: Use offline counter when reporting lookahead (Gregory Sanders)

Pull request description:

  resolves https://github.com/ElementsProject/elements/issues/802

Tree-SHA512: 37cac0979e0cd7a773d6298fcfb86f5e5719694fb20041eadd1556f70a8476fe3993a734fc286caf74ac02caed8ff8c6eb3e0978675d63509e861025599c35c8
This commit is contained in:
Steven Roose 2020-01-15 17:42:59 +00:00
commit c7ee0ac906
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87

View file

@ -1595,8 +1595,11 @@ UniValue getwalletpakinfo(const JSONRPCRequest& request)
ret.pushKV("liquid_pak", HexStr(pwallet->online_key));
ret.pushKV("liquid_pak_address", EncodeDestination(PKHash(pwallet->online_key)));
// We know that the number is non-negative from earlier check
unsigned int counter = (unsigned int)pwallet->offline_counter;
UniValue address_list(UniValue::VARR);
for (unsigned int i = 0; i < 3; i++) {
for (unsigned int i = counter; i < counter+3; i++) {
std::vector<CScript> scripts;
if (!desc->Expand(i, provider, scripts, provider)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Could not generate lookahead addresses with descriptor. This is a bug.");