Enum lightning::util::events::Event [−][src]
pub enum Event {
FundingGenerationReady {
temporary_channel_id: [u8; 32],
channel_value_satoshis: u64,
output_script: Script,
user_channel_id: u64,
},
PaymentReceived {
payment_hash: PaymentHash,
amt: u64,
purpose: PaymentPurpose,
},
PaymentSent {
payment_preimage: PaymentPreimage,
},
PaymentPathFailed {
payment_hash: PaymentHash,
rejected_by_dest: bool,
network_update: Option<NetworkUpdate>,
all_paths_failed: bool,
path: Vec<RouteHop>,
},
PendingHTLCsForwardable {
time_forwardable: Duration,
},
SpendableOutputs {
outputs: Vec<SpendableOutputDescriptor>,
},
PaymentForwarded {
fee_earned_msat: Option<u64>,
claim_from_onchain_tx: bool,
},
ChannelClosed {
channel_id: [u8; 32],
reason: ClosureReason,
},
}
Expand description
An Event which you should probably take some action in response to.
Note that while Writeable and Readable are implemented for Event, you probably shouldn’t use them directly as they don’t round-trip exactly (for example FundingGenerationReady is never written as it makes no sense to respond to it after reconnecting to peers).
Variants
Used to indicate that the client should generate a funding transaction with the given parameters and then call ChannelManager::funding_transaction_generated. Generated in ChannelManager message handling. Note that all inputs in the funding transaction must spend SegWit outputs or your counterparty can steal your funds!
Fields of FundingGenerationReady
temporary_channel_id: [u8; 32]
The random channel_id we picked which you’ll need to pass into ChannelManager::funding_transaction_generated.
channel_value_satoshis: u64
The value, in satoshis, that the output should have.
output_script: Script
The script which should be used in the transaction output.
user_channel_id: u64
The value passed in to ChannelManager::create_channel
Indicates we’ve received money! Just gotta dig out that payment preimage and feed it to ChannelManager::claim_funds to get it…. Note that if the preimage is not known or the amount paid is incorrect, you should call ChannelManager::fail_htlc_backwards to free up resources for this HTLC and avoid network congestion. The amount paid should be considered ‘incorrect’ when it is less than or more than twice the amount expected. If you fail to call either ChannelManager::claim_funds or ChannelManager::fail_htlc_backwards within the HTLC’s timeout, the HTLC will be automatically failed.
Fields of PaymentReceived
payment_hash: PaymentHash
The hash for which the preimage should be handed to the ChannelManager.
amt: u64
The value, in thousandths of a satoshi, that this payment is for. Note that you must compare this to the expected value before accepting the payment (as otherwise you are providing proof-of-payment for less than the value you expected!).
purpose: PaymentPurpose
Information for claiming this received payment, based on whether the purpose of the payment is to pay an invoice or to send a spontaneous payment.
Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target and we got back the payment preimage for it).
Note for MPP payments: in rare cases, this event may be preceded by a PaymentPathFailed
event. In this situation, you SHOULD treat this payment as having succeeded.
Fields of PaymentSent
payment_preimage: PaymentPreimage
The preimage to the hash given to ChannelManager::send_payment. Note that this serves as a payment receipt, if you wish to have such a thing, you must store it somehow!
Indicates an outbound payment we made failed. Probably some intermediary node dropped something. You may wish to retry with a different route.
Fields of PaymentPathFailed
payment_hash: PaymentHash
The hash which was given to ChannelManager::send_payment.
rejected_by_dest: bool
Indicates the payment was rejected for some reason by the recipient. This implies that the payment has failed, not just the route in question. If this is not set, you may retry the payment via a different route.
network_update: Option<NetworkUpdate>
Any failure information conveyed via the Onion return packet by a node along the failed payment route.
Should be applied to the NetworkGraph
so that routing decisions can take into
account the update. NetGraphMsgHandler
is capable of doing this.
all_paths_failed: bool
For both single-path and multi-path payments, this is set if all paths of the payment have failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the larger MPP payment were still in flight when this event was generated.
path: Vec<RouteHop>
The payment path that failed.
Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a time in the future.
Fields of PendingHTLCsForwardable
time_forwardable: Duration
The minimum amount of time that should be waited prior to calling process_pending_htlc_forwards. To increase the effort required to correlate payments, you should wait a random amount of time in roughly the range (now + time_forwardable, now + 5*time_forwardable).
Used to indicate that an output which you should know how to spend was confirmed on chain and is now spendable. Such an output will not ever be spent by rust-lightning, and are not at risk of your counterparty spending them due to some kind of timeout. Thus, you need to store them somewhere and spend them when you create on-chain transactions.
Fields of SpendableOutputs
outputs: Vec<SpendableOutputDescriptor>
The outputs which you should store as spendable by you.
This event is generated when a payment has been successfully forwarded through us and a forwarding fee earned.
Fields of PaymentForwarded
fee_earned_msat: Option<u64>
The fee, in milli-satoshis, which was earned as a result of the payment.
Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
was pending, the amount the next hop claimed will have been rounded down to the nearest
whole satoshi. Thus, the fee calculated here may be higher than expected as we still
claimed the full value in millisatoshis from the source. In this case,
claim_from_onchain_tx
will be set.
If the channel which sent us the payment has been force-closed, we will claim the funds
via an on-chain transaction. In that case we do not yet know the on-chain transaction
fees which we will spend and will instead set this to None
. It is possible duplicate
PaymentForwarded
events are generated for the same payment iff fee_earned_msat
is
None
.
claim_from_onchain_tx: bool
If this is true
, the forwarded HTLC was claimed by our counterparty via an on-chain
transaction.
Used to indicate that a channel with the given channel_id
is in the process of closure.
Fields of ChannelClosed
channel_id: [u8; 32]
The channel_id of the channel which has been closed. Note that on-chain transactions resolving the channel are likely still awaiting confirmation.
reason: ClosureReason
The reason the channel was closed.
Trait Implementations
Writes self out to the given Writer
Writes self out to a Vec
Writes self out to a Vec
Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length. Read more
Auto Trait Implementations
impl RefUnwindSafe for Event
impl UnwindSafe for Event
Blanket Implementations
Mutably borrows from an owned value. Read more