Skip to content

Commit 30e0f9f

Browse files
authored
Merge pull request #249 from starius/port-instant
port CloseInstant update and NumberOfPendingHtlcs to lnd-20 branch
2 parents 3508a5b + 1fd28b9 commit 30e0f9f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lightning_client.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,30 +3121,54 @@ 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.
31403154
CloseTx chainhash.Hash
3155+
3156+
// NumPendingHtlcs is the number of pending htlcs that we have
3157+
// present while a channel close with the NoWait option was in progress.
3158+
NumPendingHtlcs int32
31413159
}
31423160

31433161
// CloseTxid returns the closing txid of the channel.
31443162
func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
31453163
return p.CloseTx
31463164
}
31473165

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+
31483172
// CloseChannelOption is a functional type for an option that modifies a
31493173
// CloseChannelRequest.
31503174
type CloseChannelOption func(r *lnrpc.CloseChannelRequest)
@@ -3291,6 +3315,21 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
32913315
}
32923316
sendUpdate(closeUpdate)
32933317

3318+
case *lnrpc.CloseStatusUpdate_CloseInstant:
3319+
instantUpdate := update.CloseInstant
3320+
if instantUpdate == nil {
3321+
sendErr(errors.New("instant update " +
3322+
"unavailable"))
3323+
3324+
return
3325+
}
3326+
3327+
numPendingHtlcs := instantUpdate.NumPendingHtlcs
3328+
closeUpdate := &PendingCloseUpdate{
3329+
NumPendingHtlcs: numPendingHtlcs,
3330+
}
3331+
sendUpdate(closeUpdate)
3332+
32943333
default:
32953334
sendErr(fmt.Errorf("unknown channel close "+
32963335
"update: %T", resp.Update))

0 commit comments

Comments
 (0)