Skip to content

Commit 160ce53

Browse files
committed
lndclient: handle CloseInstant update
1 parent 8ddc90c commit 160ce53

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lightning_client.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,13 +3138,23 @@ func (p *PendingCloseUpdate) CloseTxid() chainhash.Hash {
31383138
type ChannelClosedUpdate struct {
31393139
// CloseTx is the closing transaction id.
31403140
CloseTx chainhash.Hash
3141+
3142+
// NumPendingHtlcs is the number of pending htlcs that we have
3143+
// present while a channel close with the NoWait option was in progress.
3144+
NumPendingHtlcs int32
31413145
}
31423146

31433147
// CloseTxid returns the closing txid of the channel.
31443148
func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
31453149
return p.CloseTx
31463150
}
31473151

3152+
// NumberOfPendingHtlcs returns the number of pending htlcs that we have
3153+
// present while a channel close with NoWait option was in progress.
3154+
func (p *ChannelClosedUpdate) NumberOfPendingHtlcs() int32 {
3155+
return p.NumPendingHtlcs
3156+
}
3157+
31483158
// CloseChannelOption is a functional type for an option that modifies a
31493159
// CloseChannelRequest.
31503160
type CloseChannelOption func(r *lnrpc.CloseChannelRequest)
@@ -3291,6 +3301,21 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
32913301
}
32923302
sendUpdate(closeUpdate)
32933303

3304+
case *lnrpc.CloseStatusUpdate_CloseInstant:
3305+
instantUpdate := update.CloseInstant
3306+
if instantUpdate == nil {
3307+
sendErr(errors.New("instant update " +
3308+
"unavailable"))
3309+
3310+
return
3311+
}
3312+
3313+
numPendingHtlcs := instantUpdate.NumPendingHtlcs
3314+
closeUpdate := &ChannelClosedUpdate{
3315+
NumPendingHtlcs: numPendingHtlcs,
3316+
}
3317+
sendUpdate(closeUpdate)
3318+
32943319
default:
32953320
sendErr(fmt.Errorf("unknown channel close "+
32963321
"update: %T", resp.Update))

0 commit comments

Comments
 (0)