Skip to content
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

Rune restriction not being enforced on pnamedescription or pnamelabel when issuing invoice #7316

Closed
Amperstrand opened this issue May 15, 2024 · 1 comment

Comments

@Amperstrand
Copy link

Amperstrand commented May 15, 2024

Rune restriction that works as expected

Intention: to be able to invoice up to 1 satoshi

lightning-cli decode string=$(lightning-cli createrune restrictions='[["method=invoice"], ["pnameamount_msat<10001"]]' | jq .rune)
{
   "type": "rune",
   "unique_id": "337",
   "string": "XXXX:=337&method=invoice&pnameamount_msat<10001",
   "restrictions": [
      {
         "alternatives": [
            "method=invoice"
         ],
         "summary": "method (of command) equal to 'invoice'"
      },
      {
         "alternatives": [
            "pnameamount_msat<10001"
         ],
         "summary": "pnameamount_msat (object parameter 'amount_msat') less than 10001"
      }
   ],
   "valid": true
}

The above works and is not an issue. It is provided to show that the next example is nearly identical, except instead of creating a restriction on amount_msat, it will try to put a restriction on the description field.

Rune restriction that does not work as expected

Intention: to require the user to enter "Paid to teststore" as the beginning of the description.

This will make it possible to have 2 users with different runes: one that must label all transactions as "Paid to teststore" and the other that must label all transactions as "Paid to otherstore". This way it will be clear which user issued which invoice.

lightning-cli decode string=$(lightning-cli createrune restrictions='[["method=invoice"], ["pnamedescription^Paid to teststore"]]' | jq .rune)
{
   "type": "rune",
   "unique_id": "338",
   "string": "XXX:=338&method=invoice&pnamedescription^Paid to teststore",
   "restrictions": [
      {
         "alternatives": [
            "method=invoice"
         ],
         "summary": "method (of command) equal to 'invoice'"
      },
      {
         "alternatives": [
            "pnamedescription^Paid to teststore"
         ],
         "summary": "pnamedescription (object parameter 'description') starts with 'Paid to teststore'"
      }
   ],
   "valid": true
}

Unfortunately, this rune restriction did not work, and bkpr-listincome shows that it was possible to use this rune to create an invoice with the description "Paid to otherstore":

      {
         "account": "ee7cee5832e12fd5c7fe346e13342b20398a6010c3761c59da18d77d9aafe5d5",
         "tag": "invoice",
         "credit_msat": 1000,
         "debit_msat": 0,
         "currency": "bc",
         "timestamp": 1715802298,
         "description": "Paid to otherstore (Order ID: )",
         "payment_id": "99fa0b27e64c19ac4ad9455470283d51c5de6a8600e4dcaf2e4fa9a9420923d9"
      }

getinfo output

v23.05-1649-g54c5135

@Amperstrand
Copy link
Author

The above issue might not (or is probably not) the case.

It might be that lnbits caches the rune that is stored in the .env file so that even if you update the rune in the .env file, it uses the old rune.

Closing this issue until or unless I am able to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant