Skip to content

Commit 6966e80

Browse files
committed
RPC: Add ancestor{count,size,fees} to listunspent output
1 parent 3f77dfd commit 6966e80

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,9 @@ static RPCHelpMan listunspent()
28802880
{RPCResult::Type::STR, "scriptPubKey", "the script key"},
28812881
{RPCResult::Type::STR_AMOUNT, "amount", "the transaction output amount in " + CURRENCY_UNIT},
28822882
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
2883+
{RPCResult::Type::NUM, "ancestorcount", /* optional */ true, "The number of in-mempool ancestor transactions, including this one (if transaction is in the mempool)"},
2884+
{RPCResult::Type::NUM, "ancestorsize", /* optional */ true, "The virtual transaction size of in-mempool ancestors, including this one (if transaction is in the mempool)"},
2885+
{RPCResult::Type::STR_AMOUNT, "ancestorfees", /* optional */ true, "The total fees of in-mempool ancestors (including this one) with fee deltas used for mining priority in " + CURRENCY_ATOM + " (if transaction is in the mempool)"},
28832886
{RPCResult::Type::STR_HEX, "redeemScript", "The redeemScript if scriptPubKey is P2SH"},
28842887
{RPCResult::Type::STR, "witnessScript", "witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
28852888
{RPCResult::Type::BOOL, "spendable", "Whether we have the private keys to spend this output"},
@@ -3046,6 +3049,16 @@ static RPCHelpMan listunspent()
30463049
entry.pushKV("scriptPubKey", HexStr(scriptPubKey));
30473050
entry.pushKV("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue));
30483051
entry.pushKV("confirmations", out.nDepth);
3052+
if (!out.nDepth) {
3053+
size_t ancestor_count, descendant_count, ancestor_size;
3054+
CAmount ancestor_fees;
3055+
pwallet->chain().getTransactionAncestry(out.tx->GetHash(), ancestor_count, descendant_count, &ancestor_size, &ancestor_fees);
3056+
if (ancestor_count) {
3057+
entry.pushKV("ancestorcount", uint64_t(ancestor_count));
3058+
entry.pushKV("ancestorsize", uint64_t(ancestor_size));
3059+
entry.pushKV("ancestorfees", uint64_t(ancestor_fees));
3060+
}
3061+
}
30493062
entry.pushKV("spendable", out.fSpendable);
30503063
entry.pushKV("solvable", out.fSolvable);
30513064
if (out.fSolvable) {

0 commit comments

Comments
 (0)