Skip to content

Commit 78c1b4a

Browse files
committed
Rename commitment transaction related classes
- ChannelStaticInfo -> ChannelTransactionParameters - HolderCommitmentTransaction -> HolderCommitmentTransactionForSigning (to be removed later) - CommitmentTransactionInfo -> CommitmentTransaction - HolderCommitmentTransactionInfo -> HolderCommitmentTransaction
1 parent 66949ce commit 78c1b4a

File tree

6 files changed

+157
-157
lines changed

6 files changed

+157
-157
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use bitcoin::secp256k1;
3939

4040
use ln::msgs::DecodeError;
4141
use ln::chan_utils;
42-
use ln::chan_utils::{CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLCType, ChannelStaticInfo, HolderCommitmentTransactionInfo};
42+
use ln::chan_utils::{CounterpartyCommitmentSecrets, HTLCOutputInCommitment, HTLCType, ChannelTransactionParameters, HolderCommitmentTransaction};
4343
use ln::channelmanager::{HTLCSource, PaymentPreimage, PaymentHash};
4444
use ln::onchaintx::{OnchainTxHandler, InputDescriptors};
4545
use chain::chaininterface::{BroadcasterInterface, FeeEstimator};
@@ -474,7 +474,7 @@ const MIN_SERIALIZATION_VERSION: u8 = 1;
474474
#[derive(Clone)]
475475
pub(crate) enum ChannelMonitorUpdateStep {
476476
LatestHolderCommitmentTXInfo {
477-
commitment_info: HolderCommitmentTransactionInfo,
477+
commitment_info: HolderCommitmentTransaction,
478478
htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>,
479479
},
480480
LatestCounterpartyCommitmentTXInfo {
@@ -936,27 +936,27 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
936936
impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
937937
pub(crate) fn new(keys: ChanSigner, shutdown_pubkey: &PublicKey,
938938
on_counterparty_tx_csv: u16, destination_script: &Script, funding_info: (OutPoint, Script),
939-
channel_static_info: &ChannelStaticInfo,
939+
channel_parameters: &ChannelTransactionParameters,
940940
funding_redeemscript: Script, channel_value_satoshis: u64,
941941
commitment_transaction_number_obscure_factor: u64,
942-
initial_holder_commitment_info: HolderCommitmentTransactionInfo) -> ChannelMonitor<ChanSigner> {
942+
initial_holder_commitment_info: HolderCommitmentTransaction) -> ChannelMonitor<ChanSigner> {
943943

944944
assert!(commitment_transaction_number_obscure_factor <= (1 << 48));
945945
let our_channel_close_key_hash = WPubkeyHash::hash(&shutdown_pubkey.serialize());
946946
let shutdown_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_close_key_hash[..]).into_script();
947947
let payment_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_point.serialize());
948948
let counterparty_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_key_hash[..]).into_script();
949949

950-
let counterparty_delayed_payment_base_key = channel_static_info.counterparty_pubkeys.delayed_payment_basepoint;
951-
let counterparty_htlc_base_key = channel_static_info.counterparty_pubkeys.htlc_basepoint;
950+
let counterparty_delayed_payment_base_key = channel_parameters.counterparty_pubkeys.delayed_payment_basepoint;
951+
let counterparty_htlc_base_key = channel_parameters.counterparty_pubkeys.htlc_basepoint;
952952
let counterparty_tx_cache = CounterpartyCommitmentTransaction { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv, per_htlc: HashMap::new() };
953953

954-
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), channel_static_info.clone());
954+
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), channel_parameters.clone());
955955

956956
let secp_ctx = Secp256k1::new();
957957

958-
let directed_channel_static_info = channel_static_info.to_directed(true);
959-
let txid = initial_holder_commitment_info.txid(&directed_channel_static_info, &secp_ctx);
958+
let directed_channel_parameters = channel_parameters.to_directed(true);
959+
let txid = initial_holder_commitment_info.txid(&directed_channel_parameters, &secp_ctx);
960960

