Skip to content

Commit fa08663

Browse files
author
MacroFake
committed
rpc: Return coinbase flag in scantxoutset
1 parent 73b6171 commit fa08663

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,7 @@ static RPCHelpMan scantxoutset()
20692069
{RPCResult::Type::STR_HEX, "scriptPubKey", "The script key"},
20702070
{RPCResult::Type::STR, "desc", "A specialized descriptor for the matched scriptPubKey"},
20712071
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " of the unspent output"},
2072+
{RPCResult::Type::BOOL, "coinbase", "Whether this is a coinbase output"},
20722073
{RPCResult::Type::NUM, "height", "Height of the unspent transaction output"},
20732074
}},
20742075
}},
@@ -2172,6 +2173,7 @@ static RPCHelpMan scantxoutset()
21722173
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey));
21732174
unspent.pushKV("desc", descriptors[txo.scriptPubKey]);
21742175
unspent.pushKV("amount", ValueFromAmount(txo.nValue));
2176+
unspent.pushKV("coinbase", coin.IsCoinBase());
21752177
unspent.pushKV("height", (int32_t)coin.nHeight);
21762178

21772179
unspents.push_back(unspent);

test/functional/rpc_scantxoutset.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def run_test(self):
3333
self.wallet = MiniWallet(self.nodes[0])
3434
self.wallet.rescan_utxos()
3535

36+
self.log.info("Test if we find coinbase outputs.")
37+
assert_equal(sum(u["coinbase"] for u in self.nodes[0].scantxoutset("start", [self.wallet.get_descriptor()])["unspents"]), 49)
38+
3639
self.log.info("Create UTXOs...")
3740
pubk1, spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit")
3841
pubk2, spk_LEGACY, addr_LEGACY = getnewdestination("legacy")

0 commit comments

Comments
 (0)