-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
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
):
❯ bitcoin-cli walletprocesspsbt "cHNidP8BAJoCAAAAAq3g8bgaDs84DkYQ6urdGcuevx4mTtc5ImnEuw/RKiZ2AAAAAAD9////O+qpBnMQ44R69kLMIMPrviyL4ml4zSC1iA8Ec7ux/8YBAAAAAP3///8ClnsOAAAAAAAWABQ1vvbTc5DqIMQ7qVHMKjCDEWY5m+DhDQAAAAAAFgAUWIMWf8n1WEfQh3v8yh+J7jCs/a577QIAAAEBH9C6DQAAAAAAFgAUsPZp8CKeWQmHjCFZ2elo6XlxIAEAAQEflqMOAAAAAAAWABRNIMqZK+4V6Fbf76G+CxrSoMafyQEIawJHMEQCIG7dSys9CpWsVOhrVH4aPc4s2hWr0gkYAwOZDWMczlweAiAj7av+wVmv37x4BNEWygqRxeP/GUblTMYzFePeJa5x0QEhA4Uz0JSTf/5CkbMHXfV7C5q8HjcjKGH6frUU57sDbHYDAAAA"
error code: -1
error message:
Internal bug detected: FinalizeAndExtractPSBT(psbtx, mtx)
wallet/rpc/spend.cpp:1618 (operator())
Bitcoin Core v27.99.0-24572cf76816
Please 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: spacebear21@0ddee75). After signing the initial PSBT, it substitutes the output address and attempts to call walletprocesspsbt
again, but fails:
2024-05-10T02:42:01.177000Z TestFramework (ERROR): JSONRPC error
Traceback (most recent call last):
File "/Users/spacebear/bin/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
self.run_test()
File "/Users/spacebear/bin/bitcoin/test/functional/rpc_psbt.py", line 601, in run_test self.test_utxo_conversion() File "/Users/spacebear/bin/bitcoin/test/functional/rpc_psbt.py", line 118, in test_utxo_conversion
signed_psbt = offline_node.walletprocesspsbt(signed_psbt_new.to_base64())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/spacebear/bin/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/spacebear/bin/bitcoin/test/functional/test_framework/authproxy.py", line 129, in __call__ raise JSONRPCException(response['error'], status)
test_framework.authproxy.JSONRPCException: Internal bug detected: FinalizeAndExtractPSBT(psbtx, mtx)
wallet/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