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

paying to invoice with deschashonly=true not working #6085

Closed
daywalker90 opened this issue Mar 10, 2023 · 14 comments · Fixed by #6337
Closed

paying to invoice with deschashonly=true not working #6085

daywalker90 opened this issue Mar 10, 2023 · 14 comments · Fixed by #6337
Assignees
Milestone

Comments

@daywalker90
Copy link
Contributor

very simple python script basically 2 lines:
cln = LightningRpc("/home/bitcoin/.lightning/bitcoin/lightning-rpc")
and then the call to pay and later invoice:

cln.pay(bolt11="lnbc10n1pjqh27app5wrx6rpq6utf5n8hggj6y2z44cdw47syrtpf93j6p78c8x2wldafshp5mg0dq0gh9jdm5l9h5p43tq8kvpz3k958hrv86pmq02vmw2uyc92qcqzpgxqzpusp57dt9lfdgs9dz9thrh8emnpl8dnlll2fqptftq64ayl205l7qh90s9qyyssqquhv5flwksfe492046rlffxknjp5x4ptf2sl5cjhasvge9rvrtfzdy5xk98fs9kd0je9gghs327c7vjhw4cd3qy2zlydaaknprryehqpqnpgc7", description='[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]')
pyln.client.lightning.RpcError: RPC call failed: method: pay, payload: {'bolt11': 'lnbc10n1pjqh27app5wrx6rpq6utf5n8hggj6y2z44cdw47syrtpf93j6p78c8x2wldafshp5mg0dq0gh9jdm5l9h5p43tq8kvpz3k958hrv86pmq02vmw2uyc92qcqzpgxqzpusp57dt9lfdgs9dz9thrh8emnpl8dnlll2fqptftq64ayl205l7qh90s9qyyssqquhv5flwksfe492046rlffxknjp5x4ptf2sl5cjhasvge9rvrtfzdy5xk98fs9kd0je9gghs327c7vjhw4cd3qy2zlydaaknprryehqpqnpgc7', 'description': '[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]'}, error: {'code': -32602, 'message': 'Invalid bolt11: h: does not match description'}
lcli decode lnbc10n1pjqh27app5wrx6rpq6utf5n8hggj6y2z44cdw47syrtpf93j6p78c8x2wldafshp5mg0dq0gh9jdm5l9h5p43tq8kvpz3k958hrv86pmq02vmw2uyc92qcqzpgxqzpusp57dt9lfdgs9dz9thrh8emnpl8dnlll2fqptftq64ayl205l7qh90s9qyyssqquhv5flwksfe492046rlffxknjp5x4ptf2sl5cjhasvge9rvrtfzdy5xk98fs9kd0je9gghs327c7vjhw4cd3qy2zlydaaknprryehqpqnpgc7
{
   "type": "bolt11 invoice",
   "currency": "bc",
   "created_at": 1678486493,
   "expiry": 60,
   "payee": "03cc1d0932bb99b0697f5b5e5961b83ab7fd66f1efc4c9f5c7bad66c1bcbe78f02",
   "msatoshi": 1000,
   "amount_msat": "1000msat",
   "description_hash": "da1ed03d172c9bba7cb7a06b1580f660451b1687b8d87d07607a99b72b84c154",
   "min_final_cltv_expiry": 40,
   "payment_secret": "f3565fa5a8815a22aee3b9f3b987e76cffffa9200ad2b06abd27d4fa7fc0b95f",
   "features": "024200",
   "payment_hash": "70cda1841ae2d3499ee844b4450ab5c35d5f4083585258cb41f1f07329df6f53",
   "signature": "30440220072eca27eeb4139a954fae87f4a4d69c8343542b4aa1fa6257ec188c946c1ad20220269286b14e9816cd7cb25422f08abd8f32577570d8808a17c8def6d308c64cdc",
   "valid": true
}

sha256sum seems fine:
echo -n '[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]' | sha256sum da1ed03d172c9bba7cb7a06b1580f660451b1687b8d87d07607a99b72b84c154 -

double check the other way around:

cln.invoice(label="test22", amount_msat=1000, description='[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]', deschashonly=True)
lcli decode lnbc10n1pjqhvg9sp5s7cq5lz5j2sthtt7gcwnd4x765zp6mtwfhjx67hqvuqwefk5407spp5nd2ee7zqmm5q3leczxpju0cseucqlenzkqgqr7k5sh76599majkshp5mg0dq0gh9jdm5l9h5p43tq8kvpz3k958hrv86pmq02vmw2uyc92qxqyjw5qcqpjrzjqtz2wwgvts8z3ml4mqp55jwhyjgqkxtffr6hy0lvmzr4z2e0qqs0xz7s4vqqfucqqyqqqqqqqqqqqzsqyg9qyysgqyy3q3amsm7etpcyyy46n7hfc98feg495w7pq850xlzgdgagf97u9afnuvsf0zjkr7eggn4mwcqkm6hn9s309mk8schkf3quafrqqg9gpnyk9vs
{
   "type": "bolt11 invoice",
   "currency": "bc",
   "created_at": 1678487813,
   "expiry": 604800,
   "payee": "0380ef0209ff1b46c38a37cd40f613d1dae3eba481a909459d6c1434a0e56e5d8c",
   "msatoshi": 1000,
   "amount_msat": "1000msat",
   "description_hash": "da1ed03d172c9bba7cb7a06b1580f660451b1687b8d87d07607a99b72b84c154",
   "min_final_cltv_expiry": 18,
   "payment_secret": "87b00a7c5492a0bbad7e461d36d4ded5041d6d6e4de46d7ae06700eca6d4abfd",
   "features": "024100",
   "routes": [
      [
         {
            "pubkey": "02c4a7390c5c0e28eff5d8034a49d724900b196948f5723fecd887512b2f0020f3",
            "short_channel_id": "774315x1267x1",
            "fee_base_msat": 0,
            "fee_proportional_millionths": 10,
            "cltv_expiry_delta": 34
         }
      ]
   ],
   "payment_hash": "9b559cf840dee808ff3811832e3f10cf300fe662b01001fad485fdaa14bbecad",
   "signature": "30440220212208f770dfb2b0e08425753f5d3829d39454b4778203d1e6f890d475092fb802205ea67c6412f14ac3f65089d76ec02dbd5e65845e5dd8f0c5ec98839d48c00415",
   "valid": true
}

