-
Notifications
You must be signed in to change notification settings - Fork 582
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
wallet: add new PSBT funding and finalizing methods #711
Conversation
wallet/psbt.go
Outdated
|
||
// We can only sign witness inputs. Everything else must already | ||
// have been signed or the finalize step later will fail. | ||
if in.WitnessUtxo == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover nested P2WKH?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, from the perspective of a signer, a NP2WKH looks exactly like a native SegWit output except that FinalScriptSig
is set to a non-empty slice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I'm missing something, but I don't see that being done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right. I assigned the script to WitnessScript
instead of FinalScriptSig
. The added test case caught that now. Thanks!
0b0fc85
to
a797c79
Compare
wallet/psbt.go
Outdated
|
||
// We can only sign witness inputs. Everything else must already | ||
// have been signed or the finalize step later will fail. | ||
if in.WitnessUtxo == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I'm missing something, but I don't see that being done here.
Can you show me how to us this PR with my current LND, so I can test PSBT funding with latest electrum releases? |
See lightningnetwork/lnd#4389, that adds PSBT signing to |
I updated the PR to include the compatibility fix for patched HW wallets: btcsuite/btcutil#178 I also made sure we always include the non-witness UTXO in our PSBTs as well to make sure we produce packets that can be signed by HW wallets with the newest firmware. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎷
Ready to land once the btcutil dep is updated.
Dependency updated. |
Can’t wait to test this out in LND! |
Depends on btcsuite/btcutil#178
Adds the methods
FundPsbt
which can perform coin selection and/or fee estimation to fund outputs in a PSBT andFinalizePsbt
which signs known inputs of a PSBT packet.We also add
FetchInputInfo
andComputeInputScript
which previously resided inlnd
to make them available to the PSBT signing code and other users ofbtcwallet
.