-
Notifications
You must be signed in to change notification settings - Fork 123
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
commitment: splits shouldn't inherit locktime from inputs #1103
Conversation
Pull Request Test Coverage Report for Build 10533902922Details
💛 - Coveralls |
In this commit, we fix an existing bug related to lock times and split commitments. Before this commit, if an input had a relative lock time, then when we went to make the new split assets, we would _copy_ that value into the split. This isn't correct as the input is valid/confirmed, so we don't need to copy over the lock time information. The prior behavior would cause certain classes of spends to fail, as we would be validating a new root asset that has no lock time, but the root asset split inserted into the split commitment would be carrying the old lock time. When verifying the split, we would set the lock times of the split to that of the new asset: https://github.com/lightninglabs/taproot-assets/blob/e893dee87e9d8f0de53b8ee9e2527add80df6491/vm/vm.go#L305-L307. As we copied over the lock time from the input, we would now effectively invalid the split commitment. Fixes #1099
523d723
to
317559c
Compare
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 find! I pushed an updated commit that also updates some other call sites.
Perhaps we should extract this "copy for descendant asset" functionality into a generic function?
Updated lightninglabs/lightning-terminal#825 to confirm this fully fixes the issue. |
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! Wondering if we shouldn't bundle the SplitCommitment
and locktime resetting into another method similar to Copy()
, to make this more explicit / easier in the future.
SGTM, was thinking that too, can tack it on. |
It appears that the underlying library may `nil` out the `rawConn` after the transfer is finished. We can avoid a panic here by only closing if the `rawConn` is non-nil.
`CopySpendTemplate` is similar to `Copy` but sheds some fields that don't need to be carried along when making a copy of an input to spend. This includes the split commitment root, and time lock information.
Implemented here: 881ecaf |
In this commit, we fix an existing bug related to lock times and split commitments. Before this commit, if an input had a relative lock time, then when we went to make the new split assets, we would copy that value into the split. This isn't correct as the input is valid/confirmed, so we don't need to copy over the lock time information.
The prior behavior would cause certain classes of spends to fail, as we would be validating a new root asset that has no lock time, but the root asset split inserted into the split commitment would be carrying the old lock time. When verifying the split, we would set the lock times of the split to that of the new asset:
taproot-assets/vm/vm.go
Lines 305 to 307 in e893dee
As we copied over the lock time from the input, we would now effectively invalid the split commitment.
Fixes #1099