Skip to content

Commit

Permalink
Merge pull request #211 from f3r10/use_from_paymentpreimage_when_cons…
Browse files Browse the repository at this point in the history
…tructing_payment_hash

refactor(simln-lib): use from<paymentpreimage> when constructing paym…
  • Loading branch information
carlaKC authored Feb 3, 2025
2 parents efb1fe0 + ed1e2a9 commit aef31ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion simln-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ expanduser = "1.2.2"
serde = { version="1.0.183", features=["derive"] }
serde_json = "1.0.104"
bitcoin = { version = "0.30.1", features=["serde"] }
lightning = { version = "0.0.121" }
lightning = { version = "0.0.123" }
tonic_lnd = { package="fedimint-tonic-lnd", version="0.1.2", features=["lightningrpc", "routerrpc"]}
tonic = { version = "0.8", features = ["tls", "transport"] }
async-trait = "0.1.73"
Expand Down
3 changes: 1 addition & 2 deletions simln-lib/src/sim_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
};
use async_trait::async_trait;
use bitcoin::constants::ChainHash;
use bitcoin::hashes::{sha256::Hash as Sha256, Hash};
use bitcoin::secp256k1::PublicKey;
use bitcoin::{Network, ScriptBuf, TxOut};
use lightning::ln::chan_utils::make_funding_redeemscript;
Expand Down Expand Up @@ -541,7 +540,7 @@ impl<T: SimNetwork> LightningNode for SimNode<'_, T> {
// our internal tracking state along with the chosen payment hash.
let (sender, receiver) = channel();
let preimage = PaymentPreimage(rand::random());
let payment_hash = PaymentHash(Sha256::hash(&preimage.0).to_byte_array());
let payment_hash = preimage.into();

// Check for payment hash collision, failing the payment if we happen to repeat one.
match self.in_flight.entry(payment_hash) {
Expand Down

0 comments on commit aef31ae

Please sign in to comment.