Skip to content

Commit e3a0aa1

Browse files
authored
Merge pull request #1132 from lightninglabs/limit-asset-id-htlc
Limit number of HTLCs in custom channel
2 parents 77e8b28 + 9a7a4c1 commit e3a0aa1

File tree

10 files changed

+338
-24
lines changed

10 files changed

+338
-24
lines changed

docs/examples/basic-price-oracle/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ require (
9292
github.com/kkdai/bstream v1.0.0 // indirect
9393
github.com/lib/pq v1.10.9 // indirect
9494
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
95-
github.com/lightninglabs/lndclient v0.18.4-3 // indirect
95+
github.com/lightninglabs/lndclient v0.18.4-5 // indirect
9696
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd // indirect
9797
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
9898
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb // indirect
99-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61 // indirect
99+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2 // indirect
100100
github.com/lightningnetwork/lnd/clock v1.1.1 // indirect
101101
github.com/lightningnetwork/lnd/fn v1.2.3 // indirect
102102
github.com/lightningnetwork/lnd/healthcheck v1.2.5 // indirect

docs/examples/basic-price-oracle/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQ
418418
github.com/lightninglabs/lightning-node-connect v0.2.5-alpha h1:ZRVChwczFXK0CEbxOCWwUA6TIZvrkE0APd1T3WjFAwg=
419419
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2 h1:Er1miPZD2XZwcfE4xoS5AILqP1mj7kqnhbBSxW9BDxY=
420420
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2/go.mod h1:antQGRDRJiuyQF6l+k6NECCSImgCpwaZapATth2Chv4=
421-
github.com/lightninglabs/lndclient v0.18.4-3 h1:Xk3ZuCQE4ZlF70jaToryL2MvRcryiE0zTfUjJbmzUBY=
422-
github.com/lightninglabs/lndclient v0.18.4-3/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
421+
github.com/lightninglabs/lndclient v0.18.4-5 h1:KokX5ZlFuZEmtD7sHWg1cXzee0ZsnBWuSKV9/RcTEv4=
422+
github.com/lightninglabs/lndclient v0.18.4-5/go.mod h1:tafbfrisn1Iwt3em3nYWdE06C8jpoZtpNyiSB485OCg=
423423
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
424424
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
425425
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=
@@ -428,8 +428,8 @@ github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display h1:Y2WiPkBS
428428
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
429429
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
430430
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
431-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61 h1:EcBM2tz+iyspYRFaDVjUe5a2bkuBWFxOWD2mzdCraUc=
432-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61/go.mod h1:q2DlXwj6ev8TMbo+CvfJ3BIrqw42HFM/fSBoyCFrjdc=
431+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2 h1:zGnSH1gTpPA637465d5tp7VkdWw5sVyWZxxmfZ0rKo4=
432+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2/go.mod h1:nPRQzLla5uHPQFyyZn8r9Vgddkd23PBUDa9rggEPOfY=
433433
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
434434
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ=
435435
github.com/lightningnetwork/lnd/fn v1.2.3 h1:Q1OrgNSgQynVheBNa16CsKVov1JI5N2AR6G07x9Mles=

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ require (
2626
github.com/lib/pq v1.10.9
2727
github.com/lightninglabs/aperture v0.3.2-beta.0.20241015115230-d59b5514c19a
2828
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2
29-
github.com/lightninglabs/lndclient v0.18.4-3
29+
github.com/lightninglabs/lndclient v0.18.4-5
3030
github.com/lightninglabs/neutrino/cache v1.1.2
31-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61
31+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2
3232
github.com/lightningnetwork/lnd/cert v1.2.2
3333
github.com/lightningnetwork/lnd/clock v1.1.1
3434
github.com/lightningnetwork/lnd/fn v1.2.3

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ github.com/lightninglabs/lightning-node-connect v0.2.5-alpha h1:ZRVChwczFXK0CEbx
486486
github.com/lightninglabs/lightning-node-connect v0.2.5-alpha/go.mod h1:A9Pof9fETkH+F67BnOmrBDThPKstqp73wlImWOZvTXQ=
487487
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2 h1:Er1miPZD2XZwcfE4xoS5AILqP1mj7kqnhbBSxW9BDxY=
488488
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.2/go.mod h1:antQGRDRJiuyQF6l+k6NECCSImgCpwaZapATth2Chv4=
489-
github.com/lightninglabs/lndclient v0.18.4-3 h1:Xk3ZuCQE4ZlF70jaToryL2MvRcryiE0zTfUjJbmzUBY=
490-
github.com/lightninglabs/lndclient v0.18.4-3/go.mod h1:/HLqmZGL9MtP8F1g+laq+L9VrsugBN5tsTct3C5wWCg=
489+
github.com/lightninglabs/lndclient v0.18.4-5 h1:KokX5ZlFuZEmtD7sHWg1cXzee0ZsnBWuSKV9/RcTEv4=
490+
github.com/lightninglabs/lndclient v0.18.4-5/go.mod h1:tafbfrisn1Iwt3em3nYWdE06C8jpoZtpNyiSB485OCg=
491491
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
492492
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
493493
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=
@@ -496,8 +496,8 @@ github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display h1:Y2WiPkBS
496496
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
497497
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
498498
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
499-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61 h1:EcBM2tz+iyspYRFaDVjUe5a2bkuBWFxOWD2mzdCraUc=
500-
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241025090009-615f3d633e61/go.mod h1:q2DlXwj6ev8TMbo+CvfJ3BIrqw42HFM/fSBoyCFrjdc=
499+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2 h1:zGnSH1gTpPA637465d5tp7VkdWw5sVyWZxxmfZ0rKo4=
500+
github.com/lightningnetwork/lnd v0.18.3-beta.rc3.0.20241120143113-9246d5c51cd2/go.mod h1:nPRQzLla5uHPQFyyZn8r9Vgddkd23PBUDa9rggEPOfY=
501501
github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf0d0Uy4qBjI=
502502
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
503503
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=

psbt_channel_funder.go

Lines changed: 26 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 "+
@@ -143,6 +156,16 @@ func (l *LndPbstChannelFunder) OpenChannel(ctx context.Context,
143156
}
144157
}
145158

159+
// ChannelAcceptor is used to accept and potentially influence parameters of
160+
// incoming channels.
161+
func (l *LndPbstChannelFunder) ChannelAcceptor(ctx context.Context,
162+
acceptor lndclient.AcceptorFunction) (chan error, error) {
163+
164+
return l.lnd.Client.ChannelAcceptor(
165+
ctx, tapchannel.DefaultTimeout/2, acceptor,
166+
)
167+
}
168+
146169
// A compile-time check to ensure that LndPbstChannelFunder fully implements
147170
// the tapchannel.PsbtChannelFunder interface.
148171
var _ tapchannel.PsbtChannelFunder = (*LndPbstChannelFunder)(nil)

sample-tapd.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@
328328
; universe.multiverse-caches.syncer-cache-pre-alloc-size=100000
329329

330330
; The size of the root node page cache for all requests that aren't served by
331-
; the syncer cache. (default: 10240)
332-
; universe.multiverse-caches.root-node-page-cache-size=10240
331+
; the syncer cache. (default: 327680)
332+
; universe.multiverse-caches.root-node-page-cache-size=327680
333333

334334

335335
[address]

server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ func (s *Server) FetchLeavesFromView(
760760
// NOTE: This method is part of the lnwallet.AuxLeafStore interface.
761761
// nolint:lll
762762
func (s *Server) FetchLeavesFromCommit(chanState lnwl.AuxChanState,
763-
com channeldb.ChannelCommitment,
764-
keys lnwl.CommitmentKeyRing) lfn.Result[lnwl.CommitDiffAuxResult] {
763+
com channeldb.ChannelCommitment, keys lnwl.CommitmentKeyRing,
764+
whoseCommit lntypes.ChannelParty) lfn.Result[lnwl.CommitDiffAuxResult] {
765765

766766
srvrLog.Debugf("FetchLeavesFromCommit called, ourBalance=%v, "+
767767
"theirBalance=%v, numHtlcs=%d", com.LocalBalance,
@@ -1159,7 +1159,8 @@ func (s *Server) ExtraBudgetForInputs(
11591159
//
11601160
// NOTE: This method is part of the sweep.AuxSweeper interface.
11611161
func (s *Server) NotifyBroadcast(req *sweep.BumpRequest,
1162-
tx *wire.MsgTx, fee btcutil.Amount) error {
1162+
tx *wire.MsgTx, fee btcutil.Amount,
1163+
outpointToTxIndex map[wire.OutPoint]int) error {
11631164

11641165
srvrLog.Tracef("NotifyBroadcast called, req=%v, tx=%v, fee=%v",
11651166
spew.Sdump(req), spew.Sdump(tx), fee)

tapcfg/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
464464
DefaultCourierAddr: proofCourierAddr,
465465
AssetSyncer: addrBook,
466466
FeatureBits: lndFeatureBitsVerifier,
467+
ErrChan: mainErrChan,
467468
},
468469
)
469470
auxTrafficShaper := tapchannel.NewAuxTrafficShaper(

tapchannel/aux_funding_controller.go

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/btcsuite/btcd/chaincfg/chainhash"
2121
"github.com/btcsuite/btcd/wire"
2222
"github.com/davecgh/go-spew/spew"
23+
"github.com/lightninglabs/lndclient"
2324
"github.com/lightninglabs/taproot-assets/address"
2425
"github.com/lightninglabs/taproot-assets/asset"
2526
"github.com/lightninglabs/taproot-assets/commitment"
@@ -52,6 +53,28 @@ const (
5253
// ackTimeout is the amount of time we'll wait to receive the protocol
5354
// level ACK from the remote party before timing out.
5455
ackTimeout = time.Second * 30
56+
57+
// maxNumAssetIDs is the maximum number of fungible asset pieces (asset
58+
// IDs) that can be committed to a single channel. The number needs to
59+
// be limited to prevent the number of required HTLC signatures to be
60+
// too large for a single CommitSig wire message to carry them. This
61+
// value is tightly coupled with the number of HTLCs that can be added
62+
// to a channel at the same time (maxNumHTLCs). The values were
63+
// determined with the TestMaxCommitSigMsgSize test in
64+
// aux_leaf_signer_test.go then a set was chosen that would allow for
65+
// a decent number of HTLCs (and also a number that is divisible by two
66+
// because each side will only be allowed to add half of the total).
67+
maxNumAssetIDs = 3
68+
69+
// maxNumHTLCs is the maximum number of HTLCs there can be in an asset
70+
// channel to avoid the number of signatures exceeding the maximum
71+
// message size of a CommitSig message. See maxNumAssetIDs for more
72+
// information.
73+
maxNumHTLCs = 166
74+
75+
// maxNumHTLCsPerParty is the maximum number of HTLCs that can be added
76+
// by a single party to a channel.
77+
maxNumHTLCsPerParty = maxNumHTLCs / 2
5578
)
5679

5780
// ErrorReporter is used to report an error back to the caller and/or peer that
@@ -94,6 +117,11 @@ type OpenChanReq struct {
94117
// PushAmt is the amount of BTC to push to the remote peer.
95118
PushAmt btcutil.Amount
96119

120+
// RemoteMaxHtlc is the maximum number of HTLCs we allow the remote to
121+
// add to the channel. If this is zero, then the default value defined
122+
// by lnd (and dependent on the channel capacity) will be used.
123+
RemoteMaxHtlc uint32
124+
97125
// PeerPub is the identity public key of the remote peer we wish to
98126
// open the channel with.
99127
PeerPub btcec.PublicKey
@@ -133,6 +161,11 @@ type PsbtChannelFunder interface {
133161
// process. Afterward, the funding transaction should be signed and
134162
// broadcast.
135163
OpenChannel(context.Context, OpenChanReq) (AssetChanIntent, error)
164+
165+
// ChannelAcceptor is used to accept and potentially influence
166+
// parameters of incoming channels.
167+
ChannelAcceptor(ctx context.Context,
168+
acceptor lndclient.AcceptorFunction) (chan error, error)
136169
}
137170

138171
// TxPublisher is an interface used to publish transactions.
@@ -217,6 +250,9 @@ type FundingControllerCfg struct {
217250
// FeatureBits is used to verify that the peer has the required feature
218251
// to fund asset channels.
219252
FeatureBits FeatureBitVerifer
253+
254+
// ErrChan is used to report errors back to the main server.
255+
ErrChan chan<- error
220256
}
221257

222258
// bindFundingReq is a request to bind a pending channel ID to a complete aux
@@ -293,6 +329,36 @@ func (f *FundingController) Start() error {
293329
f.Wg.Add(1)
294330
go f.chanFunder()
295331

332+
f.Wg.Add(1)
333+
go func() {
334+
defer f.Wg.Done()
335+
336+
ctx, cancel := f.WithCtxQuitNoTimeout()
337+
defer cancel()
338+
339+
errChan, err := f.cfg.ChannelFunder.ChannelAcceptor(
340+
ctx, f.channelAcceptor,
341+
)
342+
if err != nil {
343+
err = fmt.Errorf("unable to start channel acceptor: %w",
344+
err)
345+
f.cfg.ErrChan <- err
346+
return
347+
}
348+
349+
// We'll accept channels for as long as the funding controller
350+
// is running or until we receive an error.
351+
select {
352+
case err := <-errChan:
353+
err = fmt.Errorf("channel acceptor error: %w", err)
354+
f.cfg.ErrChan <- err
355+
356+
case <-f.Quit:
357+
log.Infof("Stopping channel acceptor, funding " +
358+
"controller shutting down")
359+
}
360+
}()
361+
296362
return nil
297363
}
298364

@@ -1003,10 +1069,11 @@ func (f *FundingController) completeChannelFunding(ctx context.Context,
10031069
// Now that we have the initial PSBT template, we can start the funding
10041070
// flow with lnd.
10051071
fundingReq := OpenChanReq{
1006-
ChanAmt: 100_000,
1007-
PushAmt: fundingState.pushAmt,
1008-
PeerPub: fundingState.peerPub,
1009-
TempPID: fundingState.pid,
1072+
ChanAmt: 100_000,
1073+
PushAmt: fundingState.pushAmt,
1074+
PeerPub: fundingState.peerPub,
1075+
TempPID: fundingState.pid,
1076+
RemoteMaxHtlc: maxNumHTLCsPerParty,
10101077
}
10111078
assetChanIntent, err := f.cfg.ChannelFunder.OpenChannel(ctx, fundingReq)
10121079
if err != nil {
@@ -1430,6 +1497,26 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
14301497
}
14311498
}()
14321499

1500+
// We need to limit the number of different fungible assets (asset IDs)
1501+
// we allow to be commited to a single channel. This is to make sure we
1502+
// have a decent number of HTLCs available. See Godoc of maxNumAssetIDs
1503+
// for more information.
1504+
//
1505+
// TODO(guggero): This following code is obviously wrong and needs to be
1506+
// changed when we support committing fungible assets into a channel. To
1507+
// avoid this TODO from being overlooked, we add a dummy implementation
1508+
// with a condition that currently will never be true (since there's
1509+
// only a single vPacket being selected currently anyway).
1510+
assetIDSet := lfn.NewSet[asset.ID]()
1511+
for _, out := range fundingVpkt.VPacket.Outputs {
1512+
assetIDSet.Add(out.Asset.ID())
1513+
}
1514+
if assetIDSet.Size() > maxNumAssetIDs {
1515+
return fmt.Errorf("too many different asset IDs in channel "+
1516+
"funding, got %d, max is %d", len(assetIDSet.ToSlice()),
1517+
maxNumAssetIDs)
1518+
}
1519+
14331520
// Now that we know the final funding asset root along with the splits,
14341521
// we can derive the tapscript root that'll be used alongside the
14351522
// internal key (which we'll only learn from lnd later as we finalize
@@ -1677,6 +1764,43 @@ func (f *FundingController) chanFunder() {
16771764
}
16781765
}
16791766

1767+
// channelAcceptor is a callback that's called by the lnd client when a new
1768+
// channel is proposed. This function is responsible for deciding whether to
1769+
// accept the channel based on the channel parameters, and to also set some
1770+
// channel parameters for our own side.
1771+
func (f *FundingController) channelAcceptor(_ context.Context,
1772+
req *lndclient.AcceptorRequest) (*lndclient.AcceptorResponse, error) {
1773+
1774+
// Avoid nil pointer dereference.
1775+
if req.CommitmentType == nil {
1776+
return nil, fmt.Errorf("commitment type is required")
1777+
}
1778+
1779+
// Ignore any non-asset channels, just accept them.
1780+
if *req.CommitmentType != lnwallet.CommitmentTypeSimpleTaprootOverlay {
1781+
return &lndclient.AcceptorResponse{
1782+
Accept: true,
1783+
}, nil
1784+
}
1785+
1786+
// Reject custom channels that don't observe the max HTLC limit.
1787+
if req.MaxAcceptedHtlcs > maxNumHTLCsPerParty {
1788+
return &lndclient.AcceptorResponse{
1789+
Accept: false,
1790+
Error: fmt.Sprintf("max accepted HTLCs must be at "+
1791+
"most %d, got %d", maxNumHTLCsPerParty,
1792+
req.MaxAcceptedHtlcs),
1793+
}, nil
1794+
}
1795+
1796+
// Everything looks good, we can now set our own max HTLC limit we'll
1797+
// observe for this channel.
1798+
return &lndclient.AcceptorResponse{
1799+
Accept: true,
1800+
MaxHtlcCount: maxNumHTLCsPerParty,
1801+
}, nil
1802+
}
1803+
16801804
// validateProofs validates the inclusion/exclusion/split proofs and the
16811805
// transfer witness of the given proofs.
16821806
func (f *FundingController) validateProofs(proofs []*proof.Proof) error {

0 commit comments

Comments
 (0)