From: Matt Corallo Date: Sun, 3 May 2020 02:07:44 +0000 (-0400) Subject: f refactor out inline if into a local variable X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=df7adb672b1fa80662ad5901765500b0f2fe536c;p=rust-lightning f refactor out inline if into a local variable --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index be45952c3..d9327dd55 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -977,11 +977,14 @@ impl Channel { if value_to_b >= (dust_limit_satoshis as i64) { log_trace!(self, " ...including {} output with value {}", if local { "to_remote" } else { "to_local" }, value_to_b); + let static_payment_pk_hash = WPubkeyHash::hash(&if local { + self.their_pubkeys.as_ref().unwrap().payment_basepoint + } else { + self.local_keys.pubkeys().payment_basepoint + }.serialize()); txouts.push((TxOut { script_pubkey: Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0) - .push_slice(&WPubkeyHash::hash(&if local { - self.their_pubkeys.as_ref().unwrap().payment_basepoint - } else { self.local_keys.pubkeys().payment_basepoint }.serialize())[..]) + .push_slice(&static_payment_pk_hash[..]) .into_script(), value: value_to_b as u64 }, None));