mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Rename TxCreationKeys::new to not conflict w/ auto-gen'd C bindings
The C bindings automatically create a _new() function for structs which contain only pub fields which we know how to map. This conflicts with the actual TxCreationKeys::new() function, so we simply rename it to capture its nature as a derivation function.
This commit is contained in:
parent
2ff4ae782e
commit
c6bae1fdb0
5 changed files with 13 additions and 13 deletions
|
@ -358,7 +358,7 @@ impl_writeable!(ChannelPublicKeys, 33*5, {
|
|||
|
||||
impl TxCreationKeys {
|
||||
/// Create a new TxCreationKeys from channel base points and the per-commitment point
|
||||
pub fn new<T: secp256k1::Signing + secp256k1::Verification>(secp_ctx: &Secp256k1<T>, per_commitment_point: &PublicKey, a_delayed_payment_base: &PublicKey, a_htlc_base: &PublicKey, b_revocation_base: &PublicKey, b_htlc_base: &PublicKey) -> Result<TxCreationKeys, SecpError> {
|
||||
pub fn derive_new<T: secp256k1::Signing + secp256k1::Verification>(secp_ctx: &Secp256k1<T>, per_commitment_point: &PublicKey, a_delayed_payment_base: &PublicKey, a_htlc_base: &PublicKey, b_revocation_base: &PublicKey, b_htlc_base: &PublicKey) -> Result<TxCreationKeys, SecpError> {
|
||||
Ok(TxCreationKeys {
|
||||
per_commitment_point: per_commitment_point.clone(),
|
||||
revocation_key: derive_public_revocation_key(&secp_ctx, &per_commitment_point, &b_revocation_base)?,
|
||||
|
|
|
@ -1126,7 +1126,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
let htlc_basepoint = &self.local_keys.pubkeys().htlc_basepoint;
|
||||
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
|
||||
|
||||
Ok(secp_check!(TxCreationKeys::new(&self.secp_ctx, &per_commitment_point, delayed_payment_base, htlc_basepoint, &their_pubkeys.revocation_basepoint, &their_pubkeys.htlc_basepoint), "Local tx keys generation got bogus keys".to_owned()))
|
||||
Ok(secp_check!(TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, delayed_payment_base, htlc_basepoint, &their_pubkeys.revocation_basepoint, &their_pubkeys.htlc_basepoint), "Local tx keys generation got bogus keys".to_owned()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -1140,7 +1140,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
let htlc_basepoint = &self.local_keys.pubkeys().htlc_basepoint;
|
||||
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
|
||||
|
||||
Ok(secp_check!(TxCreationKeys::new(&self.secp_ctx, &self.their_cur_commitment_point.unwrap(), &their_pubkeys.delayed_payment_basepoint, &their_pubkeys.htlc_basepoint, revocation_basepoint, htlc_basepoint), "Remote tx keys generation got bogus keys".to_owned()))
|
||||
Ok(secp_check!(TxCreationKeys::derive_new(&self.secp_ctx, &self.their_cur_commitment_point.unwrap(), &their_pubkeys.delayed_payment_basepoint, &their_pubkeys.htlc_basepoint, revocation_basepoint, htlc_basepoint), "Remote tx keys generation got bogus keys".to_owned()))
|
||||
}
|
||||
|
||||
/// Gets the redeemscript for the funding transaction output (ie the funding transaction output
|
||||
|
@ -4674,7 +4674,7 @@ mod tests {
|
|||
let per_commitment_secret = SecretKey::from_slice(&hex::decode("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100").unwrap()[..]).unwrap();
|
||||
let per_commitment_point = PublicKey::from_secret_key(&secp_ctx, &per_commitment_secret);
|
||||
let htlc_basepoint = &chan.local_keys.pubkeys().htlc_basepoint;
|
||||
let keys = TxCreationKeys::new(&secp_ctx, &per_commitment_point, delayed_payment_base, htlc_basepoint, &their_pubkeys.revocation_basepoint, &their_pubkeys.htlc_basepoint).unwrap();
|
||||
let keys = TxCreationKeys::derive_new(&secp_ctx, &per_commitment_point, delayed_payment_base, htlc_basepoint, &their_pubkeys.revocation_basepoint, &their_pubkeys.htlc_basepoint).unwrap();
|
||||
|
||||
chan.their_pubkeys = Some(their_pubkeys);
|
||||
|
||||
|
|
|
@ -1636,7 +1636,7 @@ fn test_fee_spike_violation_fails_htlc() {
|
|||
// Assemble the set of keys we can use for signatures for our commitment_signed message.
|
||||
let commitment_secret = SecretKey::from_slice(&remote_secret1).unwrap();
|
||||
let per_commitment_point = PublicKey::from_secret_key(&secp_ctx, &commitment_secret);
|
||||
let commit_tx_keys = chan_utils::TxCreationKeys::new(&secp_ctx, &per_commitment_point, &remote_delayed_payment_basepoint,
|
||||
let commit_tx_keys = chan_utils::TxCreationKeys::derive_new(&secp_ctx, &per_commitment_point, &remote_delayed_payment_basepoint,
|
||||
&remote_htlc_basepoint, &local_revocation_basepoint, &local_htlc_basepoint).unwrap();
|
||||
|
||||
// Build the remote commitment transaction so we can sign it, and then later use the
|
||||
|
|
|
@ -583,7 +583,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
|
|||
for (i, (outp, per_outp_material)) in cached_claim_datas.per_input_material.iter().enumerate() {
|
||||
match per_outp_material {
|
||||
&InputMaterial::Revoked { ref per_commitment_point, ref remote_delayed_payment_base_key, ref remote_htlc_base_key, ref per_commitment_key, ref input_descriptor, ref amount, ref htlc, ref on_remote_tx_csv } => {
|
||||
if let Ok(chan_keys) = TxCreationKeys::new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) {
|
||||
if let Ok(chan_keys) = TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) {
|
||||
|
||||
let witness_script = if let Some(ref htlc) = *htlc {
|
||||
chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.a_htlc_key, &chan_keys.b_htlc_key, &chan_keys.revocation_key)
|
||||
|
@ -607,7 +607,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
|
|||
}
|
||||
},
|
||||
&InputMaterial::RemoteHTLC { ref per_commitment_point, ref remote_delayed_payment_base_key, ref remote_htlc_base_key, ref preimage, ref htlc } => {
|
||||
if let Ok(chan_keys) = TxCreationKeys::new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) {
|
||||
if let Ok(chan_keys) = TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) {
|
||||
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.a_htlc_key, &chan_keys.b_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
|
||||
|
|
|
@ -46,12 +46,12 @@ impl EnforcingChannelKeys {
|
|||
keys: &TxCreationKeys) {
|
||||
let remote_points = self.inner.remote_pubkeys();
|
||||
|
||||
let keys_expected = TxCreationKeys::new(secp_ctx,
|
||||
&keys.per_commitment_point,
|
||||
&remote_points.delayed_payment_basepoint,
|
||||
&remote_points.htlc_basepoint,
|
||||
&self.inner.pubkeys().revocation_basepoint,
|
||||
&self.inner.pubkeys().htlc_basepoint).unwrap();
|
||||
let keys_expected = TxCreationKeys::derive_new(secp_ctx,
|
||||
&keys.per_commitment_point,
|
||||
&remote_points.delayed_payment_basepoint,
|
||||
&remote_points.htlc_basepoint,
|
||||
&self.inner.pubkeys().revocation_basepoint,
|
||||
&self.inner.pubkeys().htlc_basepoint).unwrap();
|
||||
if keys != &keys_expected { panic!("derived different per-tx keys") }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue