Skip to content

cli: add group key support to channel related calls. #1052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2025

Conversation

guggero
Copy link
Member

@guggero guggero commented Apr 30, 2025

@ZZiigguurraatt
Copy link

@ZZiigguurraatt can you help test this PR please?

Working on it.

@ZZiigguurraatt
Copy link

For litcli ln sendpayment, why do we have the requirement Note that this will only work in concert with the --keysend argument.? This conflicts with the statement

One can either specify the full
  parameters of the payment, or just use a payment request which encodes
  all the payment details.

  If payment isn't manually specified, then only a payment request needs
  to be passed using the --pay_req argument.

.

Confused if this comment belongs here or in lightninglabs/taproot-assets#1498 ?

@ZZiigguurraatt
Copy link

litcli ln sendpayment - Send a payment over Lightning, potentially using a mulit-asset channel as the first hop needs multi spelled right.

@ZZiigguurraatt
Copy link

At https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R451 you say Pay an invoice over lightning using an asset. and at https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R298-R299 you say Send a payment over Lightning, potentially using a mulit-asset channel as the first hop. I think these descriptions should be more consistent so we aren't confused there is some major difference in functionality.

@ZZiigguurraatt
Copy link

At https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R37 you say Interact with the Lightning Network., but I think we should be more specific so that when running litcli ln we know under NAME that this is about taproot assets without having to read through the description of each sub-command in detail.

@ZZiigguurraatt
Copy link

In https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R301-R302 you say To send an multi-asset LN payment to a single hop, the --asset_id=X argument should be used. This does not make any mention of group_key. Also, I'm a bit confused because with this command, I must specify either a asset_id or group_key, there is no other option, but the word choice leads me to believe that maybe I can send a non multi-asset payment with the command.

@ZZiigguurraatt
Copy link

If all these things can be fixed, I think we can also close lightninglabs/taproot-assets#1183 .

@guggero
Copy link
Member Author

guggero commented May 5, 2025

Here we also need to mention group_key

https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R666-R667

https://github.com/lightninglabs/lightning-terminal/pull/1052/files#diff-f9c05a4a36f7d2dcc59718bda9351aeab75a35de48e367bcd08d8cbf1f4be8f7R671-R672

Will update. As an aside: if you go to the "Files changed" tab in a PR, then you can add comments to a specific line of a PR. And then you can also group multiple such comments into a single review, which makes it easy to see and resolve. Less work for you and also less work for the author.

@guggero guggero force-pushed the group-key-support-cli branch from 96b3339 to 4f688aa Compare May 5, 2025 11:26
@guggero
Copy link
Member Author

guggero commented May 5, 2025

@ZZiigguurraatt thanks for your feedback! I think I've addressed all your comments in the latest push.

@ZZiigguurraatt
Copy link

As an aside: if you go to the "Files changed" tab in a PR, then you can add comments to a specific line of a PR.

this did not work for lines out of range from the edits you made

@guggero guggero force-pushed the group-key-support-cli branch from 4f688aa to c63c403 Compare May 5, 2025 13:30
@guggero
Copy link
Member Author

guggero commented May 5, 2025

Fixed the compilation issue.

@ZZiigguurraatt
Copy link

ZZiigguurraatt commented May 5, 2025

@ZZiigguurraatt thanks for your feedback! I think I've addressed all your comments in the latest push.

Okay, what do you think about this comment I made above "If I try sendpayment --pay_req= instead, I get [litcli] the --keysend flag must be set.", but litcli ln payinvoice -h says This command is a shortcut for 'sendpayment --pay_req=', so I feel like we are getting some conflicting information. This is also related to #1052 (comment)

@guggero
Copy link
Member Author

guggero commented May 6, 2025

@ZZiigguurraatt thanks for your feedback! I think I've addressed all your comments in the latest push.

Okay, what do you think about this comment I made above "If I try sendpayment --pay_req= instead, I get [litcli] the --keysend flag must be set.", but litcli ln payinvoice -h says This command is a shortcut for 'sendpayment --pay_req=', so I feel like we are getting some conflicting information. This is also related to #1052 (comment)

I didn't see that comment anywhere before...
But I'll look into it.

@levmi levmi requested review from ffranr, Roasbeef, gijswijs and GeorgeTsagk and removed request for Roasbeef and ffranr May 6, 2025 16:56
@ZZiigguurraatt
Copy link

I didn't see that comment anywhere before...

actually, maybe you don't get them unless I click "submit review"? I thought that meant I was satisfied with changes, but looks like I actually have a few options when I submit.

@guggero guggero force-pushed the group-key-support-cli branch 3 times, most recently from e3e8b5e to 9d9d26a Compare May 7, 2025 10:34
@guggero
Copy link
Member Author

