]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f refactor out inline if into a local variable
authorMatt Corallo <git@bluematt.me>
Sun, 3 May 2020 02:07:44 +0000 (22:07 -0400)
committerMatt Corallo <git@bluematt.me>
Sun, 3 May 2020 02:07:44 +0000 (22:07 -0400)
lightning/src/ln/channel.rs

index be45952c35da1358cacc413373139e856e567c3f..d9327dd55f7eafa6d3cfab3d1283f3fedf632ed0 100644 (file)
@@ -977,11 +977,14 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
 
                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));