Commit 7b7968e
Bolt11 invoices: do not re-encode amounts (#771)
* Bolt11 invoices: do not re-encode amounts
Bolt11 amounts may not be minimally encoded (the specs says they SHOULD be but it's not a hard requirement).
We should preserve the original amount encoding: if it was not minimally encoded and we re-encode it using its
minimal representation (for example "5" instead of "5000m") then read() will fail to verify the invoice checksum and return an "invoice isn't canonically encoded" error.
---------
Co-authored-by: Pierre-Marie Padiou <[email protected]>1 parent cf17b62 commit 7b7968e
File tree
2 files changed
+23
-6
lines changed- modules/core/src
- commonMain/kotlin/fr/acinq/lightning/payment
- commonTest/kotlin/fr/acinq/lightning/payment
2 files changed
+23
-6
lines changedLines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
| |||
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | | - | |
| 71 | + | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
| |||
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
150 | | - | |
| 158 | + | |
151 | 159 | | |
152 | 160 | | |
153 | 161 | | |
| |||
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
168 | | - | |
| 176 | + | |
169 | 177 | | |
170 | 178 | | |
171 | 179 | | |
| |||
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
206 | | - | |
| 214 | + | |
207 | 215 | | |
208 | 216 | | |
209 | 217 | | |
| |||
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
543 | 553 | | |
544 | 554 | | |
545 | 555 | | |
| |||
576 | 586 | | |
577 | 587 | | |
578 | 588 | | |
579 | | - | |
580 | 589 | | |
0 commit comments