3 use bitcoin::blockdata::script::Script;
4 use bitcoin::util::uint::Uint256;
5 use bitcoin::util::hash::Sha256dHash;
7 use secp256k1::key::PublicKey;
9 use std::time::Instant;
12 // Events a user will probably have to handle
13 /// Used to indicate that the client should generate a funding transaction with the given
14 /// parameters and then call ChannelManager::funding_transaction_generated.
15 /// Generated in ChannelManager message handling.
16 FundingGenerationReady {
17 temporary_channel_id: Uint256,
18 channel_value_satoshis: u64,
19 output_script: Script,
20 /// The value passed in to ChannelManager::create_channel
23 /// Used to indicate that the client may now broadcast the funding transaction it created for a
24 /// channel. Broadcasting such a transaction prior to this event may lead to our counterparty
25 /// trivially stealing all funds in the funding transaction!
26 FundingBroadcastSafe {
27 funding_txo: (Sha256dHash, u16),
28 /// The value passed in to ChannelManager::create_channel
31 /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
32 /// ChannelManager::claim_funds to get it....
34 payment_hash: [u8; 32],
38 // Events indicating the network loop should send a message to a peer:
39 /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
40 /// time in the future.
41 PendingHTLCsForwardable {
42 time_forwardable: Instant,
44 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
47 msg: msgs::FundingCreated,
49 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
52 msg: msgs::FundingLocked,
53 announcement_sigs: Option<msgs::AnnouncementSignatures>,
55 /// Used to indicate that a series of update_add_htlc messages, as well as a commitment_signed
56 /// message should be sent to the peer with the given node_id.
59 msgs: Vec<msgs::UpdateAddHTLC>,
60 commitment_msg: msgs::CommitmentSigned,
62 /// Used to indicate that we're ready to fulfill an htlc from the peer with the given node_id.
65 msg: msgs::UpdateFulfillHTLC,
67 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
68 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
69 BroadcastChannelAnnouncement {
70 msg: msgs::ChannelAnnouncement,
71 update_msg: msgs::ChannelUpdate,
75 pub trait EventsProvider {
76 fn get_and_clear_pending_events(&self) -> Vec<Event>;