Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
Calling walletprocesspsbt
on a signed PSBT that only includes a witness_utxo
(no non_witness_utxo
) with an invalid signature produces an internal bug (CHECK_NONFATAL
):
0❯ bitcoin-cli walletprocesspsbt "cHNidP8BAJoCAAAAAq3g8bgaDs84DkYQ6urdGcuevx4mTtc5ImnEuw/RKiZ2AAAAAAD9////O+qpBnMQ44R69kLMIMPrviyL4ml4zSC1iA8Ec7ux/8YBAAAAAP3///8ClnsOAAAAAAAWABQ1vvbTc5DqIMQ7qVHMKjCDEWY5m+DhDQAAAAAAFgAUWIMWf8n1WEfQh3v8yh+J7jCs/a577QIAAAEBH9C6DQAAAAAAFgAUsPZp8CKeWQmHjCFZ2elo6XlxIAEAAQEflqMOAAAAAAAWABRNIMqZK+4V6Fbf76G+CxrSoMafyQEIawJHMEQCIG7dSys9CpWsVOhrVH4aPc4s2hWr0gkYAwOZDWMczlweAiAj7av+wVmv37x4BNEWygqRxeP/GUblTMYzFePeJa5x0QEhA4Uz0JSTf/5CkbMHXfV7C5q8HjcjKGH6frUU57sDbHYDAAAA"
1error code: -1
2error message:
3Internal bug detected: FinalizeAndExtractPSBT(psbtx, mtx)
4wallet/rpc/spend.cpp:1618 (operator())
5Bitcoin Core v27.99.0-24572cf76816
6Please report this issue here: https://github.com/bitcoin/bitcoin/issues
Expected behaviour
This scenario should be handled gracefully either with an explanatory error message or by ignoring those bad signatures (the latter happens when non_witness_utxo
is provided). There are many reasons why a previously added signature could be invalid, e.g. if new inputs were added, outputs modified, etc.
A concrete example is a Payjoin transaction, where the receiver contributes inputs of their own after the sender has signed an initial PSBT. That’s the scenario I was testing when I stumbled onto this (see discussion here).
Steps to reproduce
I produced a minimal repro by modifying the rpc_psbt.py functional test: https://github.com/grizznaut/bitcoin/commit/0ddee75a59d33ceed11f5f8a5e59bbc46054676b). After signing the initial PSBT, it substitutes the output address and attempts to call walletprocesspsbt
again, but fails:
02024-05-10T02:42:01.177000Z TestFramework (ERROR): JSONRPC error
1Traceback (most recent call last):
2 File "/Users/jaad/bin/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
3 self.run_test()
4 File "/Users/jaad/bin/bitcoin/test/functional/rpc_psbt.py", line 601, in run_test self.test_utxo_conversion() File "/Users/jaad/bin/bitcoin/test/functional/rpc_psbt.py", line 118, in test_utxo_conversion
5 signed_psbt = offline_node.walletprocesspsbt(signed_psbt_new.to_base64())
6 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 File "/Users/jaad/bin/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
8 return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jaad/bin/bitcoin/test/functional/test_framework/authproxy.py", line 129, in __call__ raise JSONRPCException(response['error'], status)
10test_framework.authproxy.JSONRPCException: Internal bug detected: FinalizeAndExtractPSBT(psbtx, mtx)
11wallet/rpc/spend.cpp:1618 (operator())
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
master@98dd4e7
Operating system and version
MacOS Ventura 13.6
Machine specifications
No response