Skip to content

Commit 121426c

Browse files
committed
Remove ChannelContext::counterparty_funding_pubkey
The funding pubkeys will be moved to FundingScope in the next commits. And since there isn't a similar method for holder's funding_pubkey, it makes sense to remove this method.
1 parent 7fac8c3 commit 121426c

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

lightning/src/ln/channel.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,10 +1970,10 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
19701970
let sighash = initial_commitment_bitcoin_tx.get_sighash_all(&funding_script, self.funding().channel_value_satoshis);
19711971
// They sign the holder commitment transaction...
19721972
log_trace!(logger, "Checking {} tx signature {} by key {} against tx {} (sighash {}) with redeemscript {} for channel {}.",
1973-
self.received_msg(), log_bytes!(sig.serialize_compact()[..]), log_bytes!(self.context().counterparty_funding_pubkey().serialize()),
1973+
self.received_msg(), log_bytes!(sig.serialize_compact()[..]), log_bytes!(self.context().get_counterparty_pubkeys().funding_pubkey.serialize()),
19741974
encode::serialize_hex(&initial_commitment_bitcoin_tx.transaction), log_bytes!(sighash[..]),
19751975
encode::serialize_hex(&funding_script), &self.context().channel_id());
1976-
secp_check!(self.context().secp_ctx.verify_ecdsa(&sighash, sig, self.context().counterparty_funding_pubkey()), format!("Invalid {} signature from peer", self.received_msg()));
1976+
secp_check!(self.context().secp_ctx.verify_ecdsa(&sighash, sig, &self.context().get_counterparty_pubkeys().funding_pubkey), format!("Invalid {} signature from peer", self.received_msg()));
19771977

19781978
Ok(initial_commitment_tx)
19791979
}
@@ -2015,7 +2015,7 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
20152015
counterparty_signature,
20162016
Vec::new(),
20172017
&context.get_holder_pubkeys().funding_pubkey,
2018-
context.counterparty_funding_pubkey()
2018+
&context.get_counterparty_pubkeys().funding_pubkey,
20192019
);
20202020

20212021
if context.holder_signer.as_ref().validate_holder_commitment(&holder_commitment_tx, Vec::new()).is_err() {
@@ -3636,11 +3636,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
36363636
/// pays to get_funding_redeemscript().to_p2wsh()).
36373637
/// Panics if called before accept_channel/InboundV1Channel::new
36383638
pub fn get_funding_redeemscript(&self) -> ScriptBuf {
3639-
make_funding_redeemscript(&self.get_holder_pubkeys().funding_pubkey, self.counterparty_funding_pubkey())
3640-
}
3641-
3642-
fn counterparty_funding_pubkey(&self) -> &PublicKey {
3643-
&self.get_counterparty_pubkeys().funding_pubkey
3639+
make_funding_redeemscript(&self.get_holder_pubkeys().funding_pubkey, &self.get_counterparty_pubkeys().funding_pubkey)
36443640
}
36453641

36463642
pub fn get_feerate_sat_per_1000_weight(&self) -> u32 {
@@ -5466,9 +5462,9 @@ impl<SP: Deref> FundedChannel<SP> where
54665462

54675463
log_trace!(logger, "Checking commitment tx signature {} by key {} against tx {} (sighash {}) with redeemscript {} in channel {}",
54685464
log_bytes!(msg.signature.serialize_compact()[..]),
5469-
log_bytes!(self.context.counterparty_funding_pubkey().serialize()), encode::serialize_hex(&bitcoin_tx.transaction),
5465+
log_bytes!(self.context.get_counterparty_pubkeys().funding_pubkey.serialize()), encode::serialize_hex(&bitcoin_tx.transaction),
54705466
log_bytes!(sighash[..]), encode::serialize_hex(&funding_script), &self.context.channel_id());
5471-
if let Err(_) = self.context.secp_ctx.verify_ecdsa(&sighash, &msg.signature, &self.context.counterparty_funding_pubkey()) {
5467+
if let Err(_) = self.context.secp_ctx.verify_ecdsa(&sighash, &msg.signature, &self.context.get_counterparty_pubkeys().funding_pubkey) {
54725468
return Err(ChannelError::close("Invalid commitment tx signature from peer".to_owned()));
54735469
}
54745470
bitcoin_tx.txid
@@ -5560,7 +5556,7 @@ impl<SP: Deref> FundedChannel<SP> where
55605556
msg.signature,
55615557
msg.htlc_signatures.clone(),
55625558
&self.context.get_holder_pubkeys().funding_pubkey,
5563-
self.context.counterparty_funding_pubkey()
5559+
&self.context.get_counterparty_pubkeys().funding_pubkey,
55645560
);
55655561

55665562
self.context.holder_signer.as_ref().validate_holder_commitment(&holder_commitment_tx, commitment_stats.outbound_htlc_preimages)
@@ -7164,7 +7160,7 @@ impl<SP: Deref> FundedChannel<SP> where
71647160
tx.input[0].witness.push(Vec::new()); // First is the multisig dummy
71657161

71667162
let funding_key = self.context.get_holder_pubkeys().funding_pubkey.serialize();
7167-
let counterparty_funding_key = self.context.counterparty_funding_pubkey().serialize();
7163+
let counterparty_funding_key = self.context.get_counterparty_pubkeys().funding_pubkey.serialize();
71687164
let mut holder_sig = sig.serialize_der().to_vec();
71697165
holder_sig.push(EcdsaSighashType::All as u8);
71707166
let mut cp_sig = counterparty_sig.serialize_der().to_vec();
@@ -7277,7 +7273,7 @@ impl<SP: Deref> FundedChannel<SP> where
72777273
skip_remote_output = true;
72787274
closing_tx = self.build_closing_transaction(msg.fee_satoshis, skip_remote_output)?.0;
72797275
let sighash = closing_tx.trust().get_sighash_all(&funding_redeemscript, self.funding.channel_value_satoshis);
7280-
secp_check!(self.context.secp_ctx.verify_ecdsa(&sighash, &msg.signature, self.context.counterparty_funding_pubkey()), "Invalid closing tx signature from peer".to_owned());
7276+
secp_check!(self.context.secp_ctx.verify_ecdsa(&sighash, &msg.signature, &self.context.get_counterparty_pubkeys().funding_pubkey), "Invalid closing tx signature from peer".to_owned());
72817277
},
72827278
};
72837279

