Skip to content

Commit 16bc6f4

Browse files
authored
Merge pull request #132 from tnull/2024-03-avoid-offer-hash-collision
2 parents 78659f3 + f58bb84 commit 16bc6f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cli.rs

Lines changed: 3 additions & 3 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,
@@ -818,7 +818,7 @@ fn send_payment(
818818
let (payment_hash, recipient_onion, route_params) = match pay_params_opt {
819819
Ok(res) => res,
820820
Err(e) => {
821-
println!("Failed to parse invoice");
821+
println!("Failed to parse invoice: {:?}", e);
822822
print!("> ");
823823
return;
824824
}

0 commit comments

Comments
 (0)