Skip to content

Commit a2fe96d

Browse files
committed
work around rustc 1.34.1
1 parent bee401d commit a2fe96d

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,22 +1566,24 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15661566
// TODO this is not integration tested
15671567
let counterparty_initial_commitment_tx = counterparty_initial_commitment_info.build(self.counterparty_pubkeys.as_ref().unwrap(), self.holder_keys.pubkeys(), &self.funding_txo.unwrap().into_bitcoin_outpoint(), self.holder_selected_contest_delay, self.is_outbound(), &self.secp_ctx).unwrap().0;
15681568

1569-
let holder_keys = self.build_holder_transaction_keys(self.cur_holder_commitment_transaction_number)?;
1570-
let initial_commitment_info = self.build_commitment_transaction(self.cur_holder_commitment_transaction_number, &holder_keys, true, false, self.feerate_per_kw, logger);
1571-
let (sighash, initial_commitment_tx) = initial_commitment_info.0.get_sighash(self.holder_keys.pubkeys(), self.counterparty_pubkeys.as_ref().unwrap(), &self.funding_txo.unwrap().into_bitcoin_outpoint(), self.counterparty_selected_contest_delay, self.is_outbound(), &funding_script, self.channel_value_satoshis, &self.secp_ctx);
1569+
// TODO this works around rustc 1.34.1 borrow issue
1570+
let channel_monitor = {
1571+
let holder_keys = self.build_holder_transaction_keys(self.cur_holder_commitment_transaction_number)?;
1572+
let initial_commitment_info = self.build_commitment_transaction(self.cur_holder_commitment_transaction_number, &holder_keys, true, false, self.feerate_per_kw, logger);
1573+
let (sighash, initial_commitment_tx) = initial_commitment_info.0.get_sighash(self.holder_keys.pubkeys(), self.counterparty_pubkeys.as_ref().unwrap(), &self.funding_txo.unwrap().into_bitcoin_outpoint(), self.counterparty_selected_contest_delay, self.is_outbound(), &funding_script, self.channel_value_satoshis, &self.secp_ctx);
15721574

1573-
let counterparty_funding_pubkey = &self.counterparty_pubkeys.as_ref().unwrap().funding_pubkey;
1575+
let counterparty_funding_pubkey = &self.counterparty_pubkeys.as_ref().unwrap().funding_pubkey;
15741576

1575-
// They sign our commitment transaction, allowing us to broadcast the tx if we wish.
1576-
if let Err(_) = self.secp_ctx.verify(&sighash, &msg.signature, counterparty_funding_pubkey) {
1577-
return Err(ChannelError::Close("Invalid funding_signed signature from peer".to_owned()));
1578-
}
1577+
// They sign our commitment transaction, allowing us to broadcast the tx if we wish.
1578+
if let Err(_) = self.secp_ctx.verify(&sighash, &msg.signature, counterparty_funding_pubkey) {
1579+
return Err(ChannelError::Close("Invalid funding_signed signature from peer".to_owned()));
1580+
}
15791581

1580-
let counterparty_pubkeys = self.counterparty_pubkeys.as_ref().unwrap();
1581-
let funding_redeemscript = self.get_funding_redeemscript();
1582-
let funding_txo = self.funding_txo.as_ref().unwrap();
1583-
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
1584-
macro_rules! create_monitor {
1582+
let counterparty_pubkeys = self.counterparty_pubkeys.as_ref().unwrap();
1583+
let funding_redeemscript = self.get_funding_redeemscript();
1584+
let funding_txo = self.funding_txo.as_ref().unwrap();
1585+
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
1586+
macro_rules! create_monitor {
15851587
() => { {
15861588
let commitment_tx = HolderCommitmentTransaction::new_missing_holder_sig(initial_commitment_tx.clone(), msg.signature.clone(), &self.holder_keys.pubkeys().funding_pubkey, counterparty_funding_pubkey, holder_keys.clone(), self.feerate_per_kw, Vec::new());
15871589
let mut channel_monitor = ChannelMonitor::new(self.holder_keys.clone(),
@@ -1598,7 +1600,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15981600
} }
15991601
}
16001602

1601-
let channel_monitor = create_monitor!();
1603+
let channel_monitor = create_monitor!();
1604+
channel_monitor
1605+
};
16021606

16031607
assert_eq!(self.channel_state & (ChannelState::MonitorUpdateFailed as u32), 0); // We have no had any monitor(s) yet to fail update!
16041608
self.channel_state = ChannelState::FundingSent as u32;

0 commit comments

Comments
 (0)