mirror of https://github.com/bitcoin/bitcoin
Merge bitcoin/bitcoin#30515: rpc: add utxo's blockhash and number of confirmations to scantxoutset output
pull/30540/head17845e7f21
rpc: add utxo's blockhash and number of confirmations to scantxoutset output (Luis Schwab) Pull request description: This PR resolves #30478 by adding two fields to the `scantxoutset` RPC: - blockhash: the blockhash that an UTXO was created - confirmations: the number of confirmations an UTXO has relative to the chaintip. The rationale for the first field is that a blockhash is a much more reliable identifier than the height: > When using the scantxoutset RPC, the current behaviour is to show the block height of the UTXO. This is not optimal, as block height is ambiguous, especially in the case of a block reorganization happening at the same instant of the query. In this case, an UTXO that does not exist would be assumed to exist, unless the chain's tip hash is recorded before the scan, and make sure it still exists after, as per https://github.com/bitcoindevkit/bdk/issues/895#issuecomment-1475766797 comment by evanlinjin. The second one was suggested by maflcko, and I agree it's useful for human users: > While touching this, another thing to add could be the number of confirmations? I understand that this wouldn't help machine consumers of the interface, but human callers may find it useful? This will yield an RPC output like so: ```diff bitcoin-cli scantxoutset start "[\"addr(bc1q5q9344vdyjkcgv79ve3tldz4jmx4lf7knmnx6r)\"]" { "success": true, "txouts": 185259116, "height": 853622, "bestblock": "00000000000000000002e97d9be8f0ddf31829cf873061b938c10b0f80f708b2", "unspents": [ { "txid": "fae435084345fe26e464994aebc6544875bca0b897bf4ce52a65901ae28ace92", "vout": 0, "scriptPubKey": "0014a00b1ad58d24ad8433c56662bfb45596cd5fa7d6", "desc": "addr(bc1q5q9344vdyjkcgv79ve3tldz4jmx4lf7knmnx6r)#smk4xmt7", "amount": 0.00091190, "coinbase": false, "height": 852741, + "blockhash": "00000000000000000002eefe7e7db44d5619c3dace4c65f3fdcd2913d4945c13", + "confirmations": 882 } ], "total_amount": 0.00091190 } ``` ACKs for top commit: sipa: utACK17845e7f21
Eunovo: ACK17845e7f21
tdb3: ACK17845e7f21
Tree-SHA512: 02366d0004e5d547522115ef0efe6794a35978db53dda12c675cfae38197bf43f0bf89ca99a3d79e3d2cff95186015fe1ab764abb8ab82bda440ae9302ad973b
commit
38c30a4b50
Loading…
Reference in new issue