Cleanup locally-selected-delay
authorAntoine Riard <ariard@student.42.fr>
Mon, 7 Sep 2020 00:16:42 +0000 (20:16 -0400)
committerAntoine Riard <ariard@student.42.fr>
Mon, 14 Sep 2020 19:19:06 +0000 (15:19 -0400)
Comment meaning of holder/counterparty

Diverse chan_utils cleanups

Cleanups post-cbindings merge

Fix misusage of holder_selected_contest_delay instead of counterparty
_selected_contest_delay in HolderCommitmentTransaction

Fix old payment_point comment

lightning-c-bindings/src/chain/keysinterface.rs
lightning-c-bindings/src/ln/chan_utils.rs
lightning/src/chain/keysinterface.rs
lightning/src/ln/chan_utils.rs
lightning/src/ln/channel.rs
lightning/src/util/enforcing_trait_impls.rs

index 53a951e8005cf8d4e055ed20c2ac14e22dd4e8f5..c68c219c24e794f62516926879923ca1231ef47f 100644 (file)
@@ -37,14 +37,14 @@ pub enum SpendableOutputDescriptor {
        /// it is an output from an old state which we broadcast (which should never happen).
        ///
        /// To derive the delayed_payment key which is used to sign for this input, you must pass the
-       /// local delayed_payment_base_key (ie the private key which corresponds to the pubkey in
+       /// holder delayed_payment_base_key (ie the private key which corresponds to the pubkey in
        /// ChannelKeys::pubkeys().delayed_payment_basepoint) and the provided per_commitment_point to
        /// chan_utils::derive_private_key. The public key can be generated without the secret key
        /// using chan_utils::derive_public_key and only the delayed_payment_basepoint which appears in
        /// ChannelKeys::pubkeys().
        ///
        /// To derive the revocation_pubkey provided here (which is used in the witness
-       /// script generation), you must pass the remote revocation_basepoint (which appears in the
+       /// script generation), you must pass the revocation_basepoint (which appears in the
        /// call to ChannelKeys::on_accept) and the provided per_commitment point
        /// to chan_utils::derive_public_revocation_key.
        ///
@@ -351,7 +351,7 @@ pub struct ChannelKeys {
        /// protocol.
        #[must_use]
        pub sign_channel_announcement: extern "C" fn (this_arg: *const c_void, msg: &crate::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_SignatureNoneZ,
-       /// Set the remote channel basepoints and remote/local to_self_delay.
+       /// Set the counterparty channel basepoints and counterparty/local to_self_delay.
        /// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
        ///
        /// We bind local_to_self_delay late here for API convenience.
@@ -613,13 +613,13 @@ pub extern "C" fn InMemoryChannelKeys_get_revocation_base_key(this_ptr: &InMemor
 pub extern "C" fn InMemoryChannelKeys_set_revocation_base_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
        unsafe { &mut *this_ptr.inner }.revocation_base_key = val.into_rust();
 }
-/// Local secret key used for our balance in remote-broadcasted commitment transactions
+/// Local secret key used for our balance in counterparty-broadcasted commitment transactions
 #[no_mangle]
 pub extern "C" fn InMemoryChannelKeys_get_payment_key(this_ptr: &InMemoryChannelKeys) -> *const [u8; 32] {
        let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_key;
        (*inner_val).as_ref()
 }
-/// Local secret key used for our balance in remote-broadcasted commitment transactions
+/// Local secret key used for our balance in counterparty-broadcasted commitment transactions
 #[no_mangle]
 pub extern "C" fn InMemoryChannelKeys_set_payment_key(this_ptr: &mut InMemoryChannelKeys, mut val: crate::c_types::SecretKey) {
        unsafe { &mut *this_ptr.inner }.payment_key = val.into_rust();
@@ -693,8 +693,8 @@ pub extern "C" fn InMemoryChannelKeys_counterparty_selected_contest_delay(this_a
 /// Will panic if on_accept wasn't called.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn InMemoryChannelKeys_locally_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 {
-       let mut ret = unsafe { &*this_arg.inner }.locally_selected_contest_delay();
+pub extern "C" fn InMemoryChannelKeys_holder_selected_contest_delay(this_arg: &InMemoryChannelKeys) -> u16 {
+       let mut ret = unsafe { &*this_arg.inner }.holder_selected_contest_delay();
        ret
 }
 
@@ -793,8 +793,8 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_channel_announcement(this_arg
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
 }
-extern "C" fn InMemoryChannelKeys_ChannelKeys_on_accept(this_arg: *mut c_void, channel_pubkeys: &crate::ln::chan_utils::ChannelPublicKeys, mut remote_to_self_delay: u16, mut local_to_self_delay: u16) {
-       unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.on_accept(unsafe { &*channel_pubkeys.inner }, remote_to_self_delay, local_to_self_delay)
+extern "C" fn InMemoryChannelKeys_ChannelKeys_on_accept(this_arg: *mut c_void, channel_pubkeys: &crate::ln::chan_utils::ChannelPublicKeys, mut counterparty_selected_contest_delay: u16, mut holder_selected_contest_delay: u16) {
+       unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.on_accept(unsafe { &*channel_pubkeys.inner }, counterparty_selected_contest_delay, holder_selected_contest_delay)
 }
 
 #[no_mangle]
index 642353f09e207d2563b42abe6ce18dbda33210ff..d4f551b23175eddc0b64e7b515b3f4a80c254c30 100644 (file)
@@ -347,7 +347,7 @@ pub extern "C" fn ChannelPublicKeys_set_revocation_basepoint(this_ptr: &mut Chan
        unsafe { &mut *this_ptr.inner }.revocation_basepoint = val.into_rust();
 }
 /// The public key which receives our immediately spendable primary channel balance in
-/// remote-broadcasted commitment transactions. This key is static across every commitment
+/// counterparty-broadcasted commitment transactions. This key is static across every commitment
 /// transaction.
 #[no_mangle]
 pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKeys) -> crate::c_types::PublicKey {
@@ -355,7 +355,7 @@ pub extern "C" fn ChannelPublicKeys_get_payment_point(this_ptr: &ChannelPublicKe
        crate::c_types::PublicKey::from_rust(&(*inner_val))
 }
 /// The public key which receives our immediately spendable primary channel balance in
-/// remote-broadcasted commitment transactions. This key is static across every commitment
+/// counterparty-broadcasted commitment transactions. This key is static across every commitment
 /// transaction.
 #[no_mangle]
 pub extern "C" fn ChannelPublicKeys_set_payment_point(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) {
@@ -484,7 +484,7 @@ pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_vo
 /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
 /// Note that this is not the same as whether it is ountbound *from us*. To determine that you
 /// need to compare this value to whether the commitment transaction in question is that of
-/// the remote party or our own.
+/// the counterparty or our own.
 #[no_mangle]
 pub extern "C" fn HTLCOutputInCommitment_get_offered(this_ptr: &HTLCOutputInCommitment) -> bool {
        let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.offered;
@@ -493,7 +493,7 @@ pub extern "C" fn HTLCOutputInCommitment_get_offered(this_ptr: &HTLCOutputInComm
 /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
 /// Note that this is not the same as whether it is ountbound *from us*. To determine that you
 /// need to compare this value to whether the commitment transaction in question is that of
-/// the remote party or our own.
+/// the counterparty or our own.
 #[no_mangle]
 pub extern "C" fn HTLCOutputInCommitment_set_offered(this_ptr: &mut HTLCOutputInCommitment, mut val: bool) {
        unsafe { &mut *this_ptr.inner }.offered = val;
@@ -573,7 +573,7 @@ pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate
 use lightning::ln::chan_utils::HolderCommitmentTransaction as nativeHolderCommitmentTransactionImport;
 type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport;
 
-/// We use this to track local commitment transactions and put off signing them until we are ready
+/// We use this to track holder commitment transactions and put off signing them until we are ready
 /// to broadcast. This class can be used inside a signer implementation to generate a signature
 /// given the relevant secret key.
 #[must_use]
@@ -658,13 +658,13 @@ pub extern "C" fn HolderCommitmentTransaction_get_feerate_per_kw(this_ptr: &Hold
 pub extern "C" fn HolderCommitmentTransaction_set_feerate_per_kw(this_ptr: &mut HolderCommitmentTransaction, mut val: u32) {
        unsafe { &mut *this_ptr.inner }.feerate_per_kw = val;
 }
-/// The HTLCs and remote htlc signatures which were included in this commitment transaction.
+/// The HTLCs and counterparty htlc signatures which were included in this commitment transaction.
 ///
 /// Note that this includes all HTLCs, including ones which were considered dust and not
 /// actually included in the transaction as it appears on-chain, but who's value is burned as
 /// fees and not included in the to_local or to_remote outputs.
 ///
-/// The remote HTLC signatures in the second element will always be set for non-dust HTLCs, ie
+/// The counterparty HTLC signatures in the second element will always be set for non-dust HTLCs, ie
 /// those for which transaction_output_index.is_some().
 #[no_mangle]
 pub extern "C" fn HolderCommitmentTransaction_set_per_htlc(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) {
@@ -672,15 +672,15 @@ pub extern "C" fn HolderCommitmentTransaction_set_per_htlc(this_ptr: &mut Holder
        unsafe { &mut *this_ptr.inner }.per_htlc = local_val;
 }
 /// Generate a new HolderCommitmentTransaction based on a raw commitment transaction,
-/// remote signature and both parties keys.
+/// counterparty signature and both parties keys.
 ///
 /// The unsigned transaction outputs must be consistent with htlc_data.  This function
 /// only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::derived::CVec_u8Z, mut counterparty_sig: crate::c_types::Signature, our_funding_key: crate::c_types::PublicKey, their_funding_key: crate::c_types::PublicKey, mut local_keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::HolderCommitmentTransaction {
-       let mut local_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { local_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut local_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut local_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, local_orig_htlc_data_0_1); local_htlc_data_0 }); };
-       let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), counterparty_sig.into_rust(), &our_funding_key.into_rust(), &their_funding_key.into_rust(), *unsafe { Box::from_raw(local_keys.take_ptr()) }, feerate_per_kw, local_htlc_data);
+pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::derived::CVec_u8Z, mut counterparty_sig: crate::c_types::Signature, holder_funding_key: crate::c_types::PublicKey, counterparty_funding_key: crate::c_types::PublicKey, mut keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::HolderCommitmentTransaction {
+       let mut holder_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { holder_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut holder_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut holder_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, holder_orig_htlc_data_0_1); holder_htlc_data_0 }); };
+       let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), counterparty_sig.into_rust(), &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust(), *unsafe { Box::from_raw(keys.take_ptr()) }, feerate_per_kw, holder_htlc_data);
        crate::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
@@ -693,7 +693,7 @@ pub extern "C" fn HolderCommitmentTransaction_trust_key_derivation(this_arg: &Ho
        crate::ln::chan_utils::TxCreationKeys { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
 }
 
-/// Get the txid of the local commitment transaction contained in this
+/// Get the txid of the holder commitment transaction contained in this
 /// HolderCommitmentTransaction
 #[must_use]
 #[no_mangle]
@@ -708,7 +708,7 @@ pub extern "C" fn HolderCommitmentTransaction_txid(this_arg: &HolderCommitmentTr
 /// by your ChannelKeys.
 /// Funding redeemscript is script locking funding_outpoint. This is the mutlsig script
 /// between your own funding key and your counterparty's. Currently, this is provided in
-/// ChannelKeys::sign_local_commitment() calls directly.
+/// ChannelKeys::sign_holder_commitment() calls directly.
 /// Channel value is amount locked in funding_outpoint.
 #[must_use]
 #[no_mangle]
@@ -725,8 +725,8 @@ pub extern "C" fn HolderCommitmentTransaction_get_holder_sig(this_arg: &HolderCo
 /// included.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_get_htlc_sigs(this_arg: &HolderCommitmentTransaction, htlc_base_key: *const [u8; 32], mut local_csv: u16) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
-       let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), local_csv, &bitcoin::secp256k1::Secp256k1::new());
+pub extern "C" fn HolderCommitmentTransaction_get_htlc_sigs(this_arg: &HolderCommitmentTransaction, htlc_base_key: *const [u8; 32], mut counterparty_selected_contest_delay: u16) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
+       let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), counterparty_selected_contest_delay, &bitcoin::secp256k1::Secp256k1::new());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_none() { crate::c_types::Signature::null() } else {  { crate::c_types::Signature::from_rust(&(item.unwrap())) } }; local_ret_0_0 }); }; local_ret_0.into() }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
 }
