From: Valentine Wallace Date: Sun, 9 Apr 2023 19:41:33 +0000 (-0400) Subject: Support (de)ser for Path::blinded_tails in events X-Git-Tag: v0.0.115~5^2~7 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=97a8c9156449928129b83b2aa9f020b22e7a9946;p=rust-lightning Support (de)ser for Path::blinded_tails in events --- diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs index b5f682e1f..110d56cfe 100644 --- a/lightning/src/events/mod.rs +++ b/lightning/src/events/mod.rs @@ -30,7 +30,7 @@ use crate::routing::gossip::NetworkUpdate; use crate::util::errors::APIError; use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, RequiredWrapper, UpgradableRequired, WithoutLength}; use crate::util::string::UntrustedString; -use crate::routing::router::{Path, RouteHop, RouteParameters}; +use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters}; use bitcoin::{PackedLockTime, Transaction, OutPoint}; #[cfg(anchors)] @@ -884,6 +884,7 @@ impl Writeable for Event { (1, None::, option), // network_update in LDK versions prior to 0.0.114 (2, payment_failed_permanently, required), (3, false, required), // all_paths_failed in LDK versions prior to 0.0.114 + (4, path.blinded_tail, option), (5, path.hops, vec_type), (7, short_channel_id, option), (9, None::, option), // retry in LDK versions prior to 0.0.115 @@ -953,6 +954,7 @@ impl Writeable for Event { (0, payment_id, required), (2, payment_hash, option), (4, path.hops, vec_type), + (6, path.blinded_tail, option), }) }, &Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => { @@ -983,6 +985,7 @@ impl Writeable for Event { (0, payment_id, required), (2, payment_hash, required), (4, path.hops, vec_type), + (6, path.blinded_tail, option), }) }, &Event::ProbeFailed { ref payment_id, ref payment_hash, ref path, ref short_channel_id } => { @@ -992,6 +995,7 @@ impl Writeable for Event { (2, payment_hash, required), (4, path.hops, vec_type), (6, short_channel_id, option), + (8, path.blinded_tail, option), }) }, &Event::HTLCHandlingFailed { ref prev_channel_id, ref failed_next_destination } => { @@ -1122,6 +1126,7 @@ impl MaybeReadable for Event { let mut payment_hash = PaymentHash([0; 32]); let mut payment_failed_permanently = false; let mut network_update = None; + let mut blinded_tail: Option = None; let mut path: Option> = Some(vec![]); let mut short_channel_id = None; let mut payment_id = None; @@ -1130,6 +1135,7 @@ impl MaybeReadable for Event { (0, payment_hash, required), (1, network_update, upgradable_option), (2, payment_failed_permanently, required), + (4, blinded_tail, option), (5, path, vec_type), (7, short_channel_id, option), (11, payment_id, option), @@ -1141,7 +1147,7 @@ impl MaybeReadable for Event { payment_hash, payment_failed_permanently, failure, - path: Path { hops: path.unwrap(), blinded_tail: None }, + path: Path { hops: path.unwrap(), blinded_tail }, short_channel_id, #[cfg(test)] error_code, @@ -1244,18 +1250,16 @@ impl MaybeReadable for Event { }, 13u8 => { let f = || { - let mut payment_id = PaymentId([0; 32]); - let mut payment_hash = None; - let mut path: Option> = Some(vec![]); - read_tlv_fields!(reader, { + _init_and_read_tlv_fields!(reader, { (0, payment_id, required), (2, payment_hash, option), (4, path, vec_type), + (6, blinded_tail, option), }); Ok(Some(Event::PaymentPathSuccessful { - payment_id, + payment_id: payment_id.0.unwrap(), payment_hash, - path: Path { hops: path.unwrap(), blinded_tail: None }, + path: Path { hops: path.unwrap(), blinded_tail }, })) }; f() @@ -1305,38 +1309,33 @@ impl MaybeReadable for Event { }, 21u8 => { let f = || { - let mut payment_id = PaymentId([0; 32]); - let mut payment_hash = PaymentHash([0; 32]); - let mut path: Option> = Some(vec![]); - read_tlv_fields!(reader, { + _init_and_read_tlv_fields!(reader, { (0, payment_id, required), (2, payment_hash, required), (4, path, vec_type), + (6, blinded_tail, option), }); Ok(Some(Event::ProbeSuccessful { - payment_id, - payment_hash, - path: Path { hops: path.unwrap(), blinded_tail: None }, + payment_id: payment_id.0.unwrap(), + payment_hash: payment_hash.0.unwrap(), + path: Path { hops: path.unwrap(), blinded_tail }, })) }; f() }, 23u8 => { let f = || { - let mut payment_id = PaymentId([0; 32]); - let mut payment_hash = PaymentHash([0; 32]); - let mut path: Option> = Some(vec![]); - let mut short_channel_id = None; - read_tlv_fields!(reader, { + _init_and_read_tlv_fields!(reader, { (0, payment_id, required), (2, payment_hash, required), (4, path, vec_type), (6, short_channel_id, option), + (8, blinded_tail, option), }); Ok(Some(Event::ProbeFailed { - payment_id, - payment_hash, - path: Path { hops: path.unwrap(), blinded_tail: None }, + payment_id: payment_id.0.unwrap(), + payment_hash: payment_hash.0.unwrap(), + path: Path { hops: path.unwrap(), blinded_tail }, short_channel_id, })) };