Skip to content

Commit 82dee87

Browse files
committed
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 7512278 ("Increment input value sum only once per UTXO in decodepsbt") the values for those inputs were double counted.
1 parent 40a0481 commit 82dee87

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/functional/rpc_psbt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ def run_test(self):
155155
p2pkh_pos = out['n']
156156

157157
# spend single key from node 1
158-
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']
159-
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(rawtx)
158+
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})
159+
walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(created_psbt['psbt'])
160160
# Make sure it has both types of UTXOs
161161
decoded = self.nodes[1].decodepsbt(walletprocesspsbt_out['psbt'])
162162
assert 'non_witness_utxo' in decoded['inputs'][0]
163163
assert 'witness_utxo' in decoded['inputs'][0]
164+
# Check decodepsbt fee calculation (input values shall only be counted once per UTXO)
165+
assert_equal(decoded['fee'], created_psbt['fee'])
164166
assert_equal(walletprocesspsbt_out['complete'], True)
165167
self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex'])
166168

0 commit comments

Comments
 (0)