0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Merge bitcoin/bitcoin#26280: rpc: Return coinbase flag in scantxoutset

fa08663344 rpc: Return coinbase flag in scantxoutset (MacroFake)

Pull request description:

  I guess it can't hurt to return this for someone that wants to know it

ACKs for top commit:
  aureleoules:
    ACK fa08663344
  shaavan:
    ACK fa08663344

Tree-SHA512: 04c554b3ed9877bab93ffcf0c1a4430cd41b30c5f4f3bf462a518fc8b3d68832dd85a29e81bd805eaa16e987856933d7a888a8c126f670bb2844bbd5ca1bf902
This commit is contained in:
fanquake 2022-10-12 10:05:37 +08:00
commit 1d277f4223
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 5 additions and 0 deletions

View file

@ -2069,6 +2069,7 @@ static RPCHelpMan scantxoutset()
{RPCResult::Type::STR_HEX, "scriptPubKey", "The script key"}, {RPCResult::Type::STR_HEX, "scriptPubKey", "The script key"},
{RPCResult::Type::STR, "desc", "A specialized descriptor for the matched scriptPubKey"}, {RPCResult::Type::STR, "desc", "A specialized descriptor for the matched scriptPubKey"},
{RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " of the unspent output"}, {RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " of the unspent output"},
{RPCResult::Type::BOOL, "coinbase", "Whether this is a coinbase output"},
{RPCResult::Type::NUM, "height", "Height of the unspent transaction output"}, {RPCResult::Type::NUM, "height", "Height of the unspent transaction output"},
}}, }},
}}, }},
@ -2172,6 +2173,7 @@ static RPCHelpMan scantxoutset()
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey)); unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey));
unspent.pushKV("desc", descriptors[txo.scriptPubKey]); unspent.pushKV("desc", descriptors[txo.scriptPubKey]);
unspent.pushKV("amount", ValueFromAmount(txo.nValue)); unspent.pushKV("amount", ValueFromAmount(txo.nValue));
unspent.pushKV("coinbase", coin.IsCoinBase());
unspent.pushKV("height", (int32_t)coin.nHeight); unspent.pushKV("height", (int32_t)coin.nHeight);
unspents.push_back(unspent); unspents.push_back(unspent);

View file

@ -33,6 +33,9 @@ class ScantxoutsetTest(BitcoinTestFramework):
self.wallet = MiniWallet(self.nodes[0]) self.wallet = MiniWallet(self.nodes[0])
self.wallet.rescan_utxos() self.wallet.rescan_utxos()
self.log.info("Test if we find coinbase outputs.")
assert_equal(sum(u["coinbase"] for u in self.nodes[0].scantxoutset("start", [self.wallet.get_descriptor()])["unspents"]), 49)
self.log.info("Create UTXOs...") self.log.info("Create UTXOs...")
pubk1, spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit") pubk1, spk_P2SH_SEGWIT, addr_P2SH_SEGWIT = getnewdestination("p2sh-segwit")
pubk2, spk_LEGACY, addr_LEGACY = getnewdestination("legacy") pubk2, spk_LEGACY, addr_LEGACY = getnewdestination("legacy")