Skip to content

Commit 08d566a

Browse files
committed
f Add debug assertions for payment hash overriding
1 parent 5055bf0 commit 08d566a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/payment/store.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,16 @@ where
344344
if let Some(payment) = locked_payments.get_mut(&update.id) {
345345
if let Some(hash_opt) = update.hash {
346346
match payment.kind {
347-
PaymentKind::Bolt12Offer { ref mut hash, .. } => *hash = hash_opt,
348-
PaymentKind::Bolt12Refund { ref mut hash, .. } => *hash = hash_opt,
347+
PaymentKind::Bolt12Offer { ref mut hash, .. } => {
348+
debug_assert_eq!(payment.direction, PaymentDirection::Outbound,
349+
"We should only ever override payment hash for outbound BOLT 12 payments");
350+
*hash = hash_opt
351+
},
352+
PaymentKind::Bolt12Refund { ref mut hash, .. } => {
353+
debug_assert_eq!(payment.direction, PaymentDirection::Outbound,
354+
"We should only ever override payment hash for outbound BOLT 12 payments");
355+
*hash = hash_opt
356+
},
349357
_ => {},
350358
}
351359
}
@@ -381,7 +389,6 @@ where
381389
self.persist_info(&update.id, payment)?;
382390
updated = true;
383391
}
384-
385392
Ok(updated)
386393
}
387394

0 commit comments

Comments
 (0)