Skip to content

Commit caf0b25

Browse files
committed
Document outbound payment amount invariant
Replace the success-path unwrap on payment amounts with an expect that explains why outbound payments must already have a recorded amount by the time LDK reports them as sent. Co-Authored-By: HAL 9000
1 parent f229b10 commit caf0b25

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/event.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,14 @@ where
10911091
};
10921092

10931093
self.payment_store.get(&payment_id).map(|payment| {
1094+
let amount_msat = payment.amount_msat.expect(
1095+
"outbound payments should record their amount before they can succeed",
1096+
);
10941097
log_info!(
10951098
self.logger,
10961099
"Successfully sent payment of {}msat{} from \
10971100
payment hash {:?} with preimage {:?}",
1098-
payment.amount_msat.expect("payment amount should be set"),
1101+
amount_msat,
10991102
if let Some(fee) = fee_paid_msat {
11001103
format!(" (fee {} msat)", fee)
11011104
} else {

0 commit comments

Comments
 (0)