-
Notifications
You must be signed in to change notification settings - Fork 47
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
Switch account signing over to PSBT, allow deposits/account creation from P2TR inputs #370
Conversation
return order.ChannelTypePeerDependent | ||
} | ||
|
||
// TODO(guggero): Use order.ChannelTypeScriptEnforced here as |
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.
💯
8d8eb53
to
17866e9
Compare
pIn.FinalScriptWitness, err = serializeWitness([][]byte{ourSig}) | ||
// We temporarily set the final witness to the partial sig to allow the | ||
// extraction of the final TX. Unless we're using the expiry path in | ||
// which case we _can_ create the full and final witness. |
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.
👍
@Roasbeef: review reminder |
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.
PSBT all the things!
Took an initial pass over the PR, my main question/comment is: why not just also use FundPSBT
so we can remove all the coin selection logic (which was copied from lnd mostly so it's duplicated) into a single place? This would also mean that users would be able to use lnd's other coin selection mode (random inputs) as well.
@Roasbeef thanks for the review! I did think about using |
oli needs to rework to use the PSBT call for the deposit, needs some tricks bc the RPC doesn't allow inputs to specified |
Addressed all comments but something doesn't seem to be working just yet. Will debug further tomorrow. |
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.
Love all the code deletion in this latest diff! Happy we were able to work around the lack of functionality on the lnd PSBT side. I think we'll need to do something similar on a new project we're working on as well
// Unfortunately the FundPsbt call doesn't allow us to specify _any_ | ||
// inputs, otherwise it won't perform coin selection at all. So what we | ||
// do instead is to fund our account output just for the funding amount | ||
// plus whatever we need to pay for the additional input (which we know |
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.
Nice work around! We'll probably eventually patch this behavior, but good to be abble to get by w/ less as well.
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.
cc @jharveyb -- this is the workaround I was talking about earlier
// We'll start by obtaining our global lock ID. | ||
lockID, err := m.cfg.Store.LockID() | ||
outputToFund := &wire.TxOut{ | ||
Value: int64(depositAmount + acctInputFee), |
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.
This should be ok, but part of me wonders if there's some weird edge case here w/ rounding and amounts. Worst case, I guess we get rejected due to having insufficient fees.
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.
Yeah, we should always over estimate by a little bit anyway since most of the time the signatures don't end up being the full 73 bytes. But I went ahead and added a min relay fee check anyway.
Okay, after spending way too much time finding out that my problem was actually lightningnetwork/lnd#6626 I created the fix in lightningnetwork/lnd#6687. I hope that workaround is okay! |
With lnd 0.15.0 almost out of the door, it is reasonable for us to ask users to be on the latest 0.14.x version. We use the walletrpc.SignPsbt method in Pool which was added in 0.14.2.
Done, and ready for review from @positiveblue @Roasbeef #370 https://github.com/lightninglabs/subasta/pull/410 |
Ahh, makes sense. I think this is OK, as it lets us have the code be uniform vs special casing the |
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 🎊
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.
🚀
Depends on lightninglabs/lndclient#105.
This PR moves over the signing operations from
SignOutputRaw
andComputeInputScript
toSignPsbt
andFinalizePsbt
in order to prepare for Taproot/MuSig2 compatible trader accounts.With this change we also allow using P2TR wallet inputs for creating new accounts or for depositing into existing accounts.
Pull Request Checklist
used.