guggero commented May 7, 2025

Okay, so the attempt at making This command is a shortcut for 'sendpayment --pay_req= work made me realize that we never intended the sendpayment command to work in any other way than with --keysend.

This whole confusion came out of the attempt to re-use a lot of the description and also validation logic from lnd. But that just made it very hard to understand.

So I did this instead:

  • Remove the This command is a shortcut for 'sendpayment --pay_req= part from the description of payinvoice.
  • Updated the description of sendpayment to make it very explicit the command is only for keysend payments.
  • I considered renaming the command to keysend and removing the need for the --keysend flag. But that would break existing users/scripts and would lead to a bunch of duplicated code. So I decided to leave things this way. It's a bit verbose but at least the description should be more clear now.

I think with that things should be way more clear. I hope you agree with the changes, @ZZiigguurraatt.

@ZZiigguurraatt
Copy link

I tested FundChannel and I'm getting the following:

fd3988c2dd94:/$ tapcli assets groups
{
    "groups":  {
        "025ab6480a9af4d284c1e7c4b9391e2198cd54e96f41c3450499b51b0af194af57":  {
            "assets":  [
                {
                    "id":  "f1d09444f6d9935d1a22a00416dbcb9a2c1eb7d923d322871e4df1ce024415af",
                    "amount":  "2100000",
                    "lock_time":  0,
                    "relative_lock_time":  0,
                    "tag":  "Asset1",
                    "meta_hash":  "827c23a4b1a5f4f9a9a42e61aa7bf7bf7e7925b4723728b60ad1918d632e2b0a",
                    "type":  "NORMAL",
                    "version":  "ASSET_VERSION_V0"
                },
                {
                    "id":  "4b4be6b3f93c992aac615d7534eb52a81c2d077fb35717e0d8ac1ba226e1ba54",
                    "amount":  "2100000",
                    "lock_time":  0,
                    "relative_lock_time":  0,
                    "tag":  "Asset1",
                    "meta_hash":  "827c23a4b1a5f4f9a9a42e61aa7bf7bf7e7925b4723728b60ad1918d632e2b0a",
                    "type":  "NORMAL",
                    "version":  "ASSET_VERSION_V0"
                },
                {
                    "id":  "6c360362f0f62bcf0a6abd1b50d3c77dfd6d685fdbbfd9804a2b1f786cd0e9b5",
                    "amount":  "2100000",
                    "lock_time":  0,
                    "relative_lock_time":  0,
                    "tag":  "Asset1",
                    "meta_hash":  "827c23a4b1a5f4f9a9a42e61aa7bf7bf7e7925b4723728b60ad1918d632e2b0a",
                    "type":  "NORMAL",
                    "version":  "ASSET_VERSION_V0"
                }
            ]
        }
    }
}
fd3988c2dd94:/$ 
fd3988c2dd94:/$ 
fd3988c2dd94:/$ 
fd3988c2dd94:/$ litcli ln fundchannel --node_key 025974657e16df81f32623ed5fe33d49529b26659ef2de9a87d8b102e576b26af3 --asset_amount 100000 --group_key 025ab6480a9af4d284c1e7c4b9391e2198cd54e96f41c3450499b51b0af194af57
[litcli] asset with ID  not found or no combined UTXOs with at least amount 100000 is available
fd3988c2dd94:/$ 

@guggero guggero force-pushed the group-key-support-cli branch from 9d9d26a to 747706f Compare May 8, 2025 12:18
@guggero
Copy link
Member Author

guggero commented May 8, 2025

[litcli] asset with ID not found or no combined UTXOs with at least amount 100000 is available

Oops, my bad, sorry. Fixed that issue and tested the flow manually as well this time.

Copy link
Contributor

@gijswijs gijswijs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some comments throughout. The most important one is this one: #1052 (comment)

The others are all nits.

I tested the itest locally.

@guggero guggero force-pushed the group-key-support-cli branch from 747706f to 8cc2631 Compare May 8, 2025 13:34
Copy link
Contributor

@gijswijs gijswijs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@ZZiigguurraatt
Copy link

OK, things took longer on my end with some stupid mistakes managing multiple in flight PR that need to be coordinated on top of each other. I'm now able to get it to work, but I get the following error if I don't specify a fee rate

4bb544a08a1e:/$ litcli ln fundchannel --node_key  03d344679dc9a285183618a3eb1be0c897c9e6833f5f8c80513dd6534706e9ed59 --asset_amount 1000000 --group_key  02220e67ea8260deefdda3d514de83e2634ac0611e8133af21855ce43981dc598c
[litcli] error funding channel: rpc error: code = Unknown desc = fee rate must be specified
4bb544a08a1e:/$

however,

