multi: add relative thaw height interpretation
This is useful when we wish to have a channel frozen for a specific amount of blocks after its confirmation. This could also be done with an absolute thaw height, but it does not suit cases where a strict block delta needs to be enforced, as it's not possible to know for certain when a channel will be included in the chain. To work around this, we add a relative interpretation of the field, where if its value is below 500,000, then it's interpreted as a relative height. This approach allows us to prevent further database modifications to account for a relative thaw height.
This commit is contained in:
7 files changed
+80
-38
No files matched your search
@@ -355,19 +355,25 @@ func (c *ChanCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message,
|
||||
"have %v", spew.Sdump(msg))
|
||||
}
|
||||
|
||||
// As we're the responder to this shutdown (the other party wants to
|
||||
// close), we'll check if this is a frozen channel or not. If the
|
||||
// channel is frozen and we were not also the initiator of the channel
|
||||
// opening, then we'll deny their close attempt.
|
||||
// As we're the responder to this shutdown (the other party
|
||||
// wants to close), we'll check if this is a frozen channel or
|
||||
// not. If the channel is frozen and we were not also the
|
||||
// initiator of the channel opening, then we'll deny their close
|
||||
// attempt.
|
||||
chanInitiator := c.cfg.Channel.IsInitiator()
|
||||
chanState := c.cfg.Channel.State()
|
||||
if !chanInitiator && chanState.ChanType.IsFrozen() &&
|
||||
c.negotiationHeight < chanState.ThawHeight {
|
||||
|
||||
return nil, false, fmt.Errorf("initiator attempting to co-op "+
|
||||
"close frozen ChannelPoint(%v) (current_height=%v, "+
|
||||
"thaw_height=%v)", c.chanPoint, c.negotiationHeight,
|
||||
chanState.ThawHeight)
|
||||
if !chanInitiator {
|
||||
absoluteThawHeight, err := chanState.AbsoluteThawHeight()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if c.negotiationHeight < absoluteThawHeight {
|
||||
return nil, false, fmt.Errorf("initiator "+
|
||||
"attempting to co-op close frozen "+
|
||||
"ChannelPoint(%v) (current_height=%v, "+
|
||||
"thaw_height=%v)", c.chanPoint,
|
||||
c.negotiationHeight, absoluteThawHeight)
|
||||
}
|
||||
}
|
||||
|
||||
// If the remote node opened the channel with option upfront shutdown
|
||||
|
||||
Reference in new issue
Block a user