Skip to content

Commit 37efc27

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 e617424 commit 37efc27

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
@@ -1485,6 +1485,26 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
14851485
}
14861486
}()
14871487

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

0 commit comments

Comments
 (0)