mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
watchtower: convert JusticeKit to interface
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.
This commit is contained in:
@@ -37,12 +37,22 @@ func (db *TowerDB) InsertStateUpdate(update *wtdb.SessionStateUpdate) (uint16, e
|
||||
return 0, wtdb.ErrSessionNotFound
|
||||
}
|
||||
|
||||
commitType, err := info.Policy.BlobType.CommitmentType(nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
kit, err := commitType.EmptyJusticeKit()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Assert that the blob is the correct size for the session's blob type.
|
||||
if len(update.EncryptedBlob) != blob.Size(info.Policy.BlobType) {
|
||||
if len(update.EncryptedBlob) != blob.Size(kit) {
|
||||
return 0, wtdb.ErrInvalidBlobSize
|
||||
}
|
||||
|
||||
err := info.AcceptUpdateSequence(update.SeqNum, update.LastApplied)
|
||||
err = info.AcceptUpdateSequence(update.SeqNum, update.LastApplied)
|
||||
if err != nil {
|
||||
return info.LastApplied, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user