Track inbound payments by PaymentId - #948
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
51dba72 to
ff3345d
Compare
ff3345d to
544e100
Compare
544e100 to
4c3f2e4
Compare
4c3f2e4 to
4a24ee7
Compare
4a24ee7 to
d1b5ffb
Compare
|
Rebased without further changes for now. |
d1b5ffb to
b1f6564
Compare
|
Force-pushed some fixes: > git diff-tree -U2 d1b5ffb3 b1f65649
diff --git a/bindings/python/src/ldk_node/test_ldk_node.py b/bindings/python/src/ldk_node/test_ldk_node.py
index 304caf9c..063c95f7 100644
--- a/bindings/python/src/ldk_node/test_ldk_node.py
+++ b/bindings/python/src/ldk_node/test_ldk_node.py
@@ -236,5 +236,5 @@ class TestLdkNode(unittest.TestCase):
sender_payment = node_1.payment(keysend_payment_id)
- receiver_payment = node_2.payment(keysend_payment_id)
+ receiver_payment = node_2.payment(received_event.payment_id)
self.assertIsNotNone(sender_payment)
diff --git a/tests/integration_tests_migration.rs b/tests/integration_tests_migration.rs
index c4e63451..59621476 100644
--- a/tests/integration_tests_migration.rs
+++ b/tests/integration_tests_migration.rs
@@ -204,5 +204,5 @@ async fn migrate_node_across_all_backends() {
let invoice = node_b.bolt11_payment().receive(10_000, &description.into(), 3600).unwrap();
let ln_send_id = node.bolt11_payment().send(&invoice, None).unwrap();
- expect_payment_successful_event!(node, Some(ln_send_id), None);
+ expect_payment_successful_event!(node, ln_send_id, None);
expect_payment_received_event!(node_b, 10_000);
@@ -212,5 +212,5 @@ async fn migrate_node_across_all_backends() {
let invoice = node.bolt11_payment().receive(5_000, &description.into(), 3600).unwrap();
let ln_receive_id = node_b.bolt11_payment().send(&invoice, None).unwrap();
- expect_payment_successful_event!(node_b, Some(ln_receive_id), None);
+ expect_payment_successful_event!(node_b, ln_receive_id, None);
expect_payment_received_event!(node, 5_000);
|
046355b to
452c643
Compare
|
Looking at this through the lens of self-imposed versus intrinsic complexity, I think this PR again makes the cost of our current architecture clear. LDK and ldk-node persist related state independently, without a consistent commit boundary, so we have to recover consistency through careful ordering, replay, cleanup, and expiry logic. |
tankyleo
left a comment
There was a problem hiding this comment.
A few nits feel free to squash will take a better pass tomorrow
The switch to tracking payments by ID happened with LDK Node v0.3.0, which is >1.5 years old by now. We can be pretty certain that nobody is upgrading from an older version to the upcoming v0.8. Here we hence make the `payment_id` fields in `Event` required which is a nice API simplification that will also be utilized in the next commit. Co-Authored-By: HAL 9000
452c643 to
f96d289
Compare
Gate manual claiming for unknown custom-hash BOLT11 payments behind a config flag. Nodes that do not opt in fail these payments back without storing or queueing user events. Co-Authored-By: HAL 9000
f96d289 to
748143c
Compare
| claim_deadline, | ||
| custom_records, | ||
| }; | ||
| match self.event_queue.add_event(event).await { |
There was a problem hiding this comment.
Also noted in the CHANGELOG.md, we could still reach this point with manually_claim_unknown_bolt11_payments = false if the user used the for_hash variants prior to upgrading past this commit.
| @@ -1145,11 +1364,23 @@ | |||
| // be the result of a replayed event. | |||
| ), | |||
| Ok(DataStoreUpdateResult::NotFound) => { | |||
There was a problem hiding this comment.
Is it a bug if we land here ? Or are we guarding against a possible crash before the persistence completes on PaymentClaimable ?
There was a problem hiding this comment.
Note we also expose Node::remove_payment so we could always hit a case where the user for one reason or another prunes payment entries from their payment store.
Use a name that reflects both possible user actions for unknown BOLT11 payments: either claim them with a preimage or fail them back. Co-Authored-By: HAL 9000
Create inbound BOLT11 records from claimable and claimed events so inbound payments can be tracked by the IDs emitted by LDK. Generate outbound BOLT11 IDs from KeysManager entropy instead of deriving them from the payment hash. Co-Authored-By: HAL 9000
Keep outbound BOLT11 payments keyed by payment hash so repeated attempts to pay the same invoice can still return DuplicatePayment. Co-Authored-By: HAL 9000
Clarify that v0.7-or-earlier for-hash invoices can still emit PaymentClaimable after upgrade regardless of the new config flag. Co-Authored-By: HAL 9000
Cover manually claiming and failing BOLT11 for-hash invoices that were created before upgrading, so the new ID-based APIs keep handling legacy payment-hash IDs. Co-Authored-By: HAL 9000
748143c to
97b27d4
Compare
Closes #298.
This finally switches our inbound payments over to be fully tracked by payment id, and decouples payment IDs from payment hashes.