Skip to content

Commit f3625a7

Browse files
authored
Merge pull request #245 from hieblmi/fix-instant-update
lndclient: NumberOfPendingHtlcs method for close update
2 parents 988ca0f + e3b2a01 commit f3625a7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lightning_client.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3121,19 +3121,33 @@ func (s *lightningClient) OpenChannelStream(ctx context.Context,
31213121
type CloseChannelUpdate interface {
31223122
// CloseTxid returns the closing txid of the channel.
31233123
CloseTxid() chainhash.Hash
3124+
3125+
// NumberOfPendingHtlcs is the number of pending htlcs that we have
3126+
// present while a channel close with the NoWait option was in progress.
3127+
NumberOfPendingHtlcs() int32
31243128
}
31253129

31263130
// PendingCloseUpdate indicates that our closing transaction has been broadcast.
31273131
type PendingCloseUpdate struct {
31283132
// CloseTx is the closing transaction id.
31293133
CloseTx chainhash.Hash
3134+
3135+
// NumPendingHtlcs is the number of pending htlcs that we have
3136+
// present while a channel close with the NoWait option was in progress.
3137+
NumPendingHtlcs int32
31303138
}
31313139

31323140
// CloseTxid returns the closing txid of the channel.
31333141
func (p *PendingCloseUpdate) CloseTxid() chainhash.Hash {
31343142
return p.CloseTx
31353143
}
31363144

3145+
// NumberOfPendingHtlcs returns the number of pending htlcs on a pending close
3146+
// channel.
3147+
func (p *PendingCloseUpdate) NumberOfPendingHtlcs() int32 {
3148+
return p.NumPendingHtlcs
3149+
}
3150+
31373151
// ChannelClosedUpdate indicates that our channel close has confirmed on chain.
31383152
type ChannelClosedUpdate struct {
31393153
// CloseTx is the closing transaction id.
@@ -3149,6 +3163,12 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
31493163
return p.CloseTx
31503164
}
31513165

3166+
// NumberOfPendingHtlcs returns the number of pending htlcs on a pending close
3167+
// channel.
3168+
func (p *ChannelClosedUpdate) NumberOfPendingHtlcs() int32 {
3169+
return p.NumPendingHtlcs
3170+
}
3171+
31523172
// CloseChannelOption is a functional type for an option that modifies a
31533173
// CloseChannelRequest.
31543174
type CloseChannelOption func(r *lnrpc.CloseChannelRequest)
@@ -3305,7 +3325,7 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
33053325
}
33063326

33073327
numPendingHtlcs := instantUpdate.NumPendingHtlcs
3308-
closeUpdate := &ChannelClosedUpdate{
3328+
closeUpdate := &PendingCloseUpdate{
33093329
NumPendingHtlcs: numPendingHtlcs,
33103330
}
33113331
sendUpdate(closeUpdate)

0 commit comments

Comments
 (0)