Skip to content

Commit

Permalink
Add MPPFragmentFailed event
Browse files Browse the repository at this point in the history
This will be used in upcoming commits to improve our interface for failed
payments.
  • Loading branch information
valentinewallace committed Sep 1, 2021
1 parent 44e96dc commit 696b7f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use core::cmp;
use core::ops::Deref;

/// A hop in a route
#[derive(Clone, Hash, PartialEq, Eq)]
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct RouteHop {
/// The node_id of the node at this hop.
pub pubkey: PublicKey,
Expand Down
16 changes: 16 additions & 0 deletions lightning/src/util/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ln::msgs;
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use chain::keysinterface::SpendableOutputDescriptor;
use routing::router::RouteHop;
use util::ser::{Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};

use bitcoin::blockdata::script::Script;
Expand Down Expand Up @@ -137,6 +138,14 @@ pub enum Event {
#[cfg(test)]
error_data: Option<Vec<u8>>,
},
/// Indicates an outbound MPP payment partially failed. Probably some intermediary node dropped
/// something. You may wish to retry this portion of the payment with a different path.
MPPFragmentFailed {
/// The hash which was given to ChannelManager::send_payment.
payment_hash: PaymentHash,
/// The path that failed.
payment_path: Vec<RouteHop>,
},
/// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
/// time in the future.
PendingHTLCsForwardable {
Expand Down Expand Up @@ -250,6 +259,13 @@ impl Writeable for Event {
(2, claim_from_onchain_tx, required),
});
},
&Event::MPPFragmentFailed { ref payment_hash, ref payment_path } => {
8u8.write(writer)?;
write_tlv_fields!(writer, {
(0, payment_hash, required),
(2, payment_path, vec_type),
});
},
}
Ok(())
}
Expand Down

0 comments on commit 696b7f9

Please sign in to comment.