Skip to content

Commit

Permalink
RPC/Wallet: Add "use_txids" to output of getaddressinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Oct 25, 2019
1 parent 545af21 commit c05d6a8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3689,6 +3689,10 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
" \"name\": \"labelname\" (string) The label\n" " \"name\": \"labelname\" (string) The label\n"
" \"purpose\": \"string\" (string) Purpose of address (\"send\" for sending address, \"receive\" for receiving address)\n" " \"purpose\": \"string\" (string) Purpose of address (\"send\" for sending address, \"receive\" for receiving address)\n"
" },...\n" " },...\n"
" ],\n"
" \"use_txids\": [\n"
" \"txid\", (string) The ids of transactions involving this wallet which received with the address\n"
" ...\n"
" ]\n" " ]\n"
"}\n" "}\n"
}, },
Expand Down Expand Up @@ -3761,6 +3765,15 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
} }
ret.pushKV("labels", std::move(labels)); ret.pushKV("labels", std::move(labels));


// NOTE: Intentionally not special-casing a single txid: while addresses
// should never be reused, it's not unexpected to have RBF result in
// multiple txids for a single use.
UniValue use_txids(UniValue::VARR);
pwallet->FindScriptPubKeyUsed(std::set<CScript>{scriptPubKey}, [&use_txids](const CWalletTx& wtx){
use_txids.push_back(wtx.tx->GetHash().GetHex());
});
ret.pushKV("use_txids", std::move(use_txids));

return ret; return ret;
} }


Expand Down

0 comments on commit c05d6a8

Please sign in to comment.