I don't get it. hash seems fine.

@daywalker90 daywalker90 changed the title paying to invoices with deschashonly=true not working paying to invoice with deschashonly=true not working Mar 10, 2023
@daywalker90
Copy link
Contributor Author

i'm aware that it works with simple descriptions like "test". But this one does not. I tried to .encode() the description but then i get 'bytes' object has no attribute 'to_json'. I'm not in control of the description so i can't change it either. I need to know how to make this one work with the pyln-client.

@daywalker90
Copy link
Contributor Author

daywalker90 commented Mar 11, 2023

example python script:

#!/usr/bin/env python3
from pyln.client import LightningRpc
cln1 = LightningRpc("/tmp/l1-regtest/regtest/lightning-rpc")
cln2 = LightningRpc("/tmp/l2-regtest/regtest/lightning-rpc")


description='[["text/plain","Funding @odell on stacker.news"],["text/identifier","odell@stacker.news"]]'
invoice = cln1.invoice(label="test12345", amount_msat=1_000, description=description, deschashonly=True)
print(cln1.decode(invoice["bolt11"]))
print(cln2.pay(bolt11=invoice["bolt11"], description=description))

@arcbtc
Copy link
Contributor

arcbtc commented Mar 13, 2023

They broke description_hash in 23. Soooo, yeah.

@daywalker90
Copy link
Contributor Author

tried the same thing with cln-plugin using String::from("[[\"text/plain\",\"Funding @odell on stacker.news\"],[\"text/identifier\",\"odell@stacker.news\"]]") same result as with pyln-client. The invoice gets generated with the correct hash but when paying to it, it fails.

@daywalker90
Copy link
Contributor Author

also, on the cli i could pay the invoice with description="[[\"text/plain\",\"Funding @odell on stacker.news\"],[\"text/identifier\",\"odell@stacker.news\"]]"

@evd0kim
Copy link
Contributor

evd0kim commented Jun 12, 2023

Looks like non-issue for v23.05.
Added option into cln4rust for LNURL-Pay.
laanwj/cln4rust#101.
It worked on the testnet.

I think issue may be closed @rustyrussell @cdecker.

@daywalker90
Copy link
Contributor Author

it might be an issue again if description is required even with allow-deprecated-apis=true (maybe in 23.08?). If this happens i would not know how pyln-client and cln-rpc would pay to lightning adresses.

@vincenzopalazzo vincenzopalazzo self-assigned this Jun 13, 2023
@vincenzopalazzo vincenzopalazzo added this to the v23.08 milestone Jun 13, 2023
@vincenzopalazzo vincenzopalazzo added in diagnostic issue under diagnostic discussion and removed in diagnostic issue under diagnostic labels Jun 13, 2023
@vincenzopalazzo
Copy link
Contributor

I agree that this should be closed, as mentioned by @evd0kim. The issue discussed here [1] is not a problem on the cln side. Additionally, the specification side is addressed in [2].

The only possible solution is to fix the protocol to use only hash description. Unfortunately, the proposal to drop the requirements did not receive enough support, as it received 3 NACKs. Therefore, it seems unlikely that this change will happen.

[1]: GitHub Issue: ElementsProject/lightning#6092
[2]: GitHub Pull Request: lightning/bolts#1064

@daywalker90
Copy link
Contributor Author

I'm so confused. Are plugins with pyln-client or cln-rpc supposed to be able to pay invoices with description_hash and description or not? Because if yes then this issue is about certain descriptions not working with pyln-client/cln-rpc while they do work directly on the cli.

@evd0kim
Copy link
Contributor

evd0kim commented Jun 13, 2023

Oh, sorry. I thought the problem is that i couldn't generate such invoices. May be it shouldn't be closed indeed.

@vincenzopalazzo
Copy link
Contributor

Mh sorry I was answering the following message

it might be an issue again if a description is required even with allow-deprecated-apis=true

Mh so there are more than a couple of things here, let's recap a little bit to answer your questions:

  • Pyln-client and all the others should work without problems because there is no extra logic; they are just making an RPC JSON 2.0 request;
  • If you are able to pay the same invoice from the command line, you should be able to pay also from a library;

You may be passing the wrong parameters to the pay argument, what are your commands to pass to lightning-cli
that worked?

@daywalker90
Copy link
Contributor Author

also, on the cli i could pay the invoice with description="[[\"text/plain\",\"Funding @odell on stacker.news\"],[\"text/identifier\",\"odell@stacker.news\"]]"

@daywalker90
Copy link
Contributor Author

  • Pyln-client and all the others should work without problems because there is no extra logic; they are just making an RPC JSON 2.0 request;
  • If you are able to pay the same invoice from the command line, you should be able to pay also from a library;

if you reread my 1. and 3. post you can see it doesn't work and i dare you to proof me wrong :)

@vincenzopalazzo
Copy link
Contributor

Yeah, this looks strange, I will look into it

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

Successfully merging a pull request may close this issue.

5 participants