multi: build retribution info in TowerClient
Since the TowerClient now has a callback that it can use to retrieve the retribution for a certain channel and commit height, let it use this call back instead of requiring the info to be passed to it through BackupState.
This commit is contained in:
4 files changed
+25
-38
No files matched your search
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/invoices"
|
||||
"github.com/lightningnetwork/lnd/lnpeer"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/record"
|
||||
@@ -255,11 +254,8 @@ type TowerClient interface {
|
||||
// state. If the method returns nil, the backup is guaranteed to be
|
||||
// successful unless the tower is unavailable and client is force quit,
|
||||
// or the justice transaction would create dust outputs when trying to
|
||||
// abide by the negotiated policy. If the channel we're trying to back
|
||||
// up doesn't have a tweak for the remote party's output, then
|
||||
// isTweakless should be true.
|
||||
BackupState(*lnwire.ChannelID, *lnwallet.BreachRetribution,
|
||||
channeldb.ChannelType) error
|
||||
// abide by the negotiated policy.
|
||||
BackupState(chanID *lnwire.ChannelID, stateNum uint64) error
|
||||
}
|
||||
|
||||
// InterceptableHtlcForwarder is the interface to set the interceptor
|
||||
|
||||
+4
-18
@@ -2022,11 +2022,6 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
||||
// We've received a revocation from the remote chain, if valid,
|
||||
// this moves the remote chain forward, and expands our
|
||||
// revocation window.
|
||||
//
|
||||
// Before advancing our remote chain, we will record the
|
||||
// current commit tx, which is used by the TowerClient to
|
||||
// create backups.
|
||||
oldCommitTx := l.channel.State().RemoteCommitment.CommitTx
|
||||
|
||||
// We now process the message and advance our remote commit
|
||||
// chain.
|
||||
@@ -2063,24 +2058,15 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
|
||||
// create a backup for the current state.
|
||||
if l.cfg.TowerClient != nil {
|
||||
state := l.channel.State()
|
||||
breachInfo, err := lnwallet.NewBreachRetribution(
|
||||
state, state.RemoteCommitment.CommitHeight-1, 0,
|
||||
// OldCommitTx is the breaching tx at height-1.
|
||||
oldCommitTx,
|
||||
)
|
||||
if err != nil {
|
||||
l.fail(LinkFailureError{code: ErrInternalError},
|
||||
"failed to load breach info: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
chanID := l.ChanID()
|
||||
|
||||
err = l.cfg.TowerClient.BackupState(
|
||||
&chanID, breachInfo, state.ChanType,
|
||||
&chanID, state.RemoteCommitment.CommitHeight-1,
|
||||
)
|
||||
if err != nil {
|
||||
l.fail(LinkFailureError{code: ErrInternalError},
|
||||
"unable to queue breach backup: %v", err)
|
||||
"unable to queue breach backup: %v",
|
||||
err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user