@@ -36,7 +36,7 @@ use crate::ln::interactivetxs::{
36
36
TX_COMMON_FIELDS_WEIGHT,
37
37
};
38
38
use crate::ln::msgs;
39
- use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
39
+ use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket };
40
40
use crate::ln::script::{self, ShutdownScript};
41
41
use crate::ln::channel_state::{ChannelShutdownState, CounterpartyForwardingInfo, InboundHTLCDetails, InboundHTLCStateDetails, OutboundHTLCDetails, OutboundHTLCStateDetails};
42
42
use crate::ln::channelmanager::{self, OpenChannelMessage, PendingHTLCStatus, HTLCSource, SentHTLCId, HTLCFailureMsg, PendingHTLCInfo, RAACommitmentOrder, PaymentClaimDetails, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA, MAX_LOCAL_BREAKDOWN_TIMEOUT};
@@ -49,7 +49,7 @@ use crate::ln::chan_utils::{
49
49
ClosingTransaction, commit_tx_fee_sat,
50
50
};
51
51
use crate::ln::chan_utils;
52
- use crate::ln::onion_utils::HTLCFailReason;
52
+ use crate::ln::onion_utils::{ HTLCFailReason} ;
53
53
use crate::chain::BestBlock;
54
54
use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, LowerBoundedFeeEstimator, fee_for_weight};
55
55
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
@@ -4856,7 +4856,7 @@ trait FailHTLCContents {
4856
4856
impl FailHTLCContents for msgs::OnionErrorPacket {
4857
4857
type Message = msgs::UpdateFailHTLC;
4858
4858
fn to_message(self, htlc_id: u64, channel_id: ChannelId) -> Self::Message {
4859
- msgs::UpdateFailHTLC { htlc_id, channel_id, reason: self }
4859
+ msgs::UpdateFailHTLC { htlc_id, channel_id, reason: self.data }
4860
4860
}
4861
4861
fn to_inbound_htlc_state(self) -> InboundHTLCState {
4862
4862
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(self))
@@ -6070,7 +6070,7 @@ impl<SP: Deref> FundedChannel<SP> where
6070
6070
require_commitment = true;
6071
6071
match fail_msg {
6072
6072
HTLCFailureMsg::Relay(msg) => {
6073
- htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(msg.reason.clone ()));
6073
+ htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay((& msg).into ()));
6074
6074
update_fail_htlcs.push(msg)
6075
6075
},
6076
6076
HTLCFailureMsg::Malformed(msg) => {
@@ -6778,7 +6778,7 @@ impl<SP: Deref> FundedChannel<SP> where
6778
6778
update_fail_htlcs.push(msgs::UpdateFailHTLC {
6779
6779
channel_id: self.context.channel_id(),
6780
6780
htlc_id: htlc.htlc_id,
6781
- reason: err_packet.clone()
6781
+ reason: err_packet.data. clone(),
6782
6782
});
6783
6783
},
6784
6784
&InboundHTLCRemovalReason::FailMalformed((ref sha256_of_onion, ref failure_code)) => {
@@ -9932,11 +9932,6 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
9932
9932
const SERIALIZATION_VERSION: u8 = 4;
9933
9933
const MIN_SERIALIZATION_VERSION: u8 = 4;
9934
9934
9935
- impl_writeable_tlv_based_enum_legacy!(InboundHTLCRemovalReason,;
9936
- (0, FailRelay),
9937
- (1, FailMalformed),
9938
- (2, Fulfill),
9939
- );
9940
9935
9941
9936
impl Writeable for ChannelUpdateStatus {
9942
9937
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
@@ -10066,7 +10061,20 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10066
10061
},
10067
10062
&InboundHTLCState::LocalRemoved(ref removal_reason) => {
10068
10063
4u8.write(writer)?;
10069
- removal_reason.write(writer)?;
10064
+ match removal_reason {
10065
+ InboundHTLCRemovalReason::FailRelay(msgs::OnionErrorPacket { data }) => {
10066
+ 0u8.write(writer)?;
10067
+ data.write(writer)?;
10068
+ },
10069
+ InboundHTLCRemovalReason::FailMalformed((hash, code)) => {
10070
+ 1u8.write(writer)?;
10071
+ (hash, code).write(writer)?;
10072
+ },
10073
+ InboundHTLCRemovalReason::Fulfill(preimage) => {
10074
+ 2u8.write(writer)?;
10075
+ preimage.write(writer)?;
10076
+ },
10077
+ }
10070
10078
},
10071
10079
}
10072
10080
}
@@ -10145,7 +10153,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10145
10153
&HTLCUpdateAwaitingACK::FailHTLC { ref htlc_id, ref err_packet } => {
10146
10154
2u8.write(writer)?;
10147
10155
htlc_id.write(writer)?;
10148
- err_packet.write(writer)?;
10156
+ err_packet.data. write(writer)?;
10149
10157
}
10150
10158
&HTLCUpdateAwaitingACK::FailMalformedHTLC {
10151
10159
htlc_id, failure_code, sha256_of_onion
@@ -10154,10 +10162,9 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10154
10162
// `::FailHTLC` variant and write the real malformed error as an optional TLV.
10155
10163
malformed_htlcs.push((htlc_id, failure_code, sha256_of_onion));
10156
10164
10157
- let dummy_err_packet = msgs::OnionErrorPacket { data: Vec::new() };
10158
10165
2u8.write(writer)?;
10159
10166
htlc_id.write(writer)?;
10160
- dummy_err_packet .write(writer)?;
10167
+ Vec::<u8>::new() .write(writer)?;
10161
10168
}
10162
10169
}
10163
10170
}
@@ -10403,7 +10410,17 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10403
10410
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(resolution)
10404
10411
},
10405
10412
3 => InboundHTLCState::Committed,
10406
- 4 => InboundHTLCState::LocalRemoved(Readable::read(reader)?),
10413
+ 4 => {
10414
+ let reason = match <u8 as Readable>::read(reader)? {
10415
+ 0 => InboundHTLCRemovalReason::FailRelay(msgs::OnionErrorPacket {
10416
+ data: Readable::read(reader)?,
10417
+ }),
10418
+ 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
10419
+ 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?),
10420
+ _ => return Err(DecodeError::InvalidValue),
10421
+ };
10422
+ InboundHTLCState::LocalRemoved(reason)
10423
+ },
10407
10424
_ => return Err(DecodeError::InvalidValue),
10408
10425
},
10409
10426
});
@@ -10459,7 +10476,9 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10459
10476
},
10460
10477
2 => HTLCUpdateAwaitingACK::FailHTLC {
10461
10478
htlc_id: Readable::read(reader)?,
10462
- err_packet: Readable::read(reader)?,
10479
+ err_packet: OnionErrorPacket {
10480
+ data: Readable::read(reader)?,
10481
+ },
10463
10482
},
10464
10483
_ => return Err(DecodeError::InvalidValue),
10465
10484
});
0 commit comments