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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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
cmd/litcli/ln.go Outdated
@@ -437,17 +453,18 @@ var payInvoiceCommand = cli.Command{
This command attempts to pay an invoice using an asset channel as the
source of the payment. The asset ID of the channel must be specified
using the --asset_id flag.

This command is a shortcut for 'sendpayment --pay_req='.

Choose a reason for hiding this comment

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

If I try sendpayment --pay_req= instead, I get [litcli] the --keysend flag must be set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was an incorrect check. Fixed that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, that didn't work. See main comment at the bottom.

@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
Copy link
Member Author

guggero commented May 7, 2025

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.

Yeah, as long as it says "pending", only you see the comment.

@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.

}
}

if len(assetIDBytes) == 0 && len(groupKeyBytes) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely this must be

Suggested change
if len(assetIDBytes) == 0 && len(groupKeyBytes) == 0 {
if len(assetIDBytes) > 0 && len(groupKeyBytes) > 0 {

or I'm not understanding the logic here.

To send a multi-asset LN keysend payment, the --asset_id=X or
--group_key=X argument can be used to specify the asset to use.

Note that this command will only work with the --keysend argument set.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for the B1-level writing.

}

assetAmountToSend := cliCtx.Uint64(assetAmountFlag.Name)
if assetAmountToSend == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to check for zero amounts? Or is this offloaded to tapd?

PayReqString: payReq,
},
)
decodeResp, err := aliceTap.DecodeAssetPayReq(ctx, &tchrpc.AssetPayReq{
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't follow our dev guidelines. When wrapping long function calls, all arguments should begin in a new line after the open parenthesis and the close parenthesis should be placed on its own line. This is also true for the alice.AddInvoice function call above, and the aliceTap.DecodeAssetPayReq call below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
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
3 participants