mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-22 14:35:07 +02:00
test: test decodepsbt fee calculation (count input value only once per UTXO)
Checks that the RPC decodepsbt calculates the fee correctly, in particular for PSBTs with segwit inputs that have both a witness- and a non-witness-UTXO type set. Before commit 75122780e2c46505d977e24c5612dfa9442ab754 ("Increment input value sum only once per UTXO in decodepsbt") the values for those inputs were double counted.
This commit is contained in:
parent
40a04814d1
commit
82dee87933
@ -155,12 +155,14 @@ class PSBTTest(BitcoinTestFramework):
|
||||
p2pkh_pos = out['n']
|
||||
|
||||
# spend single key from node 1
|
||||
rawtx = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})['psbt']
|
||||
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(rawtx)
|
||||
created_psbt = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99})
|
||||
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(created_psbt['psbt'])
|
||||
# Make sure it has both types of UTXOs
|
||||
decoded = self.nodes[1].decodepsbt(walletprocesspsbt_out['psbt'])
|
||||
assert 'non_witness_utxo' in decoded['inputs'][0]
|
||||
assert 'witness_utxo' in decoded['inputs'][0]
|
||||
# Check decodepsbt fee calculation (input values shall only be counted once per UTXO)
|
||||
assert_equal(decoded['fee'], created_psbt['fee'])
|
||||
assert_equal(walletprocesspsbt_out['complete'], True)
|
||||
self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex'])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user