]> git.bitcoin.ninja Git - rust-lightning/commit
Delay removal of fulfilled outbound payments for a few timer ticks
authorMatt Corallo <git@bluematt.me>
Sat, 8 Oct 2022 23:26:18 +0000 (23:26 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 2 Nov 2022 01:09:07 +0000 (01:09 +0000)
commit166e0c88e46565d5f65fac83fbb606bbb3414fc3
tree02e28ea21356f3ca554379b0057b9760f40317c5
parenta10223d1ff874c293622a433eb2b23568435330d
Delay removal of fulfilled outbound payments for a few timer ticks

Previously, once a fulfilled outbound payment completed and all
associated HTLCs were resolved, we'd immediately remove the payment
entry from the `pending_outbound_payments` map.

Now that we're using the `pending_outbound_payments` map for send
idempotency, this presents a race condition - if the user makes a
redundant `send_payment` call at the same time that the original
payment's last HTLC is resolved, the user would reasonably expect
the `send_payment` call to fail due to our idempotency guarantees.

However, because the `pending_outbound_payments` entry is being
removed, if it completes first the `send_payment` call will
succeed even though the user has not had a chance to see the
corresponding `Event::PaymentSent`.

Instead, here, we delay removal of `Fulfilled`
`pending_outbound_payments` entries until several timer ticks have
passed without any corresponding event or HTLC pending.
lightning/src/ln/channelmanager.rs
lightning/src/ln/payment_tests.rs