index eb8747e6d0a934264871132bbd3601848dff651e..1cc41b0f8fa6882f498997eb2840f6ac605f9bdc 100644 (file)
@@ -319,13 +319,13 @@ pub trait ChannelKeys : Send+Clone {
        /// protocol.
        fn sign_channel_announcement<T: secp256k1::Signing>(&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
 
-       /// Set the counterparty channel basepoints and counterparty_selected/locally_selected_contest_delay.
+       /// Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay.
        /// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
        ///
-       /// We bind locally_selected_contest_delay late here for API convenience.
+       /// We bind holder_selected_contest_delay late here for API convenience.
        ///
        /// Will be called before any signatures are applied.
-       fn on_accept(&mut self, channel_points: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, locally_selected_contest_delay: u16);
+       fn on_accept(&mut self, channel_points: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16);
 }
 
 /// A trait to describe an object which can get user secrets and key material.
@@ -356,7 +356,7 @@ pub trait KeysInterface: Send + Sync {
 struct AcceptedChannelData {
        /// Counterparty public keys and base points
        counterparty_channel_pubkeys: ChannelPublicKeys,
-       /// The contest_delay value specified by our counterparty and applied on locally-broadcastable
+       /// The contest_delay value specified by our counterparty and applied on holder-broadcastable
        /// transactions, ie the amount of time that we have to wait to recover our funds if we
        /// broadcast a transaction. You'll likely want to pass this to the
        /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
@@ -364,7 +364,7 @@ struct AcceptedChannelData {
        /// The contest_delay value specified by us and applied on transactions broadcastable
        /// by our counterparty, ie the amount of time that they have to wait to recover their funds
        /// if they broadcast a transaction.
-       locally_selected_contest_delay: u16,
+       holder_selected_contest_delay: u16,
 }
 
 #[derive(Clone)]
@@ -384,7 +384,7 @@ pub struct InMemoryChannelKeys {
        pub commitment_seed: [u8; 32],
        /// Holder public keys and basepoints
        pub(crate) holder_channel_pubkeys: ChannelPublicKeys,
-       /// Counterparty public keys and counterparty/locally selected_contest_delay, populated on channel acceptance
+       /// Counterparty public keys and counterparty/holder selected_contest_delay, populated on channel acceptance
        accepted_channel_data: Option<AcceptedChannelData>,
        /// The total value of this channel
        channel_value_satoshis: u64,
@@ -442,7 +442,7 @@ impl InMemoryChannelKeys {
        /// Will panic if on_accept wasn't called.
        pub fn counterparty_pubkeys(&self) -> &ChannelPublicKeys { &self.accepted_channel_data.as_ref().unwrap().counterparty_channel_pubkeys }
 
-       /// The contest_delay value specified by our counterparty and applied on locally-broadcastable
+       /// The contest_delay value specified by our counterparty and applied on holder-broadcastable
        /// transactions, ie the amount of time that we have to wait to recover our funds if we
        /// broadcast a transaction. You'll likely want to pass this to the
        /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
@@ -453,7 +453,7 @@ impl InMemoryChannelKeys {
        /// by our counterparty, ie the amount of time that they have to wait to recover their funds
        /// if they broadcast a transaction.
        /// Will panic if on_accept wasn't called.
-       pub fn locally_selected_contest_delay(&self) -> u16 { self.accepted_channel_data.as_ref().unwrap().locally_selected_contest_delay }
+       pub fn holder_selected_contest_delay(&self) -> u16 { self.accepted_channel_data.as_ref().unwrap().holder_selected_contest_delay }
 }
 
 impl ChannelKeys for InMemoryChannelKeys {
@@ -485,7 +485,7 @@ impl ChannelKeys for InMemoryChannelKeys {
                let mut htlc_sigs = Vec::with_capacity(htlcs.len());
                for ref htlc in htlcs {
                        if let Some(_) = htlc.transaction_output_index {
-                               let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, feerate_per_kw, accepted_data.locally_selected_contest_delay, htlc, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
+                               let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, feerate_per_kw, accepted_data.holder_selected_contest_delay, htlc, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
                                let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &keys);
                                let htlc_sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0, &htlc_redeemscript, htlc.amount_msat / 1000, SigHashType::All)[..]);
                                let our_htlc_key = match chan_utils::derive_private_key(&secp_ctx, &keys.per_commitment_point, &self.htlc_base_key) {
@@ -546,7 +546,7 @@ impl ChannelKeys for InMemoryChannelKeys {
                                Ok(counterparty_delayedpubkey) => counterparty_delayedpubkey,
                                Err(_) => return Err(())
                        };
-                       chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.locally_selected_contest_delay(), &counterparty_delayedpubkey)
+                       chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.holder_selected_contest_delay(), &counterparty_delayedpubkey)
                };
                let mut sighash_parts = bip143::SigHashCache::new(justice_tx);
                let sighash = hash_to_message!(&sighash_parts.signature_hash(input, &witness_script, amount, SigHashType::All)[..]);
@@ -588,18 +588,18 @@ impl ChannelKeys for InMemoryChannelKeys {
                Ok(secp_ctx.sign(&msghash, &self.funding_key))
        }
 
-       fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, locally_selected_contest_delay: u16) {
+       fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16) {
                assert!(self.accepted_channel_data.is_none(), "Already accepted");
                self.accepted_channel_data = Some(AcceptedChannelData {
                        counterparty_channel_pubkeys: channel_pubkeys.clone(),
                        counterparty_selected_contest_delay,
-                       locally_selected_contest_delay,
+                       holder_selected_contest_delay,
                });
        }
 }
 
 impl_writeable!(AcceptedChannelData, 0,
- { counterparty_channel_pubkeys, counterparty_selected_contest_delay, locally_selected_contest_delay });
+ { counterparty_channel_pubkeys, counterparty_selected_contest_delay, holder_selected_contest_delay });
 
 impl Writeable for InMemoryChannelKeys {
        fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
index 7b35fb3d98c8f5d1e1195a3af63420c2317acb5d..89f39ed8ff8c68949d8ae39300e3d8f381ffbf97 100644 (file)
@@ -349,8 +349,8 @@ pub struct ChannelPublicKeys {
        /// counterparty to create a secret which the counterparty can reveal to revoke previous
        /// states.
        pub revocation_basepoint: PublicKey,
-       /// The public key which receives our immediately spendable primary channel balance in
-       /// counterparty-broadcasted commitment transactions. This key is static across every commitment
+       /// The public key which receives an immediately spendable primary channel balance in
+       /// a broadcaster's commitment transactions. This key is static across every commitment
        /// transaction.
        pub payment_point: PublicKey,
        /// The base point which is used (with derive_public_key) to derive a per-commitment payment
@@ -386,7 +386,7 @@ impl TxCreationKeys {
 
 /// A script either spendable by the revocation
 /// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
-/// Encumbering a `to_local` output on a commitment transaction or 2nd-stage HTLC transactions.
+/// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
 pub fn get_revokeable_redeemscript(revocation_key: &PublicKey, contest_delay: u16, broadcaster_delayed_payment_key: &PublicKey) -> Script {
        Builder::new().push_opcode(opcodes::all::OP_IF)
                      .push_slice(&revocation_key.serialize())
@@ -494,8 +494,8 @@ pub(crate) fn get_htlc_redeemscript_with_explicit_keys(htlc: &HTLCOutputInCommit
        }
 }
 
-/// note here that 'revocation_key' is generated using countersignatory_revocation_basepoint and broadcaster's
-/// commitment secret. 'htlc' does *not* need to have its previous_output_index filled.
+/// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc
+/// does not need to have its previous_output_index filled.
 #[inline]
 pub fn get_htlc_redeemscript(htlc: &HTLCOutputInCommitment, keys: &TxCreationKeys) -> Script {
        get_htlc_redeemscript_with_explicit_keys(htlc, &keys.broadcaster_htlc_key, &keys.countersignatory_htlc_key, &keys.revocation_key)
@@ -696,14 +696,14 @@ impl HolderCommitmentTransaction {
        /// The returned Vec has one entry for each HTLC, and in the same order. For HTLCs which were
        /// considered dust and not included, a None entry exists, for all others a signature is
        /// included.
-       pub fn get_htlc_sigs<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_base_key: &SecretKey, holder_selected_contest_delay: u16, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
+       pub fn get_htlc_sigs<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_base_key: &SecretKey, counterparty_selected_contest_delay: u16, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
                let txid = self.txid();
                let mut ret = Vec::with_capacity(self.per_htlc.len());
                let holder_htlc_key = derive_private_key(secp_ctx, &self.keys.per_commitment_point, htlc_base_key).map_err(|_| ())?;
 
                for this_htlc in self.per_htlc.iter() {
                        if this_htlc.0.transaction_output_index.is_some() {
-                               let htlc_tx = build_htlc_transaction(&txid, self.feerate_per_kw, holder_selected_contest_delay, &this_htlc.0, &self.keys.broadcaster_delayed_payment_key, &self.keys.revocation_key);
+                               let htlc_tx = build_htlc_transaction(&txid, self.feerate_per_kw, counterparty_selected_contest_delay, &this_htlc.0, &self.keys.broadcaster_delayed_payment_key, &self.keys.revocation_key);
 
                                let htlc_redeemscript = get_htlc_redeemscript_with_explicit_keys(&this_htlc.0, &self.keys.broadcaster_htlc_key, &self.keys.countersignatory_htlc_key, &self.keys.revocation_key);
 
@@ -717,7 +717,7 @@ impl HolderCommitmentTransaction {
        }
 
        /// Gets a signed HTLC transaction given a preimage (for !htlc.offered) and the holder HTLC transaction signature.
-       pub(crate) fn get_signed_htlc_tx(&self, htlc_index: usize, signature: &Signature, preimage: &Option<PaymentPreimage>, holder_selected_contest_delay: u16) -> Transaction {
+       pub(crate) fn get_signed_htlc_tx(&self, htlc_index: usize, signature: &Signature, preimage: &Option<PaymentPreimage>, counterparty_selected_contest_delay: u16) -> Transaction {
                let txid = self.txid();
                let this_htlc = &self.per_htlc[htlc_index];
                assert!(this_htlc.0.transaction_output_index.is_some());
@@ -726,7 +726,7 @@ impl HolderCommitmentTransaction {
                // Further, we should never be provided the preimage for an HTLC-Timeout transaction.
                if  this_htlc.0.offered && preimage.is_some() { unreachable!(); }
 
-               let mut htlc_tx = build_htlc_transaction(&txid, self.feerate_per_kw, holder_selected_contest_delay, &this_htlc.0, &self.keys.broadcaster_delayed_payment_key, &self.keys.revocation_key);
+               let mut htlc_tx = build_htlc_transaction(&txid, self.feerate_per_kw, counterparty_selected_contest_delay, &this_htlc.0, &self.keys.broadcaster_delayed_payment_key, &self.keys.revocation_key);
                // Channel should have checked that we have a counterparty signature for this HTLC at
                // creation, and we should have a sensible htlc transaction:
                assert!(this_htlc.1.is_some());
index e00d34895c2e30b54c84dab6945dc6344238c97d..2699e461806ff247163ea44e8820d376f42c70a8 100644 (file)
@@ -262,6 +262,9 @@ enum UpdateStatus {
 // has been completed, and then turn into a Channel to get compiler-time enforcement of things like
 // calling channel_id() before we're set up or things like get_outbound_funding_signed on an
 // inbound channel.
+//
+// Holder designates channel data owned for the benefice of the user client.
+// Counterparty designates channel data owned by the another channel participant entity.
 pub(super) struct Channel<ChanSigner: ChannelKeys> {
        config: ChannelConfig,
 
index 05158f1b4d2c1109071d8624d0f59f4a27d12f3b..5d0a196f31fb27d956ae4c314dc302e243a0ae33 100644 (file)
@@ -132,8 +132,8 @@ impl ChannelKeys for EnforcingChannelKeys {
                self.inner.sign_channel_announcement(msg, secp_ctx)
        }
 
-       fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, remote_locally_selected_delay: u16, locally_selected_delay: u16) {
-               self.inner.on_accept(channel_pubkeys, remote_locally_selected_delay, locally_selected_delay)
+       fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_delay: u16, holder_selected_delay: u16) {
+               self.inner.on_accept(channel_pubkeys, counterparty_selected_delay, holder_selected_delay)
        }
 }