4bb544a08a1e:/$ litcli ln fundchannel -h
NAME:
   litcli ln fundchannel - Open a Taproot Asset channel with a node on the Lightning Network.

USAGE:
   litcli ln fundchannel [command options] [arguments...]

CATEGORY:
   Channels

OPTIONS:
   --node_key value       the identity public key of the target node/peer serialized in compressed format, must already be connected to
   --sat_per_vbyte value  (optional) a manual fee expressed in sat/vByte that should be used when crafting the transaction (default: 0)
   --push_amt value       the number of satoshis to give the remote side as part of the initial commitment state, this is equivalent to first opening a channel and then sending the remote party funds, but done all in one step; therefore, this is equivalent to a donation to the remote party, unless they reimburse the funds in another way (outside the protocol) (default: 0)
   --asset_amount value   The amount of the asset to commit to the channel. (default: 0)
   --asset_id value       The asset ID to commit to the channel; cannot be used at the same time as --group_key
   --group_key value      The group key to use for selecting assets to commit to the channel; cannot be used at the same time as --asset_id
   
4bb544a08a1e:/$ 

tells me the fee rate should be optional.

I don't remember having to do this last time I ran lncli openchannel.

Also, is (default: 0) supposed to actually be 0 or some auto fee selection (both in litcli ln fundchannel and lncli openchannel?

I did try

4bb544a08a1e:/$ litcli ln fundchannel --node_key  03d344679dc9a285183618a3eb1be0c897c9e6833f5f8c80513dd6534706e9ed59 --asset_amount 1000000 --group_key  02220e67ea8260deefdda3d514de83e2634ac0611e8133af21855ce43981dc598c --sat_per_vbyte 1
[litcli] error funding channel: rpc error: code = Unknown desc = error funding channel: fee rate 250 sat/kw too low, min_relay_fee: 253 sat/kw
4bb544a08a1e:/$ 

and

4bb544a08a1e:/$ litcli ln fundchannel --node_key  03d344679dc9a285183618a3eb1be0c897c9e6833f5f8c80513dd6534706e9ed59 --asset_amount 1000000 --group_key  02220e67ea8260deefdda3d514de83e2634ac0611e8133af21855ce43981dc598c --sat_per_vbyte 0
[litcli] error funding channel: rpc error: code = Unknown desc = fee rate must be specified
4bb544a08a1e:/$ 

and then finally what worked was

4bb544a08a1e:/$ litcli ln fundchannel --node_key  03d344679dc9a285183618a3eb1be0c897c9e6833f5f8c80513dd6534706e9ed59 --asset_amount 1000000 --group_key  02220e67ea8260deefdda3d514de83e2634ac0611e8133af21855ce43981dc598c --sat_per_vbyte 3
{
	"txid": "17522c5c0384ed7f8ea7ebc76c402f1df768a003f97ca7a3fe5545af042584f2"
}
4bb544a08a1e:/$ 

@ZZiigguurraatt
Copy link

I am still going through some other tests, so I have not approved this yet.

@ZZiigguurraatt
Copy link

I don't remember having to do this last time I ran lncli openchannel.

I just re-tested and this works:

4bb544a08a1e:/$ lncli openchannel --node_key 03d344679dc9a285183618a3eb1be0c897c9e6833f5f8c80513dd6534706e9ed59 --local_amt 5000000
{
    "funding_txid": "29ab2aebc847708433b1b0d879fa2308b6e81a6c6d7c12ea97642e60bea357d3"
}
4bb544a08a1e:/$ 

@guggero
Copy link
Member Author

guggero commented May 9, 2025

I don't remember having to do this last time I ran lncli openchannel.

I think, starting with lnd 18 or 19 it's now required in lnd as well. Depending on a (potentially faulty) estimated fee has given us too many user support issues.

Also, is (default: 0) supposed to actually be 0

This is an unfortunate way the CLI library displays things. A numeric value of 0 just means "by default this flag is not set". So no, there is no auto fee estimation, you have to specify a value.

error funding channel: fee rate 250 sat/kw too low, min_relay_fee: 253 sat/kw

I did fix this issue with an additional commit in lightninglabs/taproot-assets#1498, so you should be able to specify --sat_per_vbyte 1 now.

Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@guggero guggero force-pushed the group-key-support-cli branch 3 times, most recently from 45c803f to 22f61e7 Compare May 14, 2025 11:29
@guggero guggero force-pushed the group-key-support-cli branch from 22f61e7 to e0fe977 Compare May 15, 2025 10:02
@guggero guggero merged commit 131eda1 into master May 15, 2025
18 of 22 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board May 15, 2025
@guggero guggero deleted the group-key-support-cli branch May 15, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[bug]: add group key support to litcli ln addinvoice [bug]: clean up documentation for sendpayment
4 participants