X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchan_utils.rs;h=81fa29f554113a5cb156205ab5be351ceb3290fb;hb=4fbe0c90b8d535e407bd8a3021a80ab0bf0dc06e;hp=dd5515c88046ac18b0686e7a810d5cfdeed65c3e;hpb=b94365f3f560b095350bd36d4eb9bf63268679b0;p=rust-lightning diff --git a/src/ln/chan_utils.rs b/src/ln/chan_utils.rs index dd5515c8..81fa29f5 100644 --- a/src/ln/chan_utils.rs +++ b/src/ln/chan_utils.rs @@ -7,9 +7,10 @@ use secp256k1::Secp256k1; use secp256k1; use crypto::digest::Digest; -use crypto::sha2::Sha256; use crypto::ripemd160::Ripemd160; +use util::sha2::Sha256; + // Various functions for key derivation and transaction creation for use within channels. Primarily // used in Channel and ChannelMonitor. @@ -156,7 +157,7 @@ pub struct HTLCOutputInCommitment { } #[inline] -pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a_htlc_key: &PublicKey, b_htlc_key: &PublicKey, revocation_key: &PublicKey, offered: bool) -> Script { +pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a_htlc_key: &PublicKey, b_htlc_key: &PublicKey, revocation_key: &PublicKey) -> Script { let payment_hash160 = { let mut ripemd = Ripemd160::new(); ripemd.input(&htlc.payment_hash); @@ -164,7 +165,7 @@ pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a ripemd.result(&mut res); res }; - if offered { + if htlc.offered { Builder::new().push_opcode(opcodes::All::OP_DUP) .push_opcode(opcodes::All::OP_HASH160) .push_slice(&Hash160::from_data(&revocation_key.serialize())[..]) @@ -229,6 +230,6 @@ pub fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommitment, a /// note here that 'a_revocation_key' is generated using b_revocation_basepoint and a's /// commitment secret. 'htlc' does *not* need to have its previous_output_index filled. #[inline] -pub fn get_htlc_redeemscript(htlc: &HTLCOutputInCommitment, keys: &TxCreationKeys, offered: bool) -> Script { - get_htlc_redeemscript_with_explicit_keys(htlc, &keys.a_htlc_key, &keys.b_htlc_key, &keys.revocation_key, offered) +pub fn get_htlc_redeemscript(htlc: &HTLCOutputInCommitment, keys: &TxCreationKeys) -> Script { + get_htlc_redeemscript_with_explicit_keys(htlc, &keys.a_htlc_key, &keys.b_htlc_key, &keys.revocation_key) }