Skip to content

Commit

Permalink
psbt_channel_funder+tapchannel: add remote max HTLC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guggero committed Nov 18, 2024
1 parent 2742e23 commit 3dc0834
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions psbt_channel_funder.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ func (l *LndPbstChannelFunder) OpenChannel(ctx context.Context,
// We'll map our high level params into a request for a: private,
// taproot channel, that uses the PSBT funding flow.
taprootCommitType := lnrpc.CommitmentType_SIMPLE_TAPROOT_OVERLAY
openChanStream, errChan, err := l.lnd.Client.OpenChannelStream(
ctx, route.NewVertex(&req.PeerPub), req.ChanAmt, req.PushAmt,
true, lndclient.WithCommitmentType(&taprootCommitType),
channelOpenOptions := []lndclient.OpenChannelOption{
lndclient.WithCommitmentType(&taprootCommitType),
lndclient.WithFundingShim(&lnrpc.FundingShim{
Shim: &lnrpc.FundingShim_PsbtShim{
PsbtShim: &lnrpc.PsbtShim{
Expand All @@ -110,6 +109,20 @@ func (l *LndPbstChannelFunder) OpenChannel(ctx context.Context,
},
}),
lndclient.WithRemoteReserve(CustomChannelRemoteReserve),
}

// Limit the number of HTLCs that can be added to the channel by the
// remote party.
if req.RemoteMaxHtlc > 0 {
channelOpenOptions = append(
channelOpenOptions,
lndclient.WithRemoteMaxHtlc(req.RemoteMaxHtlc),
)
}

openChanStream, errChan, err := l.lnd.Client.OpenChannelStream(
ctx, route.NewVertex(&req.PeerPub), req.ChanAmt, req.PushAmt,
true, channelOpenOptions...,
)
if err != nil {
return nil, fmt.Errorf("unable to open channel with "+
Expand Down
5 changes: 5 additions & 0 deletions tapchannel/aux_funding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ type OpenChanReq struct {
// PushAmt is the amount of BTC to push to the remote peer.
PushAmt btcutil.Amount

// RemoteMaxHtlc is the maximum number of HTLCs we allow the remote to
// add to the channel. If this is zero, then the default value defined
// by lnd (and dependent on the channel capacity) will be used.
RemoteMaxHtlc uint32

// PeerPub is the identity public key of the remote peer we wish to
// open the channel with.
PeerPub btcec.PublicKey
Expand Down

0 comments on commit 3dc0834

Please sign in to comment.