Skip to content

Commit def24fd

Browse files
committed
Drop debug_assert that would have us panic for replayed PaymentClaimeds
In cd8958f we changed the internal API behavior of `PaymentStore::update`. While previously it would return `Ok(true)` the to-be-updated entry was found in the store, it now returns `Ok(true)` if not only the entry was found but it was actually updated and re-persisted. This was an improvement as it allows us to avoid unnecessary re-persists if nothing changed. However, there were 1-2 places that implicitly relied on that behavior for logging purposes which we didn't correctly update to the new behavior. Unfortunately, one instance in handling `PaymentClaimed` events actually even `debug_assert`ed on the return value, which lead to some unnecessary panics in `debug` in case `PaymentClaimed` got replayed. Here we rectify this by dropping the `debug_assert`.
1 parent 9c02f23 commit def24fd

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/event.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,7 @@ where
886886
};
887887

888888
match self.payment_store.update(&update) {
889-
Ok(true) => (),
890-
Ok(false) => {
891-
log_error!(
892-
self.logger,
893-
"Payment with ID {} couldn't be found in store",
894-
payment_id,
895-
);
896-
debug_assert!(false);
897-
},
889+
Ok(_) => (),
898890
Err(e) => {
899891
log_error!(
900892
self.logger,

src/payment/bolt11.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,25 @@ impl Bolt11Payment {
408408
..PaymentDetailsUpdate::new(payment_id)
409409
};
410410

411-
if !self.payment_store.update(&update)? {
412-
log_error!(
413-
self.logger,
414-
"Failed to manually fail unknown payment with hash: {}",
415-
payment_hash
416-
);
417-
return Err(Error::InvalidPaymentHash);
411+
match self.payment_store.update(&update) {
412+
Ok(true) => (),
413+
Ok(false) => {
414+
log_error!(
415+
self.logger,
416+
"Failed to manually fail unknown payment with hash {}",
417+
payment_hash,
418+
);
419+
return Err(Error::InvalidPaymentHash);
420+
},
421+
Err(e) => {
422+
log_error!(
423+
self.logger,
424+
"Failed to manually fail unknown payment with hash {}: {}",
425+
payment_hash,
426+
e
427+
);
428+
return Err(e);
429+
},
418430
}
419431

420432
self.channel_manager.fail_htlc_backwards(&payment_hash);

0 commit comments

Comments
 (0)