Skip to content

Commit 18402f1

Browse files
committed
psbt_channel_funder+tapchannel: add remote max HTLC
We want to be able to dictate how many HTLCs the remote side can add to the channel we create. We'll do the same for the responder side with a channel acceptor in one of the following commits.
1 parent e730432 commit 18402f1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

psbt_channel_funder.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ func (l *LndPbstChannelFunder) OpenChannel(ctx context.Context,
9797
// We'll map our high level params into a request for a: private,
9898
// taproot channel, that uses the PSBT funding flow.
9999
taprootCommitType := lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
100-
openChanStream, errChan, err := l.lnd.Client.OpenChannelStream(
101-
ctx, route.NewVertex(&req.PeerPub), req.ChanAmt, req.PushAmt,
102-
true, lndclient.WithCommitmentType(&taprootCommitType),
100+
channelOpenOptions := []lndclient.OpenChannelOption{
101+
lndclient.WithCommitmentType(&taprootCommitType),
103102
lndclient.WithFundingShim(&lnrpc.FundingShim{
104103
Shim: &lnrpc.FundingShim_PsbtShim{
105104
PsbtShim: &lnrpc.PsbtShim{
@@ -110,6 +109,20 @@ func (l *LndPbstChannelFunder) OpenChannel(ctx context.Context,
110109
},
111110
}),
112111
lndclient.WithRemoteReserve(CustomChannelRemoteReserve),
112+
}
113+
114+
// Limit the number of HTLCs that can be added to the channel by the
115+
// remote party.
116+
if req.RemoteMaxHtlc > 0 {
117+
channelOpenOptions = append(
118+
channelOpenOptions,
119+
lndclient.WithRemoteMaxHtlc(req.RemoteMaxHtlc),
120+
)
121+
}
122+
123+
openChanStream, errChan, err := l.lnd.Client.OpenChannelStream(
124+
ctx, route.NewVertex(&req.PeerPub), req.ChanAmt, req.PushAmt,
125+
true, channelOpenOptions...,
113126
)
114127
if err != nil {
115128
return nil, fmt.Errorf("unable to open channel with "+

tapchannel/aux_funding_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ type OpenChanReq struct {
9494
// PushAmt is the amount of BTC to push to the remote peer.
9595
PushAmt btcutil.Amount
9696

97+
// RemoteMaxHtlc is the maximum number of HTLCs we allow the remote to
98+
// add to the channel. If this is zero, then the default value defined
99+
// by lnd (and dependent on the channel capacity) will be used.
100+
RemoteMaxHtlc uint32
101+
97102
// PeerPub is the identity public key of the remote peer we wish to
98103
// open the channel with.
99104
PeerPub btcec.PublicKey

0 commit comments

Comments
 (0)