From 2a50a51c3fa149b0cabf0d97b065a29f05970b2c Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Tue, 8 Oct 2024 15:57:12 +0200 Subject: [PATCH] litcli: relax fundchannel checks The RPC calls were updated to allow composite UTXOs (assets from multiple asset utxos) for funding capability, but the same functionality is not available in the CLI due to the existing sanity check. This commits changes the sanity check to allow for composite UTXOs by validating whether the running sum of the assets in the UTXOs is greater than the amount to be funded. --- cmd/litcli/ln.go | 15 ++++++++------- docs/release-notes/release-notes-0.13.995.md | 9 ++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cmd/litcli/ln.go b/cmd/litcli/ln.go index c261910f9..5593de7fe 100644 --- a/cmd/litcli/ln.go +++ b/cmd/litcli/ln.go @@ -120,22 +120,23 @@ func fundChannel(c *cli.Context) error { } assetFound := false + totalAmount := uint64(0) for _, rpcAsset := range assets.Assets { if !bytes.Equal(rpcAsset.AssetGenesis.AssetId, assetIDBytes) { continue } - if rpcAsset.Amount < requestedAmount { - continue + totalAmount += rpcAsset.Amount + if totalAmount >= requestedAmount { + assetFound = true + break } - - assetFound = true } if !assetFound { - return fmt.Errorf("asset with ID %x not found or no UTXO with "+ - "at least amount %d is available", assetIDBytes, - requestedAmount) + return fmt.Errorf("asset with ID %x not found or no combined "+ + "UTXOs with at least amount %d is available", + assetIDBytes, requestedAmount) } resp, err := tchrpcClient.FundChannel( diff --git a/docs/release-notes/release-notes-0.13.995.md b/docs/release-notes/release-notes-0.13.995.md index b85586f37..08a7f5d8b 100644 --- a/docs/release-notes/release-notes-0.13.995.md +++ b/docs/release-notes/release-notes-0.13.995.md @@ -19,9 +19,12 @@ ### Taproot Assets * A few bugs related to TAP channel liquidity were fixed, sending very small or -very big asset amounts is now possible. See [tapd PR](https://github.com/lightninglabs/taproot-assets/pull/1120). -* `ListBalances` now supports the `include_leased` flag, which will include leased -asset balances in the response. +very big asset amounts is now possible. +See [tapd PR](https://github.com/lightninglabs/taproot-assets/pull/1120). +* `ListBalances` now supports the `include_leased` flag, which will include +leased asset balances in the response. +* [The sanity checks for `fundchannel` now allow for composite +UTXOs.](https://github.com/lightninglabs/lightning-terminal/pull/865) # Autopilot