Skip to content

Commit

Permalink
Merge pull request #132 from tnull/2024-03-avoid-offer-hash-collision
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Mar 9, 2024
2 parents 78659f3 + f58bb84 commit 16bc6f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ pub(crate) fn poll_for_user_input(
}

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

let amt_msat = match (offer.amount(), user_provided_amt) {
(Some(offer::Amount::Bitcoin { amount_msats }), _) => *amount_msats,
Expand Down Expand Up @@ -818,7 +818,7 @@ fn send_payment(
let (payment_hash, recipient_onion, route_params) = match pay_params_opt {
Ok(res) => res,
Err(e) => {
println!("Failed to parse invoice");
println!("Failed to parse invoice: {:?}", e);
print!("> ");
return;
}
Expand Down

0 comments on commit 16bc6f4

Please sign in to comment.