chanbackup: handle Single creation for zero-conf channels
The SCB function NewSingle is now zero-conf aware. Since the confirmed short channel id may be unknown, it may use the broadcast height.
This commit is contained in:
1 file changed
+18
@@ -180,6 +180,24 @@ func NewSingle(channel *channeldb.OpenChannel,
|
|||||||
chanID.BlockHeight = channel.BroadcastHeight()
|
chanID.BlockHeight = channel.BroadcastHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a zero-conf channel, we'll need to have separate logic
|
||||||
|
// depending on whether it's confirmed or not. This is because the
|
||||||
|
// ShortChanID is an alias.
|
||||||
|
if channel.IsZeroConf() {
|
||||||
|
// If the channel is confirmed, we'll use the confirmed SCID.
|
||||||
|
if channel.ZeroConfConfirmed() {
|
||||||
|
chanID = channel.ZeroConfRealScid()
|
||||||
|
} else {
|
||||||
|
// Else if the zero-conf channel is unconfirmed, we'll
|
||||||
|
// need to use the broadcast height and zero out the
|
||||||
|
// TxIndex and TxPosition fields. This is so
|
||||||
|
// openChannelShell works properly.
|
||||||
|
chanID.BlockHeight = channel.BroadcastHeight()
|
||||||
|
chanID.TxIndex = 0
|
||||||
|
chanID.TxPosition = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
single := Single{
|
single := Single{
|
||||||
IsInitiator: channel.IsInitiator,
|
IsInitiator: channel.IsInitiator,
|
||||||
ChainHash: channel.ChainHash,
|
ChainHash: channel.ChainHash,
|
||||||
|
|||||||
Reference in new issue
Block a user