Skip to content

Commit 2a78472

Browse files
author
MarcoFalke
committed
Merge #19597: test: test decodepsbt fee calculation (count input value only once per UTXO)
82dee87 test: test decodepsbt fee calculation (count input value only once per UTXO) (Sebastian Falbesoner) Pull request description: Fixes #19523, adding a simple test to `rpc_psbt.py` that checks that the decodepsbt fee matches the one given by the wallet (`walletcreatefundedpsbt`). This is in particular important for PSBTs with segwit inputs that have both a witness- and a non-witness-UTXO type set. Example test run after reverting commit 7512278 ("Increment input value sum only once per UTXO in decodepsbt"): ``` $ test/functional/rpc_psbt.py 2020-07-26T11:31:44.862000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test__sutcd4y 20.00007580 2020-07-26T11:31:47.073000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/test_framework.py", line 118, in main self.run_test() File "test/functional/rpc_psbt.py", line 166, in run_test assert_equal(decoded['fee'], created_psbt['fee']) File "/home/honeybadger/buidl/bitcoin_thestack/test/functional/test_framework/util.py", line 49, in assert_equal raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args)) AssertionError: not(20.00007580 == 0.00007580) 2020-07-26T11:31:47.125000Z TestFramework (INFO): Stopping nodes ...... ``` ACKs for top commit: achow101: ACK 82dee87 Tree-SHA512: 296b8a701f851d482ef6200c6cbf0cf0257a79a828ac6dbc39b05d8c2d839c6fdb9d3f5a084015295cfa3eac7c11faa2f2d52e619c11627b04c75150eead8330
2 parents 149eca4 + 82dee87 commit 2a78472

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)