From: Wilmer Paulino Date: Wed, 18 Jan 2023 20:28:42 +0000 (-0800) Subject: Remove unused NodeSigner implementations in tests X-Git-Tag: v0.0.114-beta~50^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=aee9952ea3d519611ff151599421cd3421d418d0;p=rust-lightning Remove unused NodeSigner implementations in tests These implementations have every method panic, so assuming that the test suite passes, these implementations are never used. --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 5dbae1bbb..8b323a3a9 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -6807,22 +6807,19 @@ mod tests { use crate::ln::chan_utils::{htlc_success_tx_weight, htlc_timeout_tx_weight}; use crate::chain::BestBlock; use crate::chain::chaininterface::{FeeEstimator, LowerBoundedFeeEstimator, ConfirmationTarget}; - use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider}; + use crate::chain::keysinterface::{BaseSign, InMemorySigner, EntropySource, SignerProvider}; use crate::chain::transaction::OutPoint; use crate::util::config::UserConfig; use crate::util::enforcing_trait_impls::EnforcingSigner; use crate::util::errors::APIError; use crate::util::test_utils; use crate::util::test_utils::OnGetShutdownScriptpubkey; - use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature, Scalar}; + use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature}; use bitcoin::secp256k1::ffi::Signature as FFISignature; use bitcoin::secp256k1::{SecretKey,PublicKey}; - use bitcoin::secp256k1::ecdh::SharedSecret; - use bitcoin::secp256k1::ecdsa::RecoverableSignature; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::Hash; use bitcoin::hash_types::WPubkeyHash; - use bitcoin::bech32::u5; use bitcoin::PackedLockTime; use bitcoin::util::address::WitnessVersion; use crate::prelude::*; @@ -6861,21 +6858,6 @@ mod tests { fn get_secure_random_bytes(&self) -> [u8; 32] { [0; 32] } } - impl NodeSigner for Keys { - fn get_node_secret(&self, _recipient: Recipient) -> Result { panic!(); } - - fn get_node_id(&self, recipient: Recipient) -> Result { - let secp_ctx = Secp256k1::signing_only(); - Ok(PublicKey::from_secret_key(&secp_ctx, &self.get_node_secret(recipient)?)) - } - - fn ecdh(&self, _recipient: Recipient, _other_key: &PublicKey, _tweak: Option<&Scalar>) -> Result { panic!(); } - - fn get_inbound_payment_key_material(&self) -> KeyMaterial { panic!(); } - - fn sign_invoice(&self, _hrp_bytes: &[u8], _invoice_data: &[u5], _recipient: Recipient) -> Result { panic!(); } - } - impl SignerProvider for Keys { type Signer = InMemorySigner; diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index f528ae2d5..627ee54eb 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -51,7 +51,7 @@ use crate::sync::{Mutex, Arc}; use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use core::mem; use bitcoin::bech32::u5; -use crate::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider}; +use crate::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider}; #[cfg(feature = "std")] use std::time::{SystemTime, UNIX_EPOCH}; @@ -107,17 +107,6 @@ pub struct OnlyReadsKeysInterface {} impl EntropySource for OnlyReadsKeysInterface { fn get_secure_random_bytes(&self) -> [u8; 32] { [0; 32] }} -impl NodeSigner for OnlyReadsKeysInterface { - fn get_node_secret(&self, _recipient: Recipient) -> Result { unreachable!(); } - fn get_node_id(&self, recipient: Recipient) -> Result { - let secp_ctx = Secp256k1::signing_only(); - Ok(PublicKey::from_secret_key(&secp_ctx, &self.get_node_secret(recipient)?)) - } - fn ecdh(&self, _recipient: Recipient, _other_key: &PublicKey, _tweak: Option<&Scalar>) -> Result { unreachable!(); } - fn get_inbound_payment_key_material(&self) -> KeyMaterial { unreachable!(); } - fn sign_invoice(&self, _hrp_bytes: &[u8], _invoice_data: &[u5], _recipient: Recipient) -> Result { unreachable!(); } -} - impl SignerProvider for OnlyReadsKeysInterface { type Signer = EnforcingSigner;