]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Change ChannelKeys interface nomenclature to holder/counterparty one
authorAntoine Riard <ariard@student.42.fr>
Mon, 31 Aug 2020 19:31:19 +0000 (15:31 -0400)
committerAntoine Riard <ariard@student.42.fr>
Mon, 14 Sep 2020 18:39:47 +0000 (14:39 -0400)
Transaction signing methods are changed from local_/remote_ prefix
to newer holder_/counterparty_ wihout any semantic changes.

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

index 8b0d313f755c5e1f26cfde457d012cea5c774b1f..a4809e711bbaceb04ca1ed68fa49154f02f4fdab 100644 (file)
@@ -272,32 +272,32 @@ pub struct ChannelKeys {
        /// ChannelKeys object uniquely and lookup or re-derive its keys.
        #[must_use]
        pub key_derivation_params: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::C2Tuple_u64u64Z,
-       /// Create a signature for a remote commitment transaction and associated HTLC transactions.
+       /// Create a signature for a counterparty commitment transaction and associated HTLC transactions.
        ///
        /// Note that if signing fails or is rejected, the channel will be force-closed.
        #[must_use]
-       pub sign_remote_commitment: extern "C" fn (this_arg: *const c_void, feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
+       pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
        /// Create a signature for a local commitment transaction. This will only ever be called with
        /// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
        /// that it will not be called multiple times.
        /// An external signer implementation should check that the commitment has not been revoked.
        #[must_use]
-       pub sign_local_commitment: extern "C" fn (this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
-       /// Create a signature for each HTLC transaction spending a local commitment transaction.
+       pub sign_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
+       /// Create a signature for each HTLC transaction spending a holder commitment transaction.
        ///
-       /// Unlike sign_local_commitment, this may be called multiple times with *different*
-       /// local_commitment_tx values. While this will never be called with a revoked
-       /// local_commitment_tx, it is possible that it is called with the second-latest
-       /// local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
+       /// Unlike sign_holder_commitment, this may be called multiple times with *different*
+       /// holder_commitment_tx values. While this will never be called with a revoked
+       /// holder_commitment_tx, it is possible that it is called with the second-latest
+       /// holder_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
        /// ChannelMonitor decided to broadcast before it had been updated to the latest.
        ///
        /// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
-       /// local_commitment_tx. For those HTLCs which have transaction_output_index set to None
+       /// holder_commitment_tx. For those HTLCs which have transaction_output_index set to None
        /// (implying they were considered dust at the time the commitment transaction was negotiated),
        /// a corresponding None should be included in the return value. All other positions in the
        /// return value must contain a signature.
        #[must_use]
-       pub sign_local_commitment_htlc_transactions: extern "C" fn (this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ,
+       pub sign_holder_commitment_htlc_transactions: extern "C" fn (this_arg: *const c_void, holder_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ,
        /// Create a signature for the given input in a transaction spending an HTLC or commitment
        /// transaction output when our counterparty broadcasts an old state.
        ///
@@ -318,7 +318,7 @@ pub struct ChannelKeys {
        /// signatures).
        #[must_use]
        pub sign_justice_transaction: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
-       /// Create a signature for a claiming transaction for a HTLC output on a remote commitment
+       /// Create a signature for a claiming transaction for a HTLC output on a counterparty commitment
        /// transaction, either offered or received.
        ///
        /// Such a transaction may claim multiples offered outputs at same time if we know the
@@ -336,7 +336,7 @@ pub struct ChannelKeys {
        /// channel state keys, which are then included in the witness script and committed to in the
        /// BIP 143 signature.
        #[must_use]
-       pub sign_remote_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
+       pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ,
        /// Create a signature for a (proposed) closing transaction.
        ///
        /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
@@ -371,11 +371,11 @@ impl Clone for ChannelKeys {
                        pubkeys: self.pubkeys.clone(),
                        set_pubkeys: self.set_pubkeys.clone(),
                        key_derivation_params: self.key_derivation_params.clone(),
-                       sign_remote_commitment: self.sign_remote_commitment.clone(),
-                       sign_local_commitment: self.sign_local_commitment.clone(),
-                       sign_local_commitment_htlc_transactions: self.sign_local_commitment_htlc_transactions.clone(),
+                       sign_counterparty_commitment: self.sign_counterparty_commitment.clone(),
+                       sign_holder_commitment: self.sign_holder_commitment.clone(),
+                       sign_holder_commitment_htlc_transactions: self.sign_holder_commitment_htlc_transactions.clone(),
                        sign_justice_transaction: self.sign_justice_transaction.clone(),
-                       sign_remote_htlc_transaction: self.sign_remote_htlc_transaction.clone(),
+                       sign_counterparty_htlc_transaction: self.sign_counterparty_htlc_transaction.clone(),
                        sign_closing_transaction: self.sign_closing_transaction.clone(),
                        sign_channel_announcement: self.sign_channel_announcement.clone(),
                        on_accept: self.on_accept.clone(),
@@ -406,20 +406,20 @@ impl rustChannelKeys for ChannelKeys {
                let (mut orig_ret_0, mut orig_ret_1) = ret.to_rust(); let mut local_ret = (orig_ret_0, orig_ret_1);
                local_ret
        }
-       fn sign_remote_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &bitcoin::blockdata::transaction::Transaction, keys: &lightning::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: &[&lightning::ln::chan_utils::HTLCOutputInCommitment], _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
+       fn sign_counterparty_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &bitcoin::blockdata::transaction::Transaction, keys: &lightning::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: &[&lightning::ln::chan_utils::HTLCOutputInCommitment], _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
                let mut local_commitment_tx = ::bitcoin::consensus::encode::serialize(commitment_tx);
                let mut local_htlcs = Vec::new(); for item in htlcs.iter() { local_htlcs.push( { crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); };
-               let mut ret = (self.sign_remote_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_slice(&local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into());
+               let mut ret = (self.sign_counterparty_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_slice(&local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into());
                let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
-       fn sign_local_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
-               let mut ret = (self.sign_local_commitment)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
+       fn sign_holder_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+               let mut ret = (self.sign_holder_commitment)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
-       fn sign_local_commitment_htlc_transactions<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<Option<bitcoin::secp256k1::Signature>>, ()> {
-               let mut ret = (self.sign_local_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
+       fn sign_holder_commitment_htlc_transactions<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, local_commitment_tx: &lightning::ln::chan_utils::LocalCommitmentTransaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<Vec<Option<bitcoin::secp256k1::Signature>>, ()> {
+               let mut ret = (self.sign_holder_commitment_htlc_transactions)(self.this_arg, &crate::ln::chan_utils::LocalCommitmentTransaction { inner: unsafe { (local_commitment_tx as *const _) as *mut _ }, is_owned: false });
                let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust().drain(..) { local_ret_0.push( { let mut local_ret_0_0 = if item.is_null() { None } else { Some( { item.into_rust() }) }; local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
@@ -430,9 +430,9 @@ impl rustChannelKeys for ChannelKeys {
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
-       fn sign_remote_htlc_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
+       fn sign_counterparty_htlc_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
                let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx);
-               let mut ret = (self.sign_remote_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
+               let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
@@ -709,11 +709,11 @@ pub extern "C" fn InMemoryChannelKeys_as_ChannelKeys(this_arg: *const InMemoryCh
                pubkeys: crate::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
                set_pubkeys: Some(InMemoryChannelKeys_ChannelKeys_set_pubkeys),
                key_derivation_params: InMemoryChannelKeys_ChannelKeys_key_derivation_params,
-               sign_remote_commitment: InMemoryChannelKeys_ChannelKeys_sign_remote_commitment,
-               sign_local_commitment: InMemoryChannelKeys_ChannelKeys_sign_local_commitment,
-               sign_local_commitment_htlc_transactions: InMemoryChannelKeys_ChannelKeys_sign_local_commitment_htlc_transactions,
+               sign_counterparty_commitment: InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment,
+               sign_holder_commitment: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment,
+               sign_holder_commitment_htlc_transactions: InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions,
                sign_justice_transaction: InMemoryChannelKeys_ChannelKeys_sign_justice_transaction,
-               sign_remote_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_remote_htlc_transaction,
+               sign_counterparty_htlc_transaction: InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction,
                sign_closing_transaction: InMemoryChannelKeys_ChannelKeys_sign_closing_transaction,
                sign_channel_announcement: InMemoryChannelKeys_ChannelKeys_sign_channel_announcement,
                on_accept: InMemoryChannelKeys_ChannelKeys_on_accept,
@@ -750,21 +750,21 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_key_derivation_params(this_arg: *c
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_remote_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
        let mut local_htlcs = Vec::new(); for mut item in htlcs.as_slice().iter() { local_htlcs.push( { unsafe { &*item.inner } }); };
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_remote_commitment(feerate_per_kw, &commitment_tx.into_bitcoin(), unsafe { &*pre_keys.inner }, &local_htlcs[..], &bitcoin::secp256k1::Secp256k1::new());
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(feerate_per_kw, &commitment_tx.into_bitcoin(), unsafe { &*pre_keys.inner }, &local_htlcs[..], &bitcoin::secp256k1::Secp256k1::new());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_local_commitment(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_local_commitment(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
        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
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_local_commitment_htlc_transactions(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_local_commitment_htlc_transactions(unsafe { &*local_commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transactions(this_arg: *const c_void, local_commitment_tx: &crate::ln::chan_utils::LocalCommitmentTransaction) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_htlc_transactions(unsafe { &*local_commitment_tx.inner }, &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
 }
@@ -776,8 +776,8 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg:
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_remote_htlc_transaction(this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_remote_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new());
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction(this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new());
        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
 }
index 4373bfcbb8b1b265bccdbb47530098b331a253ff..7c68256e02f69c246c018cd501440b6975c2adf7 100644 (file)
@@ -219,52 +219,52 @@ pub trait ChannelKeys : Send+Clone {
        /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
        /// TODO: return a Result so we can signal a validation error
        fn release_commitment_secret(&self, idx: u64) -> [u8; 32];
-       /// Gets the local channel public keys and basepoints
+       /// Gets the holder's channel public keys and basepoints
        fn pubkeys(&self) -> &ChannelPublicKeys;
        /// Gets arbitrary identifiers describing the set of keys which are provided back to you in
        /// some SpendableOutputDescriptor types. These should be sufficient to identify this
        /// ChannelKeys object uniquely and lookup or re-derive its keys.
        fn key_derivation_params(&self) -> (u64, u64);
 
-       /// Create a signature for a remote commitment transaction and associated HTLC transactions.
+       /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
        ///
        /// Note that if signing fails or is rejected, the channel will be force-closed.
        //
        // TODO: Document the things someone using this interface should enforce before signing.
        // TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
        // making the callee generate it via some util function we expose)!
-       fn sign_remote_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()>;
+       fn sign_counterparty_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()>;
 
-       /// Create a signature for a local commitment transaction. This will only ever be called with
-       /// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
+       /// Create a signature for a holder's commitment transaction. This will only ever be called with
+       /// the same holder_commitment_tx (or a copy thereof), though there are currently no guarantees
        /// that it will not be called multiple times.
        /// An external signer implementation should check that the commitment has not been revoked.
        //
        // TODO: Document the things someone using this interface should enforce before signing.
        // TODO: Add more input vars to enable better checking (preferably removing commitment_tx and
-       fn sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
+       fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
 
-       /// Same as sign_local_commitment, but exists only for tests to get access to local commitment
+       /// Same as sign_holder_commitment, but exists only for tests to get access to holder commitment
        /// transactions which will be broadcasted later, after the channel has moved on to a newer
-       /// state. Thus, needs its own method as sign_local_commitment may enforce that we only ever
+       /// state. Thus, needs its own method as sign_holder_commitment may enforce that we only ever
        /// get called once.
        #[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
-       fn unsafe_sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
+       fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
 
-       /// Create a signature for each HTLC transaction spending a local commitment transaction.
+       /// Create a signature for each HTLC transaction spending a holder's commitment transaction.
        ///
-       /// Unlike sign_local_commitment, this may be called multiple times with *different*
-       /// local_commitment_tx values. While this will never be called with a revoked
-       /// local_commitment_tx, it is possible that it is called with the second-latest
-       /// local_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
+       /// Unlike sign_holder_commitment, this may be called multiple times with *different*
+       /// holder_commitment_tx values. While this will never be called with a revoked
+       /// holder_commitment_tx, it is possible that it is called with the second-latest
+       /// holder_commitment_tx (only if we haven't yet revoked it) if some watchtower/secondary
        /// ChannelMonitor decided to broadcast before it had been updated to the latest.
        ///
        /// Either an Err should be returned, or a Vec with one entry for each HTLC which exists in
-       /// local_commitment_tx. For those HTLCs which have transaction_output_index set to None
+       /// holder_commitment_tx. For those HTLCs which have transaction_output_index set to None
        /// (implying they were considered dust at the time the commitment transaction was negotiated),
        /// a corresponding None should be included in the return value. All other positions in the
        /// return value must contain a signature.
-       fn sign_local_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()>;
+       fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()>;
 
        /// Create a signature for the given input in a transaction spending an HTLC or commitment
        /// transaction output when our counterparty broadcasts an old state.
@@ -277,8 +277,8 @@ pub trait ChannelKeys : Send+Clone {
        /// Amount is value of the output spent by this input, committed to in the BIP 143 signature.
        ///
        /// per_commitment_key is revocation secret which was provided by our counterparty when they
-       /// revoked the state which they eventually broadcast. It's not a _local_ secret key and does
-       /// not allow the spending of any funds by itself (you need our local revocation_secret to do
+       /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
+       /// not allow the spending of any funds by itself (you need our holder revocation_secret to do
        /// so).
        ///
        /// htlc holds HTLC elements (hash, timelock) if the output being spent is a HTLC output, thus
@@ -286,7 +286,7 @@ pub trait ChannelKeys : Send+Clone {
        /// signatures).
        fn sign_justice_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &Option<HTLCOutputInCommitment>, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
 
-       /// Create a signature for a claiming transaction for a HTLC output on a remote commitment
+       /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
        /// transaction, either offered or received.
        ///
        /// Such a transaction may claim multiples offered outputs at same time if we know the
@@ -303,7 +303,7 @@ pub trait ChannelKeys : Send+Clone {
        /// detected onchain. It has been generated by our counterparty and is used to derive
        /// channel state keys, which are then included in the witness script and committed to in the
        /// BIP 143 signature.
-       fn sign_remote_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
+       fn sign_counterparty_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
 
        /// Create a signature for a (proposed) closing transaction.
        ///
@@ -359,7 +359,7 @@ struct AcceptedChannelData {
        /// The contest_delay value specified by our counterparty and applied on locally-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 local transactions.
+       /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
        counterparty_selected_contest_delay: u16,
        /// 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
@@ -372,18 +372,18 @@ struct AcceptedChannelData {
 pub struct InMemoryChannelKeys {
        /// Private key of anchor tx
        pub funding_key: SecretKey,
-       /// Local secret key for blinded revocation pubkey
+       /// Holder secret key for blinded revocation pubkey
        pub revocation_base_key: SecretKey,
-       /// Local secret key used for our balance in remote-broadcasted commitment transactions
+       /// Holder secret key used for our balance in counterparty-broadcasted commitment transactions
        pub payment_key: SecretKey,
-       /// Local secret key used in HTLC tx
+       /// Holder secret key used in HTLC tx
        pub delayed_payment_base_key: SecretKey,
-       /// Local htlc secret key used in commitment tx htlc outputs
+       /// Holder htlc secret key used in commitment tx htlc outputs
        pub htlc_base_key: SecretKey,
        /// Commitment seed
        pub commitment_seed: [u8; 32],
-       /// Local public keys and basepoints
-       pub(crate) local_channel_pubkeys: ChannelPublicKeys,
+       /// Holder public keys and basepoints
+       pub(crate) holder_channel_pubkeys: ChannelPublicKeys,
        /// Counterparty public keys and counterparty/locally selected_contest_delay, populated on channel acceptance
        accepted_channel_data: Option<AcceptedChannelData>,
        /// The total value of this channel
@@ -404,8 +404,8 @@ impl InMemoryChannelKeys {
                commitment_seed: [u8; 32],
                channel_value_satoshis: u64,
                key_derivation_params: (u64, u64)) -> InMemoryChannelKeys {
-               let local_channel_pubkeys =
-                       InMemoryChannelKeys::make_local_keys(secp_ctx, &funding_key, &revocation_base_key,
+               let holder_channel_pubkeys =
+                       InMemoryChannelKeys::make_holder_keys(secp_ctx, &funding_key, &revocation_base_key,
                                                             &payment_key, &delayed_payment_base_key,
                                                             &htlc_base_key);
                InMemoryChannelKeys {
@@ -416,13 +416,13 @@ impl InMemoryChannelKeys {
                        htlc_base_key,
                        commitment_seed,
                        channel_value_satoshis,
-                       local_channel_pubkeys,
+                       holder_channel_pubkeys,
                        accepted_channel_data: None,
                        key_derivation_params,
                }
        }
 
-       fn make_local_keys<C: Signing>(secp_ctx: &Secp256k1<C>,
+       fn make_holder_keys<C: Signing>(secp_ctx: &Secp256k1<C>,
                                       funding_key: &SecretKey,
                                       revocation_base_key: &SecretKey,
                                       payment_key: &SecretKey,
@@ -445,7 +445,7 @@ impl InMemoryChannelKeys {
        /// The contest_delay value specified by our counterparty and applied on locally-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 local transactions.
+       /// ln::chan_utils::build*_transaction functions when signing holder's transactions.
        /// Will panic if on_accept wasn't called.
        pub fn counterparty_selected_contest_delay(&self) -> u16 { self.accepted_channel_data.as_ref().unwrap().counterparty_selected_contest_delay }
 
@@ -466,10 +466,10 @@ impl ChannelKeys for InMemoryChannelKeys {
                chan_utils::build_commitment_secret(&self.commitment_seed, idx)
        }
 
-       fn pubkeys(&self) -> &ChannelPublicKeys { &self.local_channel_pubkeys }
+       fn pubkeys(&self) -> &ChannelPublicKeys { &self.holder_channel_pubkeys }
        fn key_derivation_params(&self) -> (u64, u64) { self.key_derivation_params }
 
-       fn sign_remote_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, pre_keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()> {
+       fn sign_counterparty_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, pre_keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()> {
                if commitment_tx.input.len() != 1 { return Err(()); }
                let keys = pre_keys.trust_key_derivation();
 
@@ -499,26 +499,26 @@ impl ChannelKeys for InMemoryChannelKeys {
                Ok((commitment_sig, htlc_sigs))
        }
 
-       fn sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+       fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
                let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
                let counterparty_channel_data = self.accepted_channel_data.as_ref().expect("must accept before signing");
                let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &counterparty_channel_data.counterparty_channel_pubkeys.funding_pubkey);
 
-               Ok(local_commitment_tx.get_local_sig(&self.funding_key, &channel_funding_redeemscript, self.channel_value_satoshis, secp_ctx))
+               Ok(holder_commitment_tx.get_local_sig(&self.funding_key, &channel_funding_redeemscript, self.channel_value_satoshis, secp_ctx))
        }
 
        #[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
-       fn unsafe_sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+       fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
                let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
                let counterparty_channel_pubkeys = &self.accepted_channel_data.as_ref().expect("must accept before signing").counterparty_channel_pubkeys;
                let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &counterparty_channel_pubkeys.funding_pubkey);
 
-               Ok(local_commitment_tx.get_local_sig(&self.funding_key, &channel_funding_redeemscript, self.channel_value_satoshis, secp_ctx))
+               Ok(holder_commitment_tx.get_local_sig(&self.funding_key, &channel_funding_redeemscript, self.channel_value_satoshis, secp_ctx))
        }
 
-       fn sign_local_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
-               let local_csv = self.accepted_channel_data.as_ref().unwrap().counterparty_selected_contest_delay;
-               local_commitment_tx.get_htlc_sigs(&self.htlc_base_key, local_csv, secp_ctx)
+       fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
+               let counterparty_selected_contest_delay = self.accepted_channel_data.as_ref().unwrap().counterparty_selected_contest_delay;
+               holder_commitment_tx.get_htlc_sigs(&self.htlc_base_key, counterparty_selected_contest_delay, secp_ctx)
        }
 
        fn sign_justice_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &Option<HTLCOutputInCommitment>, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
@@ -536,11 +536,11 @@ impl ChannelKeys for InMemoryChannelKeys {
                                Ok(counterparty_htlcpubkey) => counterparty_htlcpubkey,
                                Err(_) => return Err(())
                        };
-                       let local_htlcpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.pubkeys().htlc_basepoint) {
-                               Ok(local_htlcpubkey) => local_htlcpubkey,
+                       let holder_htlcpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.pubkeys().htlc_basepoint) {
+                               Ok(holder_htlcpubkey) => holder_htlcpubkey,
                                Err(_) => return Err(())
                        };
-                       chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &counterparty_htlcpubkey, &local_htlcpubkey, &revocation_pubkey)
+                       chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &counterparty_htlcpubkey, &holder_htlcpubkey, &revocation_pubkey)
                } else {
                        let counterparty_delayedpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.counterparty_pubkeys().delayed_payment_basepoint) {
                                Ok(counterparty_delayedpubkey) => counterparty_delayedpubkey,
@@ -553,7 +553,7 @@ impl ChannelKeys for InMemoryChannelKeys {
                return Ok(secp_ctx.sign(&sighash, &revocation_key))
        }
 
-       fn sign_remote_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+       fn sign_counterparty_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
                if let Ok(htlc_key) = chan_utils::derive_private_key(&secp_ctx, &per_commitment_point, &self.htlc_base_key) {
                        let witness_script = if let Ok(revocation_pubkey) = chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint) {
                                if let Ok(counterparty_htlcpubkey) = chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.counterparty_pubkeys().htlc_basepoint) {
@@ -629,8 +629,8 @@ impl Readable for InMemoryChannelKeys {
                let counterparty_channel_data = Readable::read(reader)?;
                let channel_value_satoshis = Readable::read(reader)?;
                let secp_ctx = Secp256k1::signing_only();
-               let local_channel_pubkeys =
-                       InMemoryChannelKeys::make_local_keys(&secp_ctx, &funding_key, &revocation_base_key,
+               let holder_channel_pubkeys =
+                       InMemoryChannelKeys::make_holder_keys(&secp_ctx, &funding_key, &revocation_base_key,
                                                             &payment_key, &delayed_payment_base_key,
                                                             &htlc_base_key);
                let params_1 = Readable::read(reader)?;
@@ -644,7 +644,7 @@ impl Readable for InMemoryChannelKeys {
                        htlc_base_key,
                        commitment_seed,
                        channel_value_satoshis,
-                       local_channel_pubkeys,
+                       holder_channel_pubkeys,
                        accepted_channel_data: counterparty_channel_data,
                        key_derivation_params: (params_1, params_2),
                })
index aee16c603baebee5fbd7f432d82e69ed8ec2efb9..5ad83125c8360bf9f920fbc8e23b770d2dc412ca 100644 (file)
@@ -1487,7 +1487,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                let counterparty_keys = self.build_remote_transaction_keys()?;
                let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, self.feerate_per_kw, logger).0;
                let pre_remote_keys = PreCalculatedTxCreationKeys::new(counterparty_keys);
-               let counterparty_signature = self.holder_keys.sign_remote_commitment(self.feerate_per_kw, &counterparty_initial_commitment_tx, &pre_remote_keys, &Vec::new(), &self.secp_ctx)
+               let counterparty_signature = self.holder_keys.sign_counterparty_commitment(self.feerate_per_kw, &counterparty_initial_commitment_tx, &pre_remote_keys, &Vec::new(), &self.secp_ctx)
                                .map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed".to_owned()))?.0;
 
                // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
@@ -3517,7 +3517,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                let counterparty_keys = self.build_remote_transaction_keys()?;
                let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, self.feerate_per_kw, logger).0;
                let pre_remote_keys = PreCalculatedTxCreationKeys::new(counterparty_keys);
-               Ok(self.holder_keys.sign_remote_commitment(self.feerate_per_kw, &counterparty_initial_commitment_tx, &pre_remote_keys, &Vec::new(), &self.secp_ctx)
+               Ok(self.holder_keys.sign_counterparty_commitment(self.feerate_per_kw, &counterparty_initial_commitment_tx, &pre_remote_keys, &Vec::new(), &self.secp_ctx)
                                .map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed".to_owned()))?.0)
        }
 
@@ -3870,7 +3870,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                        }
 
                        let pre_remote_keys = PreCalculatedTxCreationKeys::new(counterparty_keys);
-                       let res = self.holder_keys.sign_remote_commitment(feerate_per_kw, &counterparty_commitment_tx.0, &pre_remote_keys, &htlcs, &self.secp_ctx)
+                       let res = self.holder_keys.sign_counterparty_commitment(feerate_per_kw, &counterparty_commitment_tx.0, &pre_remote_keys, &htlcs, &self.secp_ctx)
                                .map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed".to_owned()))?;
                        signature = res.0;
                        htlc_signatures = res.1;
@@ -4702,13 +4702,13 @@ mod tests {
                                assert_eq!(unsigned_tx.1.len(), per_htlc.len());
 
                                localtx = LocalCommitmentTransaction::new_missing_local_sig(unsigned_tx.0.clone(), counterparty_signature.clone(), &chan_keys.pubkeys().funding_pubkey, chan.counterparty_funding_pubkey(), keys.clone(), chan.feerate_per_kw, per_htlc);
-                               let local_sig = chan_keys.sign_local_commitment(&localtx, &chan.secp_ctx).unwrap();
+                               let local_sig = chan_keys.sign_holder_commitment(&localtx, &chan.secp_ctx).unwrap();
                                assert_eq!(Signature::from_der(&hex::decode($sig_hex).unwrap()[..]).unwrap(), local_sig);
 
                                assert_eq!(serialize(&localtx.add_local_sig(&redeemscript, local_sig))[..],
                                                hex::decode($tx_hex).unwrap()[..]);
 
-                               let htlc_sigs = chan_keys.sign_local_commitment_htlc_transactions(&localtx, &chan.secp_ctx).unwrap();
+                               let htlc_sigs = chan_keys.sign_holder_commitment_htlc_transactions(&localtx, &chan.secp_ctx).unwrap();
                                let mut htlc_sig_iter = localtx.per_htlc.iter().zip(htlc_sigs.iter().enumerate());
 
                                $({
index 70030d1daf7e192da891dce1260a665735138635..5e274c798d9afc7c84c63b7a32bc90b155b2097f 100644 (file)
@@ -1704,7 +1704,7 @@ fn test_fee_spike_violation_fails_htlc() {
                let local_chan = local_chan_lock.by_id.get(&chan.2).unwrap();
                let local_chan_keys = local_chan.get_keys();
                let pre_commit_tx_keys = PreCalculatedTxCreationKeys::new(commit_tx_keys);
-               local_chan_keys.sign_remote_commitment(feerate_per_kw, &commit_tx, &pre_commit_tx_keys, &[&accepted_htlc_info], &secp_ctx).unwrap()
+               local_chan_keys.sign_counterparty_commitment(feerate_per_kw, &commit_tx, &pre_commit_tx_keys, &[&accepted_htlc_info], &secp_ctx).unwrap()
        };
 
        let commit_signed_msg = msgs::CommitmentSigned {
@@ -4217,8 +4217,8 @@ fn test_invalid_channel_announcement() {
 
        nodes[0].net_graph_msg_handler.handle_htlc_fail_channel_update(&msgs::HTLCFailChannelUpdate::ChannelClosed { short_channel_id : as_chan.get_short_channel_id().unwrap(), is_permanent: false } );
 
-       let as_bitcoin_key = as_chan.get_keys().inner.local_channel_pubkeys.funding_pubkey;
-       let bs_bitcoin_key = bs_chan.get_keys().inner.local_channel_pubkeys.funding_pubkey;
+       let as_bitcoin_key = as_chan.get_keys().inner.holder_channel_pubkeys.funding_pubkey;
+       let bs_bitcoin_key = bs_chan.get_keys().inner.holder_channel_pubkeys.funding_pubkey;
 
        let as_network_key = nodes[0].node.get_our_node_id();
        let bs_network_key = nodes[1].node.get_our_node_id();
index ec11215d60bc22032a0b2f428edd0bd7c2f88ce9..f0d7072256aa0ef24d81e26e9363eee717b29a05 100644 (file)
@@ -611,7 +611,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
                                                        let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.broadcaster_htlc_key, &chan_keys.countersignatory_htlc_key, &chan_keys.revocation_key);
 
                                                        if !preimage.is_some() { bumped_tx.lock_time = htlc.cltv_expiry }; // Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation
-                                                       if let Ok(sig) = self.key_storage.sign_remote_htlc_transaction(&bumped_tx, i, &htlc.amount_msat / 1000, &per_commitment_point, htlc, &self.secp_ctx) {
+                                                       if let Ok(sig) = self.key_storage.sign_counterparty_htlc_transaction(&bumped_tx, i, &htlc.amount_msat / 1000, &per_commitment_point, htlc, &self.secp_ctx) {
                                                                bumped_tx.input[i].witness.push(sig.serialize_der().to_vec());
                                                                bumped_tx.input[i].witness[0].push(SigHashType::All as u8);
                                                                if let &Some(preimage) = preimage {
@@ -893,7 +893,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
 
        fn sign_latest_local_htlcs(&mut self) {
                if let Some(ref local_commitment) = self.local_commitment {
-                       if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, &self.secp_ctx) {
+                       if let Ok(sigs) = self.key_storage.sign_holder_commitment_htlc_transactions(local_commitment, &self.secp_ctx) {
                                self.local_htlc_sigs = Some(Vec::new());
                                let ret = self.local_htlc_sigs.as_mut().unwrap();
                                for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() {
@@ -909,7 +909,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
        }
        fn sign_prev_local_htlcs(&mut self) {
                if let Some(ref local_commitment) = self.prev_local_commitment {
-                       if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, &self.secp_ctx) {
+                       if let Ok(sigs) = self.key_storage.sign_holder_commitment_htlc_transactions(local_commitment, &self.secp_ctx) {
                                self.prev_local_htlc_sigs = Some(Vec::new());
                                let ret = self.prev_local_htlc_sigs.as_mut().unwrap();
                                for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() {
@@ -930,7 +930,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
        // to monitor before.
        pub(super) fn get_fully_signed_local_tx(&mut self, funding_redeemscript: &Script) -> Option<Transaction> {
                if let Some(ref mut local_commitment) = self.local_commitment {
-                       match self.key_storage.sign_local_commitment(local_commitment, &self.secp_ctx) {
+                       match self.key_storage.sign_holder_commitment(local_commitment, &self.secp_ctx) {
                                Ok(sig) => Some(local_commitment.add_local_sig(funding_redeemscript, sig)),
                                Err(_) => return None,
                        }
@@ -943,7 +943,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
        pub(super) fn get_fully_signed_copy_local_tx(&mut self, funding_redeemscript: &Script) -> Option<Transaction> {
                if let Some(ref mut local_commitment) = self.local_commitment {
                        let local_commitment = local_commitment.clone();
-                       match self.key_storage.sign_local_commitment(&local_commitment, &self.secp_ctx) {
+                       match self.key_storage.sign_holder_commitment(&local_commitment, &self.secp_ctx) {
                                Ok(sig) => Some(local_commitment.add_local_sig(funding_redeemscript, sig)),
                                Err(_) => return None,
                        }
index 8f73ee8f1e1022ad711b215c372f80c61378aae9..67c38dc7193263a5df4e5e02d1e4f50bd48df627 100644 (file)
@@ -69,7 +69,7 @@ impl ChannelKeys for EnforcingChannelKeys {
        fn pubkeys(&self) -> &ChannelPublicKeys { self.inner.pubkeys() }
        fn key_derivation_params(&self) -> (u64, u64) { self.inner.key_derivation_params() }
 
-       fn sign_remote_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, pre_keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()> {
+       fn sign_counterparty_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &Transaction, pre_keys: &PreCalculatedTxCreationKeys, htlcs: &[&HTLCOutputInCommitment], secp_ctx: &Secp256k1<T>) -> Result<(Signature, Vec<Signature>), ()> {
                if commitment_tx.input.len() != 1 { panic!("lightning commitment transactions have a single input"); }
                self.check_keys(secp_ctx, pre_keys.trust_key_derivation());
                let obscured_commitment_transaction_number = (commitment_tx.lock_time & 0xffffff) as u64 | ((commitment_tx.input[0].sequence as u64 & 0xffffff) << 3*8);
@@ -84,44 +84,44 @@ impl ChannelKeys for EnforcingChannelKeys {
                        commitment_data.1 = cmp::max(commitment_number, commitment_data.1)
                }
 
-               Ok(self.inner.sign_remote_commitment(feerate_per_kw, commitment_tx, pre_keys, htlcs, secp_ctx).unwrap())
+               Ok(self.inner.sign_counterparty_commitment(feerate_per_kw, commitment_tx, pre_keys, htlcs, secp_ctx).unwrap())
        }
 
-       fn sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+       fn sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
                // TODO: enforce the ChannelKeys contract - error if this commitment was already revoked
                // TODO: need the commitment number
-               Ok(self.inner.sign_local_commitment(local_commitment_tx, secp_ctx).unwrap())
+               Ok(self.inner.sign_holder_commitment(holder_commitment_tx, secp_ctx).unwrap())
        }
 
        #[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
-       fn unsafe_sign_local_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
-               Ok(self.inner.unsafe_sign_local_commitment(local_commitment_tx, secp_ctx).unwrap())
+       fn unsafe_sign_holder_commitment<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+               Ok(self.inner.unsafe_sign_holder_commitment(holder_commitment_tx, secp_ctx).unwrap())
        }
 
-       fn sign_local_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, local_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
-               let commitment_txid = local_commitment_tx.txid();
+       fn sign_holder_commitment_htlc_transactions<T: secp256k1::Signing + secp256k1::Verification>(&self, holder_commitment_tx: &LocalCommitmentTransaction, secp_ctx: &Secp256k1<T>) -> Result<Vec<Option<Signature>>, ()> {
+               let commitment_txid = holder_commitment_tx.txid();
                let local_csv = self.inner.counterparty_selected_contest_delay();
 
-               for this_htlc in local_commitment_tx.per_htlc.iter() {
+               for this_htlc in holder_commitment_tx.per_htlc.iter() {
                        if this_htlc.0.transaction_output_index.is_some() {
-                               let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, local_commitment_tx.feerate_per_kw, local_csv, &this_htlc.0, &local_commitment_tx.local_keys.broadcaster_delayed_payment_key, &local_commitment_tx.local_keys.revocation_key);
+                               let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, holder_commitment_tx.feerate_per_kw, local_csv, &this_htlc.0, &holder_commitment_tx.local_keys.broadcaster_delayed_payment_key, &holder_commitment_tx.local_keys.revocation_key);
 
-                               let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&this_htlc.0, &local_commitment_tx.local_keys);
+                               let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&this_htlc.0, &holder_commitment_tx.local_keys);
 
                                let sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0, &htlc_redeemscript, this_htlc.0.amount_msat / 1000, SigHashType::All)[..]);
-                               secp_ctx.verify(&sighash, this_htlc.1.as_ref().unwrap(), &local_commitment_tx.local_keys.countersignatory_htlc_key).unwrap();
+                               secp_ctx.verify(&sighash, this_htlc.1.as_ref().unwrap(), &holder_commitment_tx.local_keys.countersignatory_htlc_key).unwrap();
                        }
                }
 
-               Ok(self.inner.sign_local_commitment_htlc_transactions(local_commitment_tx, secp_ctx).unwrap())
+               Ok(self.inner.sign_holder_commitment_htlc_transactions(holder_commitment_tx, secp_ctx).unwrap())
        }
 
        fn sign_justice_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &Option<HTLCOutputInCommitment>, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
                Ok(self.inner.sign_justice_transaction(justice_tx, input, amount, per_commitment_key, htlc, secp_ctx).unwrap())
        }
 
-       fn sign_remote_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
-               Ok(self.inner.sign_remote_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc, secp_ctx).unwrap())
+       fn sign_counterparty_htlc_transaction<T: secp256k1::Signing + secp256k1::Verification>(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
+               Ok(self.inner.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc, secp_ctx).unwrap())
        }
 
        fn sign_closing_transaction<T: secp256k1::Signing>(&self, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {