2

Bitcoin Core's CLI has a converttopsbt command used to convert from raw transaction to PSBT transaction but how is it possible to convert from PSBT transaction to raw transaction using Bitcoin Core (or if not possible using another client like Electrum)?

Example of a PSBT transaction (testnet):

cHNidP8BAHECAAAAAW4TCBaK74DxafvrRdWpF32Gg5eVRs1DJX9YHz2v9jduAQAAAAD9////AugDAAAAAAAAFgAUlZYmgEZt2xztxXvON/MpazPDg7h4fAEAAAAAABYAFAos5SNG8ZD0bYuTY1T3lwWbt6XcC+8cAAABAN4CAAAAAAEBtxgls3RExZgey5D+Apcb7GIFdINeRlmY05VOQwZ7LtoBAAAAAP3///8CCgAAAAAAAAAWABSdRgMHmJrQiGsOWa+Ue5R6hDsGJlCBAQAAAAAAFgAUgIISApOAGqWF1K6dU+ANtN8F53kCRzBEAiAL3rtr0r5eB/U3HFRFKEWCJ/MuHEIetMi/5W/Pdw2tOAIgNSY0WkLk1lDHFxJIYgISnlr/0ZZu6YNExTLAGmgoca4BIQNc7DqYfFYpf3ejWJHMoMS+SGNnQh+QcpG8DXyPT1mnHgPvHAAiBgIDWK/NdMjNwkMIwK+D39jKrQQdd8QVK/Kmur/hQm0ACQy0x7YSAQAAAAEAAAAAIgICoL287OJyWbD9uT1ATxNQaD9VqKoAKdvQ6mRatmnd5zMMtMe2EgAAAAABAAAAACICAkaw3TsIUUYODFTLGB5brpjvHFDF7dG63Mg9m/KFHmMzDLTHthIBAAAAAgAAAAA=

1 Answer 1

4

Yes, once the PSBT is finalized you can extract a fully-signed raw transaction from it (using the finalizepsbt RPC). As your PSBT does not have signatures yet, there is no point in constructing an actual transaction from it yet.

5
  • I see, so: a) Using the CLI how would you sign the PSBT transaction with a key not in the wallet as signrawtransactionwithkey takes a raw (not PSBT) transaction as an argument? b) Is finalizepsbt the only way in the RPC to convert from PSBT to raw transaction?
    – Amit
    Dec 7, 2020 at 21:00
  • 1
    You either use a raw transaction workflow or a PSBT workflow. Mixing them is bound to cause problems. PSBT signing will generally involve walletprocesspsbt, or using something like the HWI project to sign using hardware wallets. Dec 7, 2020 at 21:23
  • 2
    Perhaps part of the confusion is that raw transactions serve two distinct purposes: an unsigned form that you pass around while gathering signatures, and a fully-signed form that can be broadcast on the network. PSBT wholly replaces the first one, but not the second. In PSBT you'd use RPCs like createpsbt, walletcreatefundedpsbt, utxoupdatepsbt, walletprocesspsbt, combinepsbt, finalizepsbt. Only after the last of those do you have a (signed) raw transaction. Dec 7, 2020 at 21:26
  • 1
    You can still use raw transaction RPCs, and then convert to PSBT using converttopsbt but that's just for compatibility with (the very first step) of a raw-transaction based workflow. Dec 7, 2020 at 21:27
  • 2
    Bitcoin Core currently has no RPC to sign PSBT using a key not in a wallet. Dec 7, 2020 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.