lightning icon indicating copy to clipboard operation
lightning copied to clipboard

runes: pname restrictions fail if the parameter has an underscore

Open jb55 opened this issue 2 years ago • 7 comments

   > lightning-cli commando-rune restrictions='["method=invoice","pnameamount_msat=any"]'
{
   "code": -32602,
   "message": "restrictions: not a valid restriction: invalid token '\"pnameamount_msat=any\"'"
}

jb55 avatar Aug 21 '22 18:08 jb55

Is this still a valid issue?

bshramin avatar May 21 '23 02:05 bshramin

Yes, this is still a valid issue.

niftynei avatar May 28 '23 00:05 niftynei

HI @jb55,

1- Check Parameter Name: Ensure that pnameamount_msat is a valid parameter name for the invoice method in lightning-cli. If it's not a recognized parameter, the command will fail.

2- Syntax Check: Ensure that the syntax of the restrictions array is correct. In some cases, the way arguments are passed, especially in a shell environment, can affect how they are interpreted.

3 -Documentation Reference: Consult the documentation for lightning-cli and commando-rune to ensure that your syntax and usage of the parameters align with the documented method.

4- Experiment with Different Formats: Sometimes, trying different formats can help identify the issue. For example, you could try simplifying the command to see if it works with just one restriction, then add the second one.

Try modifying the command like this: 1st: lightning-cli commando-rune restrictions='["method=invoice","amount_msat=any"]'

2nd: [ if the pname prefix is required and amount_msat is the correct parameter:] lightning-cli commando-rune restrictions='["method=invoice","pname=amount_msat=any"]'

Note: use bash terminal

aliraza556 avatar Jan 18 '24 01:01 aliraza556

On Wed, Jan 17, 2024 at 05:30:10PM -0800, Ali Raza wrote:

HI @jb55,

1- Check Parameter Name: Ensure that pnameamount_msat is a valid parameter name for the invoice method in lightning-cli. If it's not a recognized parameter, the command will fail.

2- Syntax Check: Ensure that the syntax of the restrictions array is correct. In some cases, the way arguments are passed, especially in a shell environment, can affect how they are interpreted.

3 -Documentation Reference: Consult the documentation for lightning-cli and commando-rune to ensure that your syntax and usage of the parameters align with the documented method.

4- Experiment with Different Formats: Sometimes, trying different formats can help identify the issue. For example, you could try simplifying the command to see if it works with just one restriction, then add the second one.

I don't think ChatGPT is gonna help here.

jb55 avatar Jan 18 '24 17:01 jb55

@jb55 Not sure if this issue auto-fixed in the meantime or the command was malformed from the starting. But the command is working with version 23.11. Note that the restrictions parameter expects arrays of restrictions.

lightning-cli commando-rune restrictions='[["method=invoice"], ["pnameamount_msat=any"]]' lightning-cli commando-rune restrictions='[["method=pay"], ["pnameamount_msat<10000"]]'

Please feel free to comment here if it still doesn't work for you. Closing the issue for now.

ShahanaFarooqui avatar Jan 19 '24 17:01 ShahanaFarooqui

nice, thanks!

jb55 avatar Jan 19 '24 18:01 jb55

@jb55 Reopening the issue due to:

  • Discrepancy between createrune and checkrune. Either createrune should also remove _ from parameter names before creating the rune or checkrune should also work with _.
  • Documentation also needs to be updated accordingly.

Till it is addressed, pname restrictions can be used after manually removing _ from parameters. eg: lightning-cli commando-rune restrictions='[["method=invoice"], ["pnameamountmsat=any"]]' Or lightning-cli createrune restrictions='[["method=pay"], ["pnameamountmsat<10000"]]'

ShahanaFarooqui avatar Feb 20 '24 22:02 ShahanaFarooqui

Closing with PR #7124

ShahanaFarooqui avatar May 24 '24 00:05 ShahanaFarooqui