|
17 | 17 | use ln::msgs;
|
18 | 18 | use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
|
19 | 19 | use chain::keysinterface::SpendableOutputDescriptor;
|
| 20 | +use routing::router::RouteHop; |
20 | 21 | use util::ser::{Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
|
21 | 22 |
|
22 | 23 | use bitcoin::blockdata::script::Script;
|
@@ -137,6 +138,14 @@ pub enum Event {
|
137 | 138 | #[cfg(test)]
|
138 | 139 | error_data: Option<Vec<u8>>,
|
139 | 140 | },
|
| 141 | + /// Indicates an outbound MPP payment partially failed. Probably some intermediary node dropped |
| 142 | + /// something. You may wish to retry this portion of the payment with a different path. |
| 143 | + MPPFragmentFailed { |
| 144 | + /// The hash which was given to ChannelManager::send_payment. |
| 145 | + payment_hash: PaymentHash, |
| 146 | + /// The path that failed. |
| 147 | + payment_path: Vec<RouteHop>, |
| 148 | + }, |
140 | 149 | /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
|
141 | 150 | /// time in the future.
|
142 | 151 | PendingHTLCsForwardable {
|
@@ -250,6 +259,13 @@ impl Writeable for Event {
|
250 | 259 | (2, claim_from_onchain_tx, required),
|
251 | 260 | });
|
252 | 261 | },
|
| 262 | + &Event::MPPFragmentFailed { ref payment_hash, ref payment_path } => { |
| 263 | + 9u8.write(writer)?; |
| 264 | + write_tlv_fields!(writer, { |
| 265 | + (0, payment_hash, required), |
| 266 | + (2, payment_path, vec_type), |
| 267 | + }); |
| 268 | + }, |
253 | 269 | }
|
254 | 270 | Ok(())
|
255 | 271 | }
|
@@ -357,6 +373,18 @@ impl MaybeReadable for Event {
|
357 | 373 | };
|
358 | 374 | f()
|
359 | 375 | },
|
| 376 | + 9u8 => { |
| 377 | + let f = || { |
| 378 | + let mut payment_hash = PaymentHash([0; 32]); |
| 379 | + let mut payment_path = None; |
| 380 | + read_tlv_fields!(reader, { |
| 381 | + (0, payment_hash, required), |
| 382 | + (2, payment_path, vec_type), |
| 383 | + }); |
| 384 | + Ok(Some(Event::MPPFragmentFailed { payment_hash, payment_path: payment_path.unwrap() })) |
| 385 | + }; |
| 386 | + f() |
| 387 | + } |
360 | 388 | // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
|
361 | 389 | x if x % 2 == 1 => Ok(None),
|
362 | 390 | _ => Err(msgs::DecodeError::InvalidValue)
|
|
0 commit comments