Skip to content

Make impl_writeable_tlv_based_enum* actually upgradable #3160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lightning/src/blinded_path/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ pub enum OffersContext {
},
}

impl_writeable_tlv_based_enum!(MessageContext, ;
(0, Offers),
(1, Custom),
impl_writeable_tlv_based_enum!(MessageContext,
{0, Offers} => (),
{1, Custom} => (),
);

impl_writeable_tlv_based_enum!(OffersContext,
(0, Unknown) => {},
(1, OutboundPayment) => {
(0, payment_id, required),
},
;);
);

/// Construct blinded onion message hops for the given `intermediate_nodes` and `recipient_node_id`.
pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/blinded_path/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl Readable for PaymentConstraints {
}
}

impl_writeable_tlv_based_enum!(PaymentContext,
impl_writeable_tlv_based_enum_legacy!(PaymentContext,
;
(0, Unknown),
(1, Bolt12Offer),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub enum MonitorEvent {
monitor_update_id: u64,
},
}
impl_writeable_tlv_based_enum_upgradable!(MonitorEvent,
impl_writeable_tlv_based_enum_upgradable_legacy!(MonitorEvent,
// Note that Completed is currently never serialized to disk as it is generated only in
// ChainMonitor.
(0, Completed) => {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ impl PackageSolvingData {
}
}

impl_writeable_tlv_based_enum!(PackageSolvingData, ;
impl_writeable_tlv_based_enum_legacy!(PackageSolvingData, ;
(0, RevokedOutput),
(1, RevokedHTLCOutput),
(2, CounterpartyOfferedHTLCOutput),
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl PaymentPurpose {
}
}

impl_writeable_tlv_based_enum!(PaymentPurpose,
impl_writeable_tlv_based_enum_legacy!(PaymentPurpose,
(0, Bolt11InvoicePayment) => {
(0, payment_preimage, option),
(2, payment_secret, required),
Expand Down Expand Up @@ -494,7 +494,7 @@ enum InterceptNextHop {
impl_writeable_tlv_based_enum!(InterceptNextHop,
(0, FakeScid) => {
(0, requested_next_hop_scid, required),
};
},
);

/// The reason the payment failed. Used in [`Event::PaymentFailed`].
Expand Down Expand Up @@ -535,7 +535,7 @@ impl_writeable_tlv_based_enum!(PaymentFailureReason,
(4, RetriesExhausted) => {},
(6, PaymentExpired) => {},
(8, RouteNotFound) => {},
(10, UnexpectedError) => {}, ;
(10, UnexpectedError) => {},
);

/// An Event which you should probably take some action in response to.
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl_writeable_tlv_based_enum!(InboundHTLCResolution,
},
(2, Pending) => {
(0, update_add_htlc, required),
};
},
);

enum InboundHTLCState {
Expand Down Expand Up @@ -8390,7 +8390,7 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
const SERIALIZATION_VERSION: u8 = 4;
const MIN_SERIALIZATION_VERSION: u8 = 3;

impl_writeable_tlv_based_enum!(InboundHTLCRemovalReason,;
impl_writeable_tlv_based_enum_legacy!(InboundHTLCRemovalReason,;
(0, FailRelay),
(1, FailMalformed),
(2, Fulfill),
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/ln/channel_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl_writeable_tlv_based_enum_upgradable!(InboundHTLCStateDetails,
(0, AwaitingRemoteRevokeToAdd) => {},
(2, Committed) => {},
(4, AwaitingRemoteRevokeToRemoveFulfill) => {},
(6, AwaitingRemoteRevokeToRemoveFail) => {};
(6, AwaitingRemoteRevokeToRemoveFail) => {},
);

/// Exposes details around pending inbound HTLCs.
Expand Down Expand Up @@ -159,7 +159,7 @@ impl_writeable_tlv_based_enum_upgradable!(OutboundHTLCStateDetails,
(0, AwaitingRemoteRevokeToAdd) => {},
(2, Committed) => {},
(4, AwaitingRemoteRevokeToRemoveSuccess) => {},
(6, AwaitingRemoteRevokeToRemoveFailure) => {};
(6, AwaitingRemoteRevokeToRemoveFailure) => {},
);

/// Exposes details around pending outbound HTLCs.
Expand Down Expand Up @@ -701,5 +701,5 @@ impl_writeable_tlv_based_enum!(ChannelShutdownState,
(2, ShutdownInitiated) => {},
(4, ResolvingHTLCs) => {},
(6, NegotiatingClosingFee) => {},
(8, ShutdownComplete) => {}, ;
(8, ShutdownComplete) => {},
);
10 changes: 5 additions & 5 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl_writeable_tlv_based_enum!(SentHTLCId,
},
(2, OutboundRoute) => {
(0, session_priv, required),
};
},
);


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

#[derive(Debug)]
Expand Down Expand Up @@ -10808,7 +10808,7 @@ impl_writeable_tlv_based_enum!(PendingHTLCRouting,
(4, payment_data, option), // Added in 0.0.116
(5, custom_tlvs, optional_vec),
},
;);
);

impl_writeable_tlv_based!(PendingHTLCInfo, {
(0, routing, required),
Expand Down Expand Up @@ -10888,14 +10888,14 @@ impl Readable for HTLCFailureMsg {
}
}

impl_writeable_tlv_based_enum!(PendingHTLCStatus, ;
impl_writeable_tlv_based_enum_legacy!(PendingHTLCStatus, ;
(0, Forward),
(1, Fail),
);

impl_writeable_tlv_based_enum!(BlindedFailure,
(0, FromIntroductionNode) => {},
(2, FromBlindedNode) => {}, ;
(2, FromBlindedNode) => {},
);

impl_writeable_tlv_based!(HTLCPreviousHopData, {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/onion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ impl_writeable_tlv_based_enum!(HTLCFailReasonRepr,
(0, failure_code, required),
(2, data, required_vec),
},
;);
);

impl HTLCFailReason {
#[rustfmt::skip]
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/ln/outbound_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ pub enum Retry {
}

#[cfg(not(feature = "std"))]
impl_writeable_tlv_based_enum!(Retry,
impl_writeable_tlv_based_enum_legacy!(Retry,
;
(0, Attempts)
);

#[cfg(feature = "std")]
impl_writeable_tlv_based_enum!(Retry,
impl_writeable_tlv_based_enum_legacy!(Retry,
;
(0, Attempts),
(2, Timeout)
Expand Down Expand Up @@ -397,7 +397,7 @@ pub(crate) enum StaleExpiration {
AbsoluteTimeout(core::time::Duration),
}

impl_writeable_tlv_based_enum!(StaleExpiration,
impl_writeable_tlv_based_enum_legacy!(StaleExpiration,
;
(0, TimerTicks),
(2, AbsoluteTimeout)
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Readable for ShutdownScript {
}
}

impl_writeable_tlv_based_enum!(ShutdownScriptImpl, ;
impl_writeable_tlv_based_enum_legacy!(ShutdownScriptImpl, ;
(0, Legacy),
(1, Bolt2),
);
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ pub enum SpendableOutputDescriptor {
StaticPaymentOutput(StaticPaymentOutputDescriptor),
}

impl_writeable_tlv_based_enum!(SpendableOutputDescriptor,
impl_writeable_tlv_based_enum_legacy!(SpendableOutputDescriptor,
(0, StaticOutput) => {
(0, outpoint, required),
(1, channel_keys_id, option),
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ pub enum MaxDustHTLCExposure {
FeeRateMultiplier(u64),
}

impl_writeable_tlv_based_enum!(MaxDustHTLCExposure, ;
impl_writeable_tlv_based_enum_legacy!(MaxDustHTLCExposure, ;
(1, FixedLimitMsat),
(3, FeeRateMultiplier),
);
Expand Down
Loading
Loading