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
+13
-8
@@ -2122,14 +2122,19 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
})
|
||||
} else {
|
||||
// If this is a frozen channel, then we only allow the co-op
|
||||
// close to proceed if we were the responder to this channel.
|
||||
if channel.ChanType.IsFrozen() && channel.IsInitiator &&
|
||||
uint32(bestHeight) < channel.ThawHeight {
|
||||
|
||||
return fmt.Errorf("cannot co-op close frozen channel "+
|
||||
"as initiator until height=%v, "+
|
||||
"(current_height=%v)", channel.ThawHeight,
|
||||
bestHeight)
|
||||
// close to proceed if we were the responder to this channel if
|
||||
// the absolute thaw height has not been met.
|
||||
if channel.IsInitiator {
|
||||
absoluteThawHeight, err := channel.AbsoluteThawHeight()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if uint32(bestHeight) < absoluteThawHeight {
|
||||
return fmt.Errorf("cannot co-op close frozen "+
|
||||
"channel as initiator until height=%v, "+
|
||||
"(current_height=%v)",
|
||||
absoluteThawHeight, bestHeight)
|
||||
}
|
||||
}
|
||||
|
||||
// If the link is not known by the switch, we cannot gracefully close
|
||||
|
||||
Reference in new issue
Block a user