use crate::chain::channelmonitor;
use crate::chain::channelmonitor::MonitorEvent;
use crate::chain::transaction::OutPoint;
-use crate::chain::keysinterface;
+use crate::sign;
use crate::events;
use crate::ln::channelmanager;
use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use core::mem;
use bitcoin::bech32::u5;
-use crate::chain::keysinterface::{InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider};
+use crate::sign::{InMemorySigner, Recipient, EntropySource, NodeSigner, SignerProvider};
#[cfg(feature = "std")]
use std::time::{SystemTime, UNIX_EPOCH};
))
}
- fn get_destination_script(&self) -> Script { unreachable!(); }
- fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!(); }
+ fn get_destination_script(&self) -> Result<Script, ()> { Err(()) }
+ fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { Err(()) }
}
pub struct TestChainMonitor<'a> {
self.update_rets.lock().unwrap().push_back(next_ret);
}
}
-impl<Signer: keysinterface::WriteableEcdsaChannelSigner> chainmonitor::Persist<Signer> for TestPersister {
+impl<Signer: sign::WriteableEcdsaChannelSigner> chainmonitor::Persist<Signer> for TestPersister {
fn persist_new_channel(&self, _funding_txo: OutPoint, _data: &channelmonitor::ChannelMonitor<Signer>, _id: MonitorUpdateId) -> chain::ChannelMonitorUpdateStatus {
if let Some(update_ret) = self.update_rets.lock().unwrap().pop_front() {
return update_ret
fn provided_init_features(&self, _their_init_features: &PublicKey) -> InitFeatures {
channelmanager::provided_init_features(&UserConfig::default())
}
+
+ fn handle_open_channel_v2(&self, _their_node_id: &PublicKey, msg: &msgs::OpenChannelV2) {
+ self.received_msg(wire::Message::OpenChannelV2(msg.clone()));
+ }
+
+ fn handle_accept_channel_v2(&self, _their_node_id: &PublicKey, msg: &msgs::AcceptChannelV2) {
+ self.received_msg(wire::Message::AcceptChannelV2(msg.clone()));
+ }
+
+ fn handle_tx_add_input(&self, _their_node_id: &PublicKey, msg: &msgs::TxAddInput) {
+ self.received_msg(wire::Message::TxAddInput(msg.clone()));
+ }
+
+ fn handle_tx_add_output(&self, _their_node_id: &PublicKey, msg: &msgs::TxAddOutput) {
+ self.received_msg(wire::Message::TxAddOutput(msg.clone()));
+ }
+
+ fn handle_tx_remove_input(&self, _their_node_id: &PublicKey, msg: &msgs::TxRemoveInput) {
+ self.received_msg(wire::Message::TxRemoveInput(msg.clone()));
+ }
+
+ fn handle_tx_remove_output(&self, _their_node_id: &PublicKey, msg: &msgs::TxRemoveOutput) {
+ self.received_msg(wire::Message::TxRemoveOutput(msg.clone()));
+ }
+
+ fn handle_tx_complete(&self, _their_node_id: &PublicKey, msg: &msgs::TxComplete) {
+ self.received_msg(wire::Message::TxComplete(msg.clone()));
+ }
+
+ fn handle_tx_signatures(&self, _their_node_id: &PublicKey, msg: &msgs::TxSignatures) {
+ self.received_msg(wire::Message::TxSignatures(msg.clone()));
+ }
+
+ fn handle_tx_init_rbf(&self, _their_node_id: &PublicKey, msg: &msgs::TxInitRbf) {
+ self.received_msg(wire::Message::TxInitRbf(msg.clone()));
+ }
+
+ fn handle_tx_ack_rbf(&self, _their_node_id: &PublicKey, msg: &msgs::TxAckRbf) {
+ self.received_msg(wire::Message::TxAckRbf(msg.clone()));
+ }
+
+ fn handle_tx_abort(&self, _their_node_id: &PublicKey, msg: &msgs::TxAbort) {
+ self.received_msg(wire::Message::TxAbort(msg.clone()));
+ }
}
impl events::MessageSendEventsProvider for TestChannelMessageHandler {
}
impl NodeSigner for TestNodeSigner {
- fn get_inbound_payment_key_material(&self) -> crate::chain::keysinterface::KeyMaterial {
+ fn get_inbound_payment_key_material(&self) -> crate::sign::KeyMaterial {
unreachable!()
}
}
pub struct TestKeysInterface {
- pub backing: keysinterface::PhantomKeysManager,
+ pub backing: sign::PhantomKeysManager,
pub override_random_bytes: Mutex<Option<[u8; 32]>>,
pub disable_revocation_policy_check: bool,
enforcement_states: Mutex<HashMap<[u8;32], Arc<Mutex<EnforcementState>>>>,
self.backing.ecdh(recipient, other_key, tweak)
}
- fn get_inbound_payment_key_material(&self) -> keysinterface::KeyMaterial {
+ fn get_inbound_payment_key_material(&self) -> sign::KeyMaterial {
self.backing.get_inbound_payment_key_material()
}
))
}
- fn get_destination_script(&self) -> Script { self.backing.get_destination_script() }
+ fn get_destination_script(&self) -> Result<Script, ()> { self.backing.get_destination_script() }
- fn get_shutdown_scriptpubkey(&self) -> ShutdownScript {
+ fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> {
match &mut *self.expectations.lock().unwrap() {
None => self.backing.get_shutdown_scriptpubkey(),
Some(expectations) => match expectations.pop_front() {
None => panic!("Unexpected get_shutdown_scriptpubkey"),
- Some(expectation) => expectation.returns,
+ Some(expectation) => Ok(expectation.returns),
},
}
}
pub fn new(seed: &[u8; 32], network: Network) -> Self {
let now = Duration::from_secs(genesis_block(network).header.time as u64);
Self {
- backing: keysinterface::PhantomKeysManager::new(seed, now.as_secs(), now.subsec_nanos(), seed),
+ backing: sign::PhantomKeysManager::new(seed, now.as_secs(), now.subsec_nanos(), seed),
override_random_bytes: Mutex::new(None),
disable_revocation_policy_check: false,
enforcement_states: Mutex::new(HashMap::new()),
}
}
- /// Sets an expectation that [`keysinterface::SignerProvider::get_shutdown_scriptpubkey`] is
+ /// Sets an expectation that [`sign::SignerProvider::get_shutdown_scriptpubkey`] is
/// called.
pub fn expect(&self, expectation: OnGetShutdownScriptpubkey) -> &Self {
self.expectations.lock().unwrap()
}
}
-/// An expectation that [`keysinterface::SignerProvider::get_shutdown_scriptpubkey`] was called and
+/// An expectation that [`sign::SignerProvider::get_shutdown_scriptpubkey`] was called and
/// returns a [`ShutdownScript`].
pub struct OnGetShutdownScriptpubkey {
/// A shutdown script used to close a channel.