Skip to content

Defer transaction signing until user clicks Send#915

Open
151henry151 wants to merge 1 commit into
bitcoin-core:masterfrom
151henry151:fix-30070-defer-signing
Open

Defer transaction signing until user clicks Send#915
151henry151 wants to merge 1 commit into
bitcoin-core:masterfrom
151henry151:fix-30070-defer-signing

Conversation

@151henry151

@151henry151 151henry151 commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

Fixes #30070

When creating an unsigned PSBT from the GUI, the transaction was already signed during preparation, causing legacy inputs to have non-empty scriptSig fields. The PSBT parser then rejects them.

This defers signing until the user clicks "Send" instead of signing during preparation. Fee calculation still works since transactions can be created without signing.

Follows the approach suggested by @achow101 in the issue comments.

@DrahtBot

DrahtBot commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK achow101

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@hebasto hebasto changed the title qt: Defer transaction signing until user clicks Send Defer transaction signing until user clicks Send Nov 22, 2025
@151henry151

Copy link
Copy Markdown
Contributor Author

It looks like the one failing check is a CI issue with disk space too low. I'm not sure how to address that. I think the code of the PR is correct.

@151henry151

Copy link
Copy Markdown
Contributor Author

@achow101 would you like to check this out and let me know if it looks OK?

@maflcko maflcko closed this Dec 17, 2025
@maflcko maflcko reopened this Dec 17, 2025
@151henry151

Copy link
Copy Markdown
Contributor Author

Should I push an empty commit to trigger a re-run of the CI here, or is there some other action needed?

@hebasto

hebasto commented Jan 19, 2026

Copy link
Copy Markdown
Member

Should I push an empty commit to trigger a re-run of the CI here, or is there some other action needed?

No action needed.

@hebasto

hebasto commented Jan 19, 2026

Copy link
Copy Markdown
Member

cc @achow101 @furszy

@hebasto hebasto added Wallet and removed CI failed labels Jan 19, 2026

@achow101 achow101 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Comment thread src/qt/walletmodel.cpp Outdated
Comment thread src/qt/sendcoinsdialog.cpp Outdated
@151henry151

Copy link
Copy Markdown
Contributor Author

For the rebase, I kept master's new createTransaction usage and error flow, wired in the defer-signing logic (sign parameter), and re-added the AmountExceedsBalance check after a successful result. I initially missed updating that to AmountExceedsBalance, but I’ve corrected it. If anyone wants to check this out and let me know if it looks correct, I'd appreciate any feedback. Thanks

@151henry151

Copy link
Copy Markdown
Contributor Author

Would anyone like to take another look at this? Any review or feedback welcomed

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check this works with locked encrypted wallets

Comment thread src/qt/sendcoinsdialog.cpp

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to move the UnlockContext when you sign the transaction otherwise it fails to send now.

Screen.Recording.2026-03-04.at.11.32.40.AM.mov

@151henry151

Copy link
Copy Markdown
Contributor Author

Thanks @johnny9 , I'll take a closer look this evening

@151henry151 151henry151 force-pushed the fix-30070-defer-signing branch from 9b65413 to 39a5fed Compare March 5, 2026 22:05

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the UnlockContext in the "Send" click flow resolved the previous issue. I think the previous UnlockContext is no longer needed.

I also see that the send confirmation dialog isn't as accurate as it was previously so should adjust what the dialog says or expose the correct fee estimated size through the model.

Comment thread src/qt/sendcoinsdialog.cpp
Comment thread src/qt/sendcoinsdialog.cpp Outdated
@151henry151 151henry151 force-pushed the fix-30070-defer-signing branch from 39a5fed to 6a999c2 Compare March 16, 2026 01:01
@151henry151

Copy link
Copy Markdown
Contributor Author

@johnny9 I think I've fixed it correctly; I tested locally (built the gui and tested manually) and it seems like the issues are resolved. Could you test it again to confirm, and take a look at the changes to see if there are any mistakes or problems you can see?

@151henry151 151henry151 requested a review from johnny9 March 16, 2026 15:59

@johnny9 johnny9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think I was wrong and we need both UnlockContexts. Sorry to flp-flop on that. Also take a look at achow's comment again. Seems like you didnt remove the parameter he mentioned. Other than those things I think this looks good now

Comment thread src/qt/sendcoinsdialog.cpp
Comment thread src/qt/walletmodel.cpp Outdated
Comment thread src/qt/walletmodel.h Outdated
@151henry151 151henry151 force-pushed the fix-30070-defer-signing branch from 6a999c2 to 5b79f27 Compare March 31, 2026 14:18
@151henry151

Copy link
Copy Markdown
Contributor Author

Thanks for the additional feedback; I've made the changes and I tested locally, I think it is all correct. Please check it out for me and see if you find any other errors or problems with it.

@151henry151

Copy link
Copy Markdown
Contributor Author

@johnny9 @achow101 I think this is ready for review, if anybody wants to check it out?

@151henry151

Copy link
Copy Markdown
Contributor Author

Just checking in; anything further I can do here to get this ready for merge?

@maflcko

maflcko commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

According to https://btctranscripts.com/bitcoin-core-dev-tech/2026-05/qml-planning and https://btctranscripts.com/bitcoin-core-dev-tech/2026-05/qml-update, there seems to be momentum toward QML, so review in the legacy gui is reduced for now?

This fixes issue #30070 where creating unsigned PSBTs from the GUI
would fail because the transaction was already signed during preparation,
causing legacy inputs to have non-empty scriptSig fields.

The fix defers signing until the user explicitly clicks 'Send', allowing
truly unsigned PSBTs to be created while still supporting fee calculation.
@151henry151 151henry151 force-pushed the fix-30070-defer-signing branch from 5b79f27 to 320db33 Compare June 10, 2026 04:19
@151henry151

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (4b91316). Updated for the current fillPSBT/PSBTFillOptions API and post–gui#807 createTransaction flow.

prepareTransaction now always calls createTransaction with sign=false; internal wallets sign via fillPSBT only after the user clicks Send, with UnlockContext at prepare and send (encrypted wallets). The confirmation dialog labels tx size as unsigned. This should also subsume the overlapping walletmodel.cpp hunk in bitcoin/bitcoin#33112.

Tested with cmake --build build --target bitcoin-qt test_bitcoin-qt and ./build/bin/test_bitcoin-qt --run_all — passed.

Re QML: agreed there's momentum toward a QML replacement, but this is a small fix for the GUI we still ship today (#30070); I don't think that direction makes this redundant in the meantime.

@151henry151

Copy link
Copy Markdown
Contributor Author

CI on the latest push is mostly failing at "Restore caches" with warpbuilds/cache/restore@v1 not allowed on this repo — could that be from the rebased master CI workflow rather than the patch itself, or did I miss something I should have done?

@hebasto

hebasto commented Jun 10, 2026

Copy link
Copy Markdown
Member

CI on the latest push is mostly failing at "Restore caches" with warpbuilds/cache/restore@v1 not allowed on this repo — could that be from the rebased master CI workflow rather than the patch itself, or did I miss something I should have done?

Should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load PSBT error: Unable to decode PSBT

7 participants