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

Parsed amount is a non standard denomination #1

Open
leocape opened this issue Oct 11, 2023 · 3 comments
Open

Parsed amount is a non standard denomination #1

leocape opened this issue Oct 11, 2023 · 3 comments

Comments

@leocape
Copy link

leocape commented Oct 11, 2023

Hi

The parsed amount appears to be a non standard denomination.

As is:
For example, an invoice with amount SAT 50,000 parses to 500 (500 of what?).

To be:
The amount should be parsed to either Sats or Millisats (50,000 or 50,000,000), or ideally, both.

Example Invoice:
lntb500u1pjjdp9kpp5ujwdkw8d0cf8cy3hzs6yxzawat0uscg37ll5ret4w7era3009kasdqqcqzzsxqyz5vqsp5pdu05r2lcu0l7l5uw0jf9jfwy4qs8pjs8n78zz8zv8nrvtl9mj5q9qyyssqnc9r9n7xyh6dzg23hnvtnn7xd0qgtn8fy3spjdcqu64af87wj74ncfwhv8lrfhc2tngkaj2c743y0pevfcu0c9lxm2plj97my5kclgsqflgg34

@sashazykov
Copy link

@leocape Look at multiplier field. It represents denomination. In this case it is u, so you need to multiply it by 100_000 to get msats and then to divide it by 1_000 to get sats.

=> #<Lightning::Invoice::Message:0x0000558d9768bf30
 @amount=500,
 @description="",
 @expiry=86400,
 @min_final_cltv_expiry=80,
 @multiplier="u",
 @payment_hash="e49cdb38ed7e127c12371434430baeeadfc86111f7ff41e57577b23ec5ef2dbb",
 @prefix="lntb",
 @routing_info=[],
 @signature="9e0a32cfc625f4d12151bcd8b9cfc66bc085cce92460193700e6abd49fce97ab3c25d761fe34df0a5cd16ec958f56247872c4e38fc17e6da83f917db252d8fa200",
 @timestamp=1697023158>
[2] pry(main)> invoice.amount
=> 500
[3] pry(main)> invoice.multiplier
=> "u"
[4] pry(main)> invoice.amount * 100_000 / 1000
=> 50000```

@sashazykov
Copy link

https://docs.lightning.engineering/the-lightning-network/payment-lifecycle/understanding-lightning-invoices#amount

@leocape
Copy link
Author

leocape commented Sep 24, 2024

Thank you!

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

2 participants