server+contractcourt: hand-off BreachCloseInfo to channel arbitrator

This also changes the chain_watcher and breacharbiter handoff. The
new logic ensures that the channel is only marked as pending closed
when the channel arbitrator has persisted the resolutions and commit
set.
This commit is contained in:
eugene
2022-01-13 15:01:13 -05:00
parent b7407882ac
commit ebaffb953a
5 changed files with 289 additions and 89 deletions

View File

@ -1088,8 +1088,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
},
IsOurAddress: cc.Wallet.IsOurAddress,
ContractBreach: func(chanPoint wire.OutPoint,
breachRet *lnwallet.BreachRetribution,
markClosed func() error) error {
breachRet *lnwallet.BreachRetribution) error {
// processACK will handle the breachArbiter ACKing the
// event.
@ -1101,8 +1100,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
}
// If the breachArbiter successfully handled
// the event, we can mark the channel closed.
finalErr <- markClosed()
// the event, we can signal that the handoff
// was successful.
finalErr <- nil
}
event := &contractcourt.ContractBreachEvent{
@ -1118,9 +1118,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
return ErrServerShuttingDown
}
// We'll wait for a final error to be available, either
// from the breachArbiter or from our markClosed
// function closure.
// We'll wait for a final error to be available from
// the breachArbiter.
select {
case err := <-finalErr:
return err