Skip to content

Commit 4a1a645

Browse files
committed
Generate random PaymentId for outbound offers
Previously, we'd deterministically derive the `offer_hash` as a `PaymentId` for outbound BOLT 12 payments. However, as offers may be paid multiple times, this could result in collisions in our `outbound_payments` store. Here, we therefore use random `PaymentId`s to avoid collisions, even if offers are paid multiple times.
1 parent 78659f3 commit 4a1a645

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ pub(crate) fn poll_for_user_input(
175175
}
176176

177177
if let Ok(offer) = Offer::from_str(invoice_str.unwrap()) {
178-
let offer_hash = Sha256::hash(invoice_str.unwrap().as_bytes());
179-
let payment_id = PaymentId(*offer_hash.as_ref());
178+
let random_bytes = keys_manager.get_secure_random_bytes();
179+
let payment_id = PaymentId(random_bytes);
180180

181181
let amt_msat = match (offer.amount(), user_provided_amt) {
182182
(Some(offer::Amount::Bitcoin { amount_msats }), _) => *amount_msats,

0 commit comments

Comments
 (0)