@@ -8024,8 +8020,8 @@ impl<SP: Deref> FundedChannel<SP> where
80248020
short_channel_id,
80258021
node_id_1: if were_node_one { node_id } else { counterparty_node_id },
80268022
node_id_2: if were_node_one { counterparty_node_id } else { node_id },
8027-
bitcoin_key_1: NodeId::from_pubkey(if were_node_one { &self.context.get_holder_pubkeys().funding_pubkey } else { self.context.counterparty_funding_pubkey() }),
8028-
bitcoin_key_2: NodeId::from_pubkey(if were_node_one { self.context.counterparty_funding_pubkey() } else { &self.context.get_holder_pubkeys().funding_pubkey }),
8023+
bitcoin_key_1: NodeId::from_pubkey(if were_node_one { &self.context.get_holder_pubkeys().funding_pubkey } else { &self.context.get_counterparty_pubkeys().funding_pubkey }),
8024+
bitcoin_key_2: NodeId::from_pubkey(if were_node_one { &self.context.get_counterparty_pubkeys().funding_pubkey } else { &self.context.get_holder_pubkeys().funding_pubkey }),
80298025
excess_data: Vec::new(),
80308026
};
80318027

@@ -8150,10 +8146,10 @@ impl<SP: Deref> FundedChannel<SP> where
81508146
"Bad announcement_signatures. Failed to verify node_signature. UnsignedChannelAnnouncement used for verification is {:?}. their_node_key is {:?}",
81518147
&announcement, self.context.get_counterparty_node_id())));
81528148
}
8153-
if self.context.secp_ctx.verify_ecdsa(&msghash, &msg.bitcoin_signature, self.context.counterparty_funding_pubkey()).is_err() {
8149+
if self.context.secp_ctx.verify_ecdsa(&msghash, &msg.bitcoin_signature, &self.context.get_counterparty_pubkeys().funding_pubkey).is_err() {
81548150
return Err(ChannelError::close(format!(
81558151
"Bad announcement_signatures. Failed to verify bitcoin_signature. UnsignedChannelAnnouncement used for verification is {:?}. their_bitcoin_key is ({:?})",
8156-
&announcement, self.context.counterparty_funding_pubkey())));
8152+
&announcement, &self.context.get_counterparty_pubkeys().funding_pubkey)));
81578153
}
81588154

81598155
self.context.announcement_sigs = Some((msg.node_signature, msg.bitcoin_signature));
@@ -11414,7 +11410,7 @@ mod tests {
1141411410
let counterparty_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_sig_hex).unwrap()[..]).unwrap();
1141511411
let sighash = unsigned_tx.get_sighash_all(&redeemscript, chan.funding.channel_value_satoshis);
1141611412
log_trace!(logger, "unsigned_tx = {}", serialize(&unsigned_tx.transaction).as_hex());
11417-
assert!(secp_ctx.verify_ecdsa(&sighash, &counterparty_signature, chan.context.counterparty_funding_pubkey()).is_ok(), "verify counterparty commitment sig");
11413+
assert!(secp_ctx.verify_ecdsa(&sighash, &counterparty_signature, &chan.context.get_counterparty_pubkeys().funding_pubkey).is_ok(), "verify counterparty commitment sig");
1141811414

1141911415
let mut per_htlc: Vec<(HTLCOutputInCommitment, Option<Signature>)> = Vec::new();
1142011416
per_htlc.clear(); // Don't warn about excess mut for no-HTLC calls
@@ -11432,7 +11428,7 @@ mod tests {
1143211428
counterparty_signature,
1143311429
counterparty_htlc_sigs,
1143411430
&chan.context.holder_signer.as_ref().pubkeys().funding_pubkey,
11435-
chan.context.counterparty_funding_pubkey()
11431+
&chan.context.get_counterparty_pubkeys().funding_pubkey,
1143611432
);
1143711433
let holder_sig = signer.sign_holder_commitment(&holder_commitment_tx, &secp_ctx).unwrap();
1143811434
assert_eq!(Signature::from_der(&<Vec<u8>>::from_hex($sig_hex).unwrap()[..]).unwrap(), holder_sig, "holder_sig");

0 commit comments

Comments
 (0)