Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC: Internal bug in walletprocesspsbt when non_witness_utxo is not provided and a witness signature is invalid #30077

Open
1 task done
grizznaut opened this issue May 10, 2024 · 0 comments
Labels

Comments

@grizznaut
Copy link

grizznaut commented May 10, 2024

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: grizznaut@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/jaad/bin/bitcoin/test/functional/test_framework/test_framework.py", line 132, in main
    self.run_test()
  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
    signed_psbt = offline_node.walletprocesspsbt(signed_psbt_new.to_base64())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jaad/bin/bitcoin/test/functional/test_framework/coverage.py", line 50, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                     File "/Users/jaad/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants