breacharbiter: introduce new sub-system to watch for breaches
This commit introduces a new sub-system into the daemon whose job it is to vigilantly watch for any potential channel breaches throughout the up-time of the daemon. The logic which was moved from the utxoNursery in a prior commit now resides within the breachArbiter. Upon start-up the breachArbiter will query the database for all active channels, launching a goroutine for each channel in order to be able to take action if a channel breach is detected. The breachArbiter is also responsible for notifying the htlcSwitch about channel breaches in order to black-list the breached linked during any multi-hop forwarding decisions.
This commit is contained in:
10 files changed
+593
-43
No files matched your search
@@ -866,6 +866,8 @@ func (p *peer) handleLocalClose(req *closeLinkReq) {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
p.server.breachArbiter.settledContracts <- req.chanPoint
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -916,6 +918,8 @@ func (p *peer) handleRemoteClose(req *lnwire.CloseRequest) {
|
||||
if err := wipeChannel(p, channel); err != nil {
|
||||
peerLog.Errorf("unable to wipe channel: %v", err)
|
||||
}
|
||||
|
||||
p.server.breachArbiter.settledContracts <- req.ChannelPoint
|
||||
}
|
||||
|
||||
// wipeChannel removes the passed channel from all indexes associated with the
|
||||
@@ -960,7 +964,7 @@ func wipeChannel(p *peer, channel *lnwallet.LightningChannel) error {
|
||||
// small summary for historical records.
|
||||
if err := channel.DeleteState(); err != nil {
|
||||
peerLog.Errorf("Unable to delete ChannelPoint(%v) "+
|
||||
"from db %v", chanID, err)
|
||||
"from db: %v", chanID, err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1075,12 +1079,15 @@ out:
|
||||
for {
|
||||
select {
|
||||
case <-channel.UnilateralCloseSignal:
|
||||
// TODO(roasbeef): need to send HTLC outputs to nursery
|
||||
peerLog.Warnf("Remote peer has closed ChannelPoint(%v) on-chain",
|
||||
state.chanPoint)
|
||||
if err := wipeChannel(p, channel); err != nil {
|
||||
peerLog.Errorf("unable to wipe channel %v", err)
|
||||
}
|
||||
|
||||
p.server.breachArbiter.settledContracts <- state.chanPoint
|
||||
|
||||
break out
|
||||
case <-channel.ForceCloseSignal:
|
||||
peerLog.Warnf("ChannelPoint(%v) has been force "+
|
||||
|
||||
Reference in new issue
Block a user