breacharbiter: notify the ChainArbitrator of fresh signals for a channel on startup
This commit is contained in:
parent
367231320b
commit
94504a9d41
@ -45,6 +45,14 @@ type BreachConfig struct {
|
||||
// a close type to be included in the channel close summary.
|
||||
CloseLink func(*wire.OutPoint, htlcswitch.ChannelCloseType)
|
||||
|
||||
// UpdateCloseSignal allows the breach arbiter to notify the
|
||||
// ChainArbitrator that a set of new signals for the unilateral closing
|
||||
// of a channel is now available. This ensures that ifa channel hasn't
|
||||
// had any updates since it was live, then we're still able to act on
|
||||
// on-chain events.
|
||||
UpdateCloseSignal func(*wire.OutPoint,
|
||||
chan *lnwallet.UnilateralCloseSummary) error
|
||||
|
||||
// DB provides access to the user's channels, allowing the breach
|
||||
// arbiter to determine the current state of a user's channels, and how
|
||||
// it should respond to channel closure.
|
||||
@ -306,6 +314,15 @@ func (b *breachArbiter) contractObserver(
|
||||
chanPoint := channel.ChanPoint
|
||||
b.breachObservers[*chanPoint] = settleSignal
|
||||
|
||||
// Before we'll launch our breach observe, we'll send this
|
||||
// latest set of contract signals to the ChainArbitrator.
|
||||
//
|
||||
// TODO(roasbeef): just move now?
|
||||
err := b.cfg.UpdateCloseSignal(chanPoint, channel.UnilateralClose)
|
||||
if err != nil {
|
||||
brarLog.Errorf("unable to update close signals: %v", err)
|
||||
}
|
||||
|
||||
b.wg.Add(1)
|
||||
go b.breachObserver(channel, settleSignal)
|
||||
}
|
||||
|
@ -1097,10 +1097,9 @@ func TestBreachHandoffFail(t *testing.T) {
|
||||
aliceKeyPriv, _ := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
alicesPrivKey)
|
||||
aliceSigner := &mockSigner{aliceKeyPriv}
|
||||
estimator := &lnwallet.StaticFeeEstimator{FeeRate: 50}
|
||||
|
||||
alice2, err := lnwallet.NewLightningChannel(aliceSigner, notifier,
|
||||
estimator, alice.State())
|
||||
nil, alice.State())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test channels: %v", err)
|
||||
}
|
||||
@ -1382,16 +1381,23 @@ func createInitChannelsWithNotifier(revocationWindow int,
|
||||
Db: dbBob,
|
||||
}
|
||||
|
||||
pCache := &mockPreimageCache{
|
||||
// hash -> preimage
|
||||
preimageMap: make(map[[32]byte][]byte),
|
||||
}
|
||||
|
||||
aliceSigner := &mockSigner{aliceKeyPriv}
|
||||
bobSigner := &mockSigner{bobKeyPriv}
|
||||
|
||||
channelAlice, err := lnwallet.NewLightningChannel(aliceSigner, notifier,
|
||||
estimator, aliceChannelState)
|
||||
channelAlice, err := lnwallet.NewLightningChannel(
|
||||
aliceSigner, notifier, pCache, aliceChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
channelBob, err := lnwallet.NewLightningChannel(bobSigner, notifier,
|
||||
estimator, bobChannelState)
|
||||
channelBob, err := lnwallet.NewLightningChannel(
|
||||
bobSigner, notifier, pCache, bobChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@ -1476,7 +1482,7 @@ func forceStateTransition(chanA, chanB *lnwallet.LightningChannel) error {
|
||||
return err
|
||||
}
|
||||
|
||||
bobRevocation, err := chanB.RevokeCurrentCommitment()
|
||||
bobRevocation, _, err := chanB.RevokeCurrentCommitment()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1492,7 +1498,7 @@ func forceStateTransition(chanA, chanB *lnwallet.LightningChannel) error {
|
||||
return err
|
||||
}
|
||||
|
||||
aliceRevocation, err := chanA.RevokeCurrentCommitment()
|
||||
aliceRevocation, _, err := chanA.RevokeCurrentCommitment()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user