diff --git a/lightning_client.go b/lightning_client.go index 8060274..f64f408 100644 --- a/lightning_client.go +++ b/lightning_client.go @@ -3121,12 +3121,20 @@ func (s *lightningClient) OpenChannelStream(ctx context.Context, type CloseChannelUpdate interface { // CloseTxid returns the closing txid of the channel. CloseTxid() chainhash.Hash + + // NumberOfPendingHtlcs is the number of pending htlcs that we have + // present while a channel close with the NoWait option was in progress. + NumberOfPendingHtlcs() int32 } // PendingCloseUpdate indicates that our closing transaction has been broadcast. type PendingCloseUpdate struct { // CloseTx is the closing transaction id. CloseTx chainhash.Hash + + // NumPendingHtlcs is the number of pending htlcs that we have + // present while a channel close with the NoWait option was in progress. + NumPendingHtlcs int32 } // CloseTxid returns the closing txid of the channel. @@ -3134,10 +3142,20 @@ func (p *PendingCloseUpdate) CloseTxid() chainhash.Hash { return p.CloseTx } +// NumberOfPendingHtlcs returns the number of pending htlcs on a pending close +// channel. +func (p *PendingCloseUpdate) NumberOfPendingHtlcs() int32 { + return p.NumPendingHtlcs +} + // ChannelClosedUpdate indicates that our channel close has confirmed on chain. type ChannelClosedUpdate struct { // CloseTx is the closing transaction id. CloseTx chainhash.Hash + + // NumPendingHtlcs is the number of pending htlcs that we have + // present while a channel close with the NoWait option was in progress. + NumPendingHtlcs int32 } // CloseTxid returns the closing txid of the channel. @@ -3145,6 +3163,12 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash { return p.CloseTx } +// NumberOfPendingHtlcs returns the number of pending htlcs on a pending close +// channel. +func (p *ChannelClosedUpdate) NumberOfPendingHtlcs() int32 { + return p.NumPendingHtlcs +} + // CloseChannelOption is a functional type for an option that modifies a // CloseChannelRequest. type CloseChannelOption func(r *lnrpc.CloseChannelRequest) @@ -3291,6 +3315,21 @@ func (s *lightningClient) CloseChannel(ctx context.Context, } sendUpdate(closeUpdate) + case *lnrpc.CloseStatusUpdate_CloseInstant: + instantUpdate := update.CloseInstant + if instantUpdate == nil { + sendErr(errors.New("instant update " + + "unavailable")) + + return + } + + numPendingHtlcs := instantUpdate.NumPendingHtlcs + closeUpdate := &PendingCloseUpdate{ + NumPendingHtlcs: numPendingHtlcs, + } + sendUpdate(closeUpdate) + default: sendErr(fmt.Errorf("unknown channel close "+ "update: %T", resp.Update))