Skip to content

Commit e6eb654

Browse files
committed
Replace vec_type TLVs in channel/manager with required/optional
* `PhantomRouteHints::channels` has been written since the struct was added in 410eb05. * `HTLCSource::path_hops` has been written since the struct was converted to TLVs in 66784e3.
1 parent 6fbeea0 commit e6eb654

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6783,9 +6783,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
67836783
(7, self.context.shutdown_scriptpubkey, option),
67846784
(8, self.context.blocked_monitor_updates, optional_vec),
67856785
(9, self.context.target_closing_feerate_sats_per_kw, option),
6786-
(11, self.context.monitor_pending_finalized_fulfills, vec_type),
6786+
(11, self.context.monitor_pending_finalized_fulfills, required_vec),
67876787
(13, self.context.channel_creation_height, required),
6788-
(15, preimages, vec_type),
6788+
(15, preimages, required_vec),
67896789
(17, self.context.announcement_sigs_state, required),
67906790
(19, self.context.latest_inbound_scid_alias, option),
67916791
(21, self.context.outbound_scid_alias, required),
@@ -7091,9 +7091,9 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
70917091
(7, shutdown_scriptpubkey, option),
70927092
(8, blocked_monitor_updates, optional_vec),
70937093
(9, target_closing_feerate_sats_per_kw, option),
7094-
(11, monitor_pending_finalized_fulfills, vec_type),
7094+
(11, monitor_pending_finalized_fulfills, optional_vec),
70957095
(13, channel_creation_height, option),
7096-
(15, preimages_opt, vec_type),
7096+
(15, preimages_opt, optional_vec),
70977097
(17, announcement_sigs_state, option),
70987098
(19, latest_inbound_scid_alias, option),
70997099
(21, outbound_scid_alias, option),

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, No
4545
#[cfg(any(feature = "_test_utils", test))]
4646
use crate::ln::features::InvoiceFeatures;
4747
use crate::routing::gossip::NetworkGraph;
48-
use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteHop, RouteParameters, Router};
48+
use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
4949
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
5050
use crate::ln::msgs;
5151
use crate::ln::onion_utils;
@@ -3170,6 +3170,7 @@ where
31703170
/// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
31713171
/// different route unless you intend to pay twice!
31723172
///
3173+
/// [`RouteHop`]: crate::routing::router::RouteHop
31733174
/// [`Event::PaymentSent`]: events::Event::PaymentSent
31743175
/// [`Event::PaymentFailed`]: events::Event::PaymentFailed
31753176
/// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
@@ -7442,7 +7443,7 @@ impl Readable for ChannelDetails {
74427443
}
74437444

74447445
impl_writeable_tlv_based!(PhantomRouteHints, {
7445-
(2, channels, vec_type),
7446+
(2, channels, required_vec),
74467447
(4, phantom_scid, required),
74477448
(6, real_node_pubkey, required),
74487449
});
@@ -7634,15 +7635,15 @@ impl Readable for HTLCSource {
76347635
0 => {
76357636
let mut session_priv: crate::util::ser::RequiredWrapper<SecretKey> = crate::util::ser::RequiredWrapper(None);
76367637
let mut first_hop_htlc_msat: u64 = 0;
7637-
let mut path_hops: Option<Vec<RouteHop>> = Some(Vec::new());
7638+
let mut path_hops = Vec::new();
76387639
let mut payment_id = None;
76397640
let mut payment_params: Option<PaymentParameters> = None;
76407641
let mut blinded_tail: Option<BlindedTail> = None;
76417642
read_tlv_fields!(reader, {
76427643
(0, session_priv, required),
76437644
(1, payment_id, option),
76447645
(2, first_hop_htlc_msat, required),
7645-
(4, path_hops, vec_type),
7646+
(4, path_hops, required_vec),
76467647
(5, payment_params, (option: ReadableArgs, 0)),
76477648
(6, blinded_tail, option),
76487649
});
@@ -7651,7 +7652,7 @@ impl Readable for HTLCSource {
76517652
// instead.
76527653
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
76537654
}
7654-
let path = Path { hops: path_hops.ok_or(DecodeError::InvalidValue)?, blinded_tail };
7655+
let path = Path { hops: path_hops, blinded_tail };
76557656
if path.hops.len() == 0 {
76567657
return Err(DecodeError::InvalidValue);
76577658
}
@@ -7686,7 +7687,7 @@ impl Writeable for HTLCSource {
76867687
(1, payment_id_opt, option),
76877688
(2, first_hop_htlc_msat, required),
76887689
// 3 was previously used to write a PaymentSecret for the payment.
7689-
(4, path.hops, vec_type),
7690+
(4, path.hops, required_vec),
76907691
(5, None::<PaymentParameters>, option), // payment_params in LDK versions prior to 0.0.115
76917692
(6, path.blinded_tail, option),
76927693
});
@@ -7936,7 +7937,7 @@ where
79367937
(6, monitor_update_blocked_actions_per_peer, option),
79377938
(7, self.fake_scid_rand_bytes, required),
79387939
(8, if events_not_backwards_compatible { Some(&*events) } else { None }, option),
7939-
(9, htlc_purposes, vec_type),
7940+
(9, htlc_purposes, required_vec),
79407941
(10, in_flight_monitor_updates, option),
79417942
(11, self.probing_cookie_secret, required),
79427943
(13, htlc_onion_fields, optional_vec),
@@ -8375,7 +8376,7 @@ where
83758376
(6, monitor_update_blocked_actions_per_peer, option),
83768377
(7, fake_scid_rand_bytes, option),
83778378
(8, events_override, option),
8378-
(9, claimable_htlc_purposes, vec_type),
8379+
(9, claimable_htlc_purposes, optional_vec),
83798380
(10, in_flight_monitor_updates, option),
83808381
(11, probing_cookie_secret, option),
83818382
(13, claimable_htlc_onion_fields, optional_vec),

0 commit comments

Comments
 (0)