+//! Utilities that take care of tasks that (1) need to happen periodically to keep Rust-Lightning
+//! running properly, and (2) either can or should be run in the background. See docs for
+//! [`BackgroundProcessor`] for more details on the nitty-gritty.
+
+#![deny(broken_intra_doc_links)]
+#![deny(missing_docs)]
+#![deny(unsafe_code)]
+
#[macro_use] extern crate lightning;
use lightning::chain;
/// Start a background thread that takes care of responsibilities enumerated in the top-level
/// documentation.
///
- /// If `persist_manager` returns an error, then this thread will return said error (and `start()`
- /// will need to be called again to restart the `BackgroundProcessor`). Users should wait on
- /// [`thread_handle`]'s `join()` method to be able to tell if and when an error is returned, or
- /// implement `persist_manager` such that an error is never returned to the `BackgroundProcessor`
+ /// If `persist_manager` returns an error, then this thread will return said error (and
+ /// `start()` will need to be called again to restart the `BackgroundProcessor`). Users should
+ /// wait on [`thread_handle`]'s `join()` method to be able to tell if and when an error is
+ /// returned, or implement `persist_manager` such that an error is never returned to the
+ /// `BackgroundProcessor`
///
- /// `persist_manager` is responsible for writing out the `ChannelManager` to disk, and/or uploading
- /// to one or more backup services. See [`ChannelManager::write`] for writing out a `ChannelManager`.
- /// See [`FilesystemPersister::persist_manager`] for Rust-Lightning's provided implementation.
+ /// `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
+ /// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
+ /// [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
+ /// provided implementation.
///
- /// [`thread_handle`]: struct.BackgroundProcessor.html#structfield.thread_handle
- /// [`ChannelManager::write`]: ../lightning/ln/channelmanager/struct.ChannelManager.html#method.write
- /// [`FilesystemPersister::persist_manager`]: ../lightning_persister/struct.FilesystemPersister.html#impl
+ /// [`thread_handle`]: BackgroundProcessor::thread_handle
+ /// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
+ /// [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
+ /// [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
pub fn start<PM, Signer, M, T, K, F, L>(persist_manager: PM, manager: Arc<ChannelManager<Signer, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>>, logger: Arc<L>) -> Self
where Signer: 'static + Sign,
M: 'static + chain::Watch<Signer>,
$node_a.node.handle_accept_channel(&$node_b.node.get_our_node_id(), InitFeatures::known(), &get_event_msg!($node_b, MessageSendEvent::SendAcceptChannel, $node_a.node.get_our_node_id()));
let events = $node_a.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
- let (temporary_channel_id, tx, funding_output) = match events[0] {
+ let (temporary_channel_id, tx) = match events[0] {
Event::FundingGenerationReady { ref temporary_channel_id, ref channel_value_satoshis, ref output_script, user_channel_id } => {
assert_eq!(*channel_value_satoshis, $channel_value);
assert_eq!(user_channel_id, 42);
let tx = Transaction { version: 1 as i32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
}]};
- let funding_outpoint = OutPoint { txid: tx.txid(), index: 0 };
- (*temporary_channel_id, tx, funding_outpoint)
+ (*temporary_channel_id, tx)
},
_ => panic!("Unexpected event"),
};
- $node_a.node.funding_transaction_generated(&temporary_channel_id, funding_output);
+ $node_a.node.funding_transaction_generated(&temporary_channel_id, tx.clone()).unwrap();
$node_b.node.handle_funding_created(&$node_a.node.get_our_node_id(), &get_event_msg!($node_a, MessageSendEvent::SendFundingCreated, $node_b.node.get_our_node_id()));
$node_a.node.handle_funding_signed(&$node_b.node.get_our_node_id(), &get_event_msg!($node_b, MessageSendEvent::SendFundingSigned, $node_a.node.get_our_node_id()));
tx