Commit d79de9d
committed
event: expose BOLT12 invoice in PaymentSuccessful for proof of payment
This patch adds the `bolt12_invoice` field to the `PaymentSuccessful`
event, enabling users to obtain proof of payment for BOLT12 transactions.
Problem:
Previously, after a successful BOLT12 payment, users had no way to
access the paid invoice data. This made it impossible to provide
proof of payment to third parties, who need both the payment preimage
and the original invoice to verify that sha256(preimage) matches the
invoice's payment_hash.
Solution:
Add a `bolt12_invoice: Option<Vec<u8>>` field to `PaymentSuccessful`
that contains the serialized BOLT12 invoice bytes. The invoice is
serialized using LDK's standard encoding, which can be parsed back
using `Bolt12Invoice::try_from(bytes)` in native Rust, or by
hex-encoding the bytes and using `Bolt12Invoice.from_str()` in FFI
bindings.
Design decisions:
- Store as `Vec<u8>` rather than the complex `PaidBolt12Invoice` type
to avoid UniFFI limitations with objects in enum variants
- Return `None` for `StaticInvoice` (async payments) since proof of
payment is not possible for those payment types anyway
- Use TLV tag 7 for serialization, maintaining backward compatibility
with existing persisted events
This implementation follows the maintainer guidance from PR lightningdevkit#563 to
expose the invoice via the event rather than storing it in the
payment store.
Signed-off-by: Vincenzo Palazzo <[email protected]>1 parent bbefa73 commit d79de9d
File tree
3 files changed
+104
-2
lines changed- bindings
- src
- tests
3 files changed
+104
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| |||
264 | 277 | | |
265 | 278 | | |
266 | 279 | | |
| 280 | + | |
267 | 281 | | |
268 | 282 | | |
269 | 283 | | |
| |||
1022 | 1036 | | |
1023 | 1037 | | |
1024 | 1038 | | |
| 1039 | + | |
1025 | 1040 | | |
1026 | 1041 | | |
1027 | 1042 | | |
| |||
1062 | 1077 | | |
1063 | 1078 | | |
1064 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1065 | 1088 | | |
1066 | 1089 | | |
1067 | 1090 | | |
1068 | 1091 | | |
1069 | 1092 | | |
| 1093 | + | |
1070 | 1094 | | |
1071 | 1095 | | |
1072 | 1096 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
1303 | 1304 | | |
1304 | 1305 | | |
1305 | 1306 | | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
1306 | 1384 | | |
1307 | 1385 | | |
1308 | 1386 | | |
| |||
0 commit comments