Skip to content

Commit 0cfe55c

Browse files
authored
Merge pull request #3160 from TheBlueMatt/2024-07-better-enum-upgradable-ser
Make `impl_writeable_tlv_based_enum*` actually upgradable
2 parents 012bc50 + 1d1f47c commit 0cfe55c

16 files changed

+226
-52
lines changed

lightning/src/blinded_path/message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ pub enum OffersContext {
119119
},
120120
}
121121

122-
impl_writeable_tlv_based_enum!(MessageContext, ;
123-
(0, Offers),
124-
(1, Custom),
122+
impl_writeable_tlv_based_enum!(MessageContext,
123+
{0, Offers} => (),
124+
{1, Custom} => (),
125125
);
126126

127127
impl_writeable_tlv_based_enum!(OffersContext,
128128
(0, Unknown) => {},
129129
(1, OutboundPayment) => {
130130
(0, payment_id, required),
131131
},
132-
;);
132+
);
133133

134134
/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
135135
pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(

lightning/src/blinded_path/payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl Readable for PaymentConstraints {
431431
}
432432
}
433433

434-
impl_writeable_tlv_based_enum!(PaymentContext,
434+
impl_writeable_tlv_based_enum_legacy!(PaymentContext,
435435
;
436436
(0, Unknown),
437437
(1, Bolt12Offer),

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub enum MonitorEvent {
189189
monitor_update_id: u64,
190190
},
191191
}
192-
impl_writeable_tlv_based_enum_upgradable!(MonitorEvent,
192+
impl_writeable_tlv_based_enum_upgradable_legacy!(MonitorEvent,
193193
// Note that Completed is currently never serialized to disk as it is generated only in
194194
// ChainMonitor.
195195
(0, Completed) => {

lightning/src/chain/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl PackageSolvingData {
689689
}
690690
}
691691

692-
impl_writeable_tlv_based_enum!(PackageSolvingData, ;
692+
impl_writeable_tlv_based_enum_legacy!(PackageSolvingData, ;
693693
(0, RevokedOutput),
694694
(1, RevokedHTLCOutput),
695695
(2, CounterpartyOfferedHTLCOutput),

lightning/src/events/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl PaymentPurpose {
171171
}
172172
}
173173

174-
impl_writeable_tlv_based_enum!(PaymentPurpose,
174+
impl_writeable_tlv_based_enum_legacy!(PaymentPurpose,
175175
(0, Bolt11InvoicePayment) => {
176176
(0, payment_preimage, option),
177177
(2, payment_secret, required),
@@ -494,7 +494,7 @@ enum InterceptNextHop {
494494
impl_writeable_tlv_based_enum!(InterceptNextHop,
495495
(0, FakeScid) => {
496496
(0, requested_next_hop_scid, required),
497-
};
497+
},
498498
);
499499

500500
/// The reason the payment failed. Used in [`Event::PaymentFailed`].
@@ -535,7 +535,7 @@ impl_writeable_tlv_based_enum!(PaymentFailureReason,
535535
(4, RetriesExhausted) => {},
536536
(6, PaymentExpired) => {},
537537
(8, RouteNotFound) => {},
538-
(10, UnexpectedError) => {}, ;
538+
(10, UnexpectedError) => {},
539539
);
540540

541541
/// An Event which you should probably take some action in response to.

lightning/src/ln/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl_writeable_tlv_based_enum!(InboundHTLCResolution,
130130
},
131131
(2, Pending) => {
132132
(0, update_add_htlc, required),
133-
};
133+
},
134134
);
135135

136136
enum InboundHTLCState {
@@ -8495,7 +8495,7 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
84958495
const SERIALIZATION_VERSION: u8 = 4;
84968496
const MIN_SERIALIZATION_VERSION: u8 = 3;
84978497

8498-
impl_writeable_tlv_based_enum!(InboundHTLCRemovalReason,;
8498+
impl_writeable_tlv_based_enum_legacy!(InboundHTLCRemovalReason,;
84998499
(0, FailRelay),
85008500
(1, FailMalformed),
85018501
(2, Fulfill),

lightning/src/ln/channel_state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl_writeable_tlv_based_enum_upgradable!(InboundHTLCStateDetails,
6969
(0, AwaitingRemoteRevokeToAdd) => {},
7070
(2, Committed) => {},
7171
(4, AwaitingRemoteRevokeToRemoveFulfill) => {},
72-
(6, AwaitingRemoteRevokeToRemoveFail) => {};
72+
(6, AwaitingRemoteRevokeToRemoveFail) => {},
7373
);
7474

7575
/// Exposes details around pending inbound HTLCs.
@@ -159,7 +159,7 @@ impl_writeable_tlv_based_enum_upgradable!(OutboundHTLCStateDetails,
159159
(0, AwaitingRemoteRevokeToAdd) => {},
160160
(2, Committed) => {},
161161
(4, AwaitingRemoteRevokeToRemoveSuccess) => {},
162-
(6, AwaitingRemoteRevokeToRemoveFailure) => {};
162+
(6, AwaitingRemoteRevokeToRemoveFailure) => {},
163163
);
164164

165165
/// Exposes details around pending outbound HTLCs.
@@ -701,5 +701,5 @@ impl_writeable_tlv_based_enum!(ChannelShutdownState,
701701
(2, ShutdownInitiated) => {},
702702
(4, ResolvingHTLCs) => {},
703703
(6, NegotiatingClosingFee) => {},
704-
(8, ShutdownComplete) => {}, ;
704+
(8, ShutdownComplete) => {},
705705
);

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl_writeable_tlv_based_enum!(SentHTLCId,
476476
},
477477
(2, OutboundRoute) => {
478478
(0, session_priv, required),
479-
};
479+
},
480480
);
481481

482482

@@ -881,7 +881,7 @@ impl_writeable_tlv_based_enum!(EventCompletionAction,
881881
// Note that by the time we get past the required read above, channel_funding_outpoint will be
882882
// filled in, so we can safely unwrap it here.
883883
(3, channel_id, (default_value, ChannelId::v1_from_funding_outpoint(channel_funding_outpoint.0.unwrap()))),
884-
};
884+
}
885885
);
886886

887887
#[derive(Debug)]
@@ -10829,7 +10829,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
1082910829
(4, payment_data, option), // Added in 0.0.116
1083010830
(5, custom_tlvs, optional_vec),
1083110831
},
10832-
;);
10832+
);
1083310833

1083410834
impl_writeable_tlv_based!(PendingHTLCInfo, {
1083510835
(0, routing, required),
@@ -10909,14 +10909,14 @@ impl Readable for HTLCFailureMsg {
1090910909
}
1091010910
}
1091110911

10912-
impl_writeable_tlv_based_enum!(PendingHTLCStatus, ;
10912+
impl_writeable_tlv_based_enum_legacy!(PendingHTLCStatus, ;
1091310913
(0, Forward),
1091410914
(1, Fail),
1091510915
);
1091610916

1091710917
impl_writeable_tlv_based_enum!(BlindedFailure,
1091810918
(0, FromIntroductionNode) => {},
10919-
(2, FromBlindedNode) => {}, ;
10919+
(2, FromBlindedNode) => {},
1092010920
);
1092110921

1092210922
impl_writeable_tlv_based!(HTLCPreviousHopData, {

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ impl_writeable_tlv_based_enum!(HTLCFailReasonRepr,
953953
(0, failure_code, required),
954954
(2, data, required_vec),
955955
},
956-
;);
956+
);
957957

958958
impl HTLCFailReason {
959959
#[rustfmt::skip]

lightning/src/ln/outbound_payment.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,13 @@ pub enum Retry {
300300
}
301301

302302
#[cfg(not(feature = "std"))]
303-
impl_writeable_tlv_based_enum!(Retry,
303+
impl_writeable_tlv_based_enum_legacy!(Retry,
304304
;
305305
(0, Attempts)
306306
);
307307

308308
#[cfg(feature = "std")]
309-
impl_writeable_tlv_based_enum!(Retry,
309+
impl_writeable_tlv_based_enum_legacy!(Retry,
310310
;
311311
(0, Attempts),
312312
(2, Timeout)
@@ -397,7 +397,7 @@ pub(crate) enum StaleExpiration {
397397
AbsoluteTimeout(core::time::Duration),
398398
}
399399

400-
impl_writeable_tlv_based_enum!(StaleExpiration,
400+
impl_writeable_tlv_based_enum_legacy!(StaleExpiration,
401401
;
402402
(0, TimerTicks),
403403
(2, AbsoluteTimeout)

lightning/src/ln/script.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Readable for ShutdownScript {
5353
}
5454
}
5555

56-
impl_writeable_tlv_based_enum!(ShutdownScriptImpl, ;
56+
impl_writeable_tlv_based_enum_legacy!(ShutdownScriptImpl, ;
5757
(0, Legacy),
5858
(1, Bolt2),
5959
);

lightning/src/sign/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub enum SpendableOutputDescriptor {
301301
StaticPaymentOutput(StaticPaymentOutputDescriptor),
302302
}
303303

304-
impl_writeable_tlv_based_enum!(SpendableOutputDescriptor,
304+
impl_writeable_tlv_based_enum_legacy!(SpendableOutputDescriptor,
305305
(0, StaticOutput) => {
306306
(0, outpoint, required),
307307
(1, channel_keys_id, option),

lightning/src/util/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub enum MaxDustHTLCExposure {
410410
FeeRateMultiplier(u64),
411411
}
412412

413-
impl_writeable_tlv_based_enum!(MaxDustHTLCExposure, ;
413+
impl_writeable_tlv_based_enum_legacy!(MaxDustHTLCExposure, ;
414414
(1, FixedLimitMsat),
415415
(3, FeeRateMultiplier),
416416
);

0 commit comments

Comments
 (0)