Skip to content

Commit dcee975

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 4382b05 commit dcee975

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
@@ -1497,6 +1497,26 @@ func (f *FundingController) processFundingReq(fundingFlows fundingFlowIndex,
14971497
}
14981498
}()
14991499

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+
15001520
// Now that we know the final funding asset root along with the splits,
15011521
// we can derive the tapscript root that'll be used alongside the
15021522
// internal key (which we'll only learn from lnd later as we finalize

0 commit comments

Comments
 (0)