-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
watchtower+refactor: CommitmentType and JusticeKit interface #7736
watchtower+refactor: CommitmentType and JusticeKit interface #7736
Conversation
328b828
to
abfb9d6
Compare
fc39a66
to
a90576f
Compare
7e1acea
to
a851935
Compare
a851935
to
34a7293
Compare
34a7293
to
3bbdc28
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.
Very nice, LGTM 🎉
Just a couple of nits, very clean and well structured 💯
3bbdc28
to
960471e
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.
Thanks for the speedy review @guggero 🎉 🚗
@bitromortac: review reminder |
960471e
to
920cdaa
Compare
pushed a tiny update here to incorporate this comment from the follow up PR. No logic changes - just changing the JusticeKit API to return types like |
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, awesome refactor PR 🔥! Only have some nits and a question regarding the JusticeKit
interface.
In this commit a new enum, CommitmentType, is introduced and initially there are 3 CommitmentTypes: Legacy, LegacyTweakless and Anchor. Then, various methods are added to `CommitmentType`. This allows us to remove a bunch of "if-else" chains from the `wtclient` and `lookout` code. This will also make things easier to extend when a new commitment type (like Taproot) is added.
In preparation for the next commit which will introduce the `JusticeKit` interface, here we just move the code related to building the actual justice kit packet into a separate file.
In this commit, we convert the `JusticeKit` struct to an interface. Then, we add two implementations of that interface: 1) The `legacyJusticeKit` which implements all the methods of `JusticeKit` 2) The `anchorJusticKit` which wraps the `legacyJusticeKit` and just re-implements the `ToRemoteOutputSpendInfo` method since.
920cdaa
to
4daa0f3
Compare
This PR is a pure refactor of some watchtower code. Currently, the
tower code is littered with many
if isAnchor() {..} else {}
blocksand this will become even more hairy once we have to cater for
taproot channels. With that in mind, this PR does a few things so that
adding support for taproot channels can be a relatively small diff:
CommitmentType
enum is added which will hide some detailsabout the inputs of the justice transaction.
JusticeKit
is converted from a struct to an interface with variousmethods on it. Two implementations are added:
legacyJusticeKit
andanchorJusticeKit
both of which use the same encoding.This is a pre-requisite for #7733