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....
33 /// Note that if the preimage is not known, you must call ChannelManager::fail_htlc_backwards
34 /// to free up resources for this HTLC.
36 payment_hash: [u8; 32],
39 /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
40 /// and we got back the payment preimage for it). payment_preimage serves as a payment receipt,
41 /// if you wish to have such a thing, you must store it somehow!
43 payment_preimage: [u8; 32],
45 /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
46 /// something. You may wish to retry with a different route.
48 payment_hash: [u8; 32],
51 // Events indicating the network loop should send a message to a peer:
52 /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
53 /// time in the future.
54 PendingHTLCsForwardable {
55 time_forwardable: Instant,
57 /// Used to indicate that a funding_created message should be sent to the peer with the given node_id.
60 msg: msgs::FundingCreated,
62 /// Used to indicate that a funding_locked message should be sent to the peer with the given node_id.
65 msg: msgs::FundingLocked,
66 announcement_sigs: Option<msgs::AnnouncementSignatures>,
68 /// Used to indicate that a series of update_add_htlc messages, as well as a commitment_signed
69 /// message should be sent to the peer with the given node_id.
72 msgs: Vec<msgs::UpdateAddHTLC>,
73 commitment_msg: msgs::CommitmentSigned,
75 /// Used to indicate that we're ready to fulfill an htlc from the peer with the given node_id.
78 msg: msgs::UpdateFulfillHTLC,
79 commitment_msg: msgs::CommitmentSigned,
81 /// Used to indicate that we need to fail an htlc from the peer with the given node_id.
84 msg: msgs::UpdateFailHTLC,
85 commitment_msg: msgs::CommitmentSigned,
87 /// Used to indicate that a channel_announcement and channel_update should be broadcast to all
88 /// peers (except the peer with node_id either msg.contents.node_id_1 or msg.contents.node_id_2).
89 BroadcastChannelAnnouncement {
90 msg: msgs::ChannelAnnouncement,
91 update_msg: msgs::ChannelUpdate,
93 /// Used to indicate that a channel_update should be broadcast to all peers.
94 BroadcastChannelUpdate {
95 msg: msgs::ChannelUpdate,
99 pub trait EventsProvider {
100 fn get_and_clear_pending_events(&self) -> Vec<Event>;