Skip to content

Commit 39c71b1

Browse files
committed
tapchannel: add check for number of asset IDs in channel
We add a placeholder implementation that currently does nothing but will help us to think about this problem when we implement fungible asset support in tapd.
1 parent a72dcbc commit 39c71b1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tapchannel/aux_funding_controller.go

+20
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,26 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
14841484
}
14851485
}()
14861486

1487+
// We need to limit the number of different fungible assets (asset IDs)
1488+
// we allow to be commited to a single channel. This is to make sure we
1489+
// have a decent number of HTLCs available. See Godoc of maxNumAssetIDs
1490+
// for more information.
1491+
//
1492+
// TODO(guggero): This following code is obviously wrong and needs to be
1493+
// changed when we support committing fungible assets into a channel. To
1494+
// avoid this TODO from being overlooked, we add a dummy implementation
1495+
// with a condition that currently will never be true (since there's
1496+
// only a single vPacket being selected currently anyway).
1497+
assetIDSet := lfn.NewSet[asset.ID]()
1498+
for _, out := range fundingVpkt.VPacket.Outputs {
1499+
assetIDSet.Add(out.Asset.ID())
1500+
}
1501+
if len(assetIDSet.ToSlice()) > maxNumAssetIDs {
1502+
return fmt.Errorf("too many different asset IDs in channel "+
1503+
"funding, got %d, max is %d", len(assetIDSet.ToSlice()),
1504+
maxNumAssetIDs)
1505+
}
1506+
14871507
// Now that we know the final funding asset root along with the splits,
14881508
// we can derive the tapscript root that'll be used alongside the
14891509
// internal key (which we'll only learn from lnd later as we finalize

0 commit comments

Comments
 (0)