2 use chain::transaction::OutPoint;
4 use bitcoin::blockdata::script::Script;
6 use secp256k1::key::PublicKey;
8 use std::time::Instant;
11 // Events a user will probably have to handle
12 /// Used to indicate that the client should generate a funding transaction with the given
13 /// parameters and then call ChannelManager::funding_transaction_generated.
14 /// Generated in ChannelManager message handling.
15 FundingGenerationReady {
16 temporary_channel_id: [u8; 32],
17 channel_value_satoshis: u64,
18 output_script: Script,
19 /// The value passed in to ChannelManager::create_channel
22 /// Used to indicate that the client may now broadcast the funding transaction it created for a
23 /// channel. Broadcasting such a transaction prior to this event may lead to our counterparty
24 /// trivially stealing all funds in the funding transaction!
25 FundingBroadcastSafe {
26 funding_txo: OutPoint,
27 /// The value passed in to ChannelManager::create_channel
30 /// Indicates we've received money! Just gotta dig out that payment preimage and feed it to
31 /// ChannelManager::claim_funds to get it....
32 /// Note that if the preimage is not known, you must call ChannelManager::fail_htlc_backwards
33 /// to free up resources for this HTLC.
35 payment_hash: [u8; 32],
38 /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
39 /// and we got back the payment preimage for it). payment_preimage serves as a payment receipt,
40 /// if you wish to have such a thing, you must store it somehow!
42 payment_preimage: [u8; 32],
44 /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
45 /// something. You may wish to retry with a different route.
47 payment_hash: [u8; 32],
49 /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
50 /// time in the future.
51 PendingHTLCsForwardable {
52 time_forwardable: Instant,
55 // Events indicating the network loop should send a message to a peer:
56 /// Used to indicate that we've initialted a channel open and should send the open_channel
57 /// message provided to the given peer
60 msg: msgs::OpenChannel,
62 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
65 msg: msgs::FundingCreated,
67 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
70 msg: msgs::FundingLocked,
71 announcement_sigs: Option<msgs::AnnouncementSignatures>,
73 /// Used to indicate that a series of HTLC update messages, as well as a commitment_signed
74 /// message should be sent to the peer with the given node_id.
77 updates: msgs::CommitmentUpdate,
79 /// Used to indicate that a shutdown message should be sent to the peer with the given node_id.
84 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
85 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
86 BroadcastChannelAnnouncement {
87 msg: msgs::ChannelAnnouncement,
88 update_msg: msgs::ChannelUpdate,
90 /// Used to indicate that a channel_update should be broadcast to all peers.
91 BroadcastChannelUpdate {
92 msg: msgs::ChannelUpdate,
96 /// Broadcast an error downstream to be handled
99 action: Option<msgs::ErrorAction>
103 pub trait EventsProvider {
104 fn get_and_clear_pending_events(&self) -> Vec<Event>;