961961
// block for Rust 1.34 compat
962962
let (holder_commitment_tx, current_holder_commitment_number) = {
@@ -983,7 +983,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
983983
ChannelMonitor {
984984
latest_update_id: 0,
985985
commitment_transaction_number_obscure_factor,
986-
is_outbound: channel_static_info.is_outbound_from_holder,
986+
is_outbound: channel_parameters.is_outbound_from_holder,
987987

988988
destination_script: destination_script.clone(),
989989
broadcasted_holder_revokable_script: None,
@@ -1000,7 +1000,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
10001000
channel_value_satoshis,
10011001
their_cur_revocation_points: None,
10021002

1003-
on_holder_tx_csv: channel_static_info.counterparty_selected_contest_delay,
1003+
on_holder_tx_csv: channel_parameters.counterparty_selected_contest_delay,
10041004

10051005
commitment_secrets: CounterpartyCommitmentSecrets::new(),
10061006
counterparty_claimable_outpoints: HashMap::new(),
@@ -1133,8 +1133,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
11331133
/// is important that any clones of this channel monitor (including remote clones) by kept
11341134
/// up-to-date as our holder commitment transaction is updated.
11351135
/// Panics if set_on_holder_tx_csv has never been called.
1136-
fn provide_latest_holder_commitment_tx_info(&mut self, commitment_info: HolderCommitmentTransactionInfo, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>) -> Result<(), MonitorUpdateError> {
1137-
let txid = commitment_info.txid(&self.onchain_tx_handler.channel_static_info.to_directed(true), &self.secp_ctx);
1136+
fn provide_latest_holder_commitment_tx_info(&mut self, commitment_info: HolderCommitmentTransaction, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>) -> Result<(), MonitorUpdateError> {
1137+
let txid = commitment_info.txid(&self.onchain_tx_handler.channel_transaction_parameters.to_directed(true), &self.secp_ctx);
11381138

11391139
// block for Rust 1.34 compat
11401140
let mut new_holder_commitment_tx = {
@@ -2506,7 +2506,7 @@ mod tests {
25062506
use ln::channelmanager::{PaymentPreimage, PaymentHash};
25072507
use ln::onchaintx::{OnchainTxHandler, InputDescriptors};
25082508
use ln::chan_utils;
2509-
use ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, ChannelStaticInfo, HolderCommitmentTransactionInfo};
2509+
use ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, ChannelTransactionParameters, HolderCommitmentTransaction};
25102510
use util::test_utils::TestLogger;
25112511
use bitcoin::secp256k1::key::{SecretKey,PublicKey};
25122512
use bitcoin::secp256k1::Secp256k1;
@@ -2584,7 +2584,7 @@ mod tests {
25842584
delayed_payment_basepoint: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[47; 32]).unwrap()),
25852585
htlc_basepoint: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[48; 32]).unwrap())
25862586
};
2587-
let channel_static_info = ChannelStaticInfo {
2587+
let channel_parameters = ChannelTransactionParameters {
25882588
holder_pubkeys: keys.holder_channel_pubkeys.clone(),
25892589
counterparty_pubkeys,
25902590
holder_selected_contest_delay: 66,
@@ -2595,13 +2595,13 @@ mod tests {
25952595
// Prune with one old state and a holder commitment tx holding a few overlaps with the
25962596
// old state.
25972597
let mut monitor = ChannelMonitor::new(keys,
2598-
&PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()), 0, &Script::new(),
2599-
(OutPoint { txid: Txid::from_slice(&[43; 32]).unwrap(), index: 0 }, Script::new()),
2600-
&channel_static_info,
2601-
Script::new(), 46, 0,
2602-
HolderCommitmentTransactionInfo::dummy());
2598+
&PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()), 0, &Script::new(),
2599+
(OutPoint { txid: Txid::from_slice(&[43; 32]).unwrap(), index: 0 }, Script::new()),
2600+
&channel_parameters,
2601+
Script::new(), 46, 0,
2602+
HolderCommitmentTransaction::dummy());
26032603

2604-
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransactionInfo::dummy(), preimages_to_holder_htlcs!(preimages[0..10])).unwrap();
2604+
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransaction::dummy(), preimages_to_holder_htlcs!(preimages[0..10])).unwrap();
26052605
monitor.provide_latest_counterparty_commitment_tx_info(&dummy_tx, preimages_slice_to_htlc_outputs!(preimages[5..15]), 281474976710655, dummy_key, &logger);
26062606
monitor.provide_latest_counterparty_commitment_tx_info(&dummy_tx, preimages_slice_to_htlc_outputs!(preimages[15..20]), 281474976710654, dummy_key, &logger);
26072607
monitor.provide_latest_counterparty_commitment_tx_info(&dummy_tx, preimages_slice_to_htlc_outputs!(preimages[17..20]), 281474976710653, dummy_key, &logger);
@@ -2627,15 +2627,15 @@ mod tests {
26272627

26282628
// Now update holder commitment tx info, pruning only element 18 as we still care about the
26292629
// previous commitment tx's preimages too
2630-
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransactionInfo::dummy(), preimages_to_holder_htlcs!(preimages[0..5])).unwrap();
2630+
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransaction::dummy(), preimages_to_holder_htlcs!(preimages[0..5])).unwrap();
26312631
secret[0..32].clone_from_slice(&hex::decode("2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8").unwrap());
26322632
monitor.provide_secret(281474976710653, secret.clone()).unwrap();
26332633
assert_eq!(monitor.payment_preimages.len(), 12);
26342634
test_preimages_exist!(&preimages[0..10], monitor);
26352635
test_preimages_exist!(&preimages[18..20], monitor);
26362636

26372637
// But if we do it again, we'll prune 5-10
2638-
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransactionInfo::dummy(), preimages_to_holder_htlcs!(preimages[0..3])).unwrap();
2638+
monitor.provide_latest_holder_commitment_tx_info(HolderCommitmentTransaction::dummy(), preimages_to_holder_htlcs!(preimages[0..3])).unwrap();
26392639
secret[0..32].clone_from_slice(&hex::decode("27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116").unwrap());
26402640
monitor.provide_secret(281474976710652, secret.clone()).unwrap();
26412641
assert_eq!(monitor.payment_preimages.len(), 5);

lightning/src/chain/keysinterface.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use util::ser::{Writeable, Writer, Readable};
3333

3434
use chain::transaction::OutPoint;
3535
use ln::chan_utils;
36-
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript, ChannelPublicKeys, HolderCommitmentTransaction, PreCalculatedTxCreationKeys};
36+
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript, ChannelPublicKeys, HolderCommitmentTransactionForSigning, PreCalculatedTxCreationKeys};
3737
use ln::msgs::UnsignedChannelAnnouncement;
3838

3939
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -242,14 +242,14 @@ pub trait ChannelKeys : Send+Clone {
242242
//
243243
// TODO: Document the things someone using this interface should enforce before signing.
244244
// TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
245-
fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
245+
fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
246246

247247
/// Same as sign_holder_commitment, but exists only for tests to get access to holder commitment
248248
/// transactions which will be broadcasted later, after the channel has moved on to a newer
249249
/// state. Thus, needs its own method as sign_holder_commitment may enforce that we only ever
250250
/// get called once.
251251
#[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
252-
fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
252+
fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
253253

254254
/// Create a signature for each HTLC transaction spending a holder's commitment transaction.
255255
///
@@ -264,7 +264,7 @@ pub trait ChannelKeys : Send+Clone {
264264
/// (implying they were considered dust at the time the commitment transaction was negotiated),
265265
/// a corresponding None should be included in the return value. All other positions in the
266266
/// return value must contain a signature.
267-
fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()>;
267+
fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()>;
268268

269269
/// Create a signature for the given input in a transaction spending an HTLC or commitment
270270
/// transaction output when our counterparty broadcasts an old state.
@@ -499,7 +499,7 @@ impl ChannelKeys for InMemoryChannelKeys {
499499
Ok((commitment_sig, htlc_sigs))
500500
}
501501

502-
fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
502+
fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
503503
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
504504
let counterparty_channel_data = self.accepted_channel_data.as_ref().expect("must accept before signing");
505505
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &counterparty_channel_data.counterparty_channel_pubkeys.funding_pubkey);
@@ -508,15 +508,15 @@ impl ChannelKeys for InMemoryChannelKeys {
508508
}
509509

510510
#[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
511-
fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
511+
fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
512512
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
513513
let counterparty_channel_pubkeys = &self.accepted_channel_data.as_ref().expect("must accept before signing").counterparty_channel_pubkeys;
514514
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &counterparty_channel_pubkeys.funding_pubkey);
515515

516516
Ok(holder_commitment_tx.get_holder_sig(&self.funding_key, &channel_funding_redeemscript, self.channel_value_satoshis, secp_ctx))
517517
}
518518

519-
fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
519+
fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &HolderCommitmentTransactionForSigning, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
520520
let counterparty_selected_contest_delay = self.accepted_channel_data.as_ref().unwrap().counterparty_selected_contest_delay;
521521
holder_commitment_tx.get_htlc_sigs(&self.htlc_base_key, counterparty_selected_contest_delay, secp_ctx)
522522
}

0 commit comments

Comments
 (0)