@@ -35,7 +35,7 @@ use crate::ln::interactivetxs::{
35
35
TX_COMMON_FIELDS_WEIGHT,
36
36
};
37
37
use crate::ln::msgs;
38
- use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
38
+ use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket };
39
39
use crate::ln::script::{self, ShutdownScript};
40
40
use crate::ln::channel_state::{ChannelShutdownState, CounterpartyForwardingInfo, InboundHTLCDetails, InboundHTLCStateDetails, OutboundHTLCDetails, OutboundHTLCStateDetails};
41
41
use crate::ln::channelmanager::{self, OpenChannelMessage, PendingHTLCStatus, HTLCSource, SentHTLCId, HTLCFailureMsg, PendingHTLCInfo, RAACommitmentOrder, PaymentClaimDetails, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA, MAX_LOCAL_BREAKDOWN_TIMEOUT};
@@ -50,7 +50,7 @@ use crate::ln::chan_utils::{
50
50
#[cfg(splicing)]
51
51
use crate::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
52
52
use crate::ln::chan_utils;
53
- use crate::ln::onion_utils::HTLCFailReason;
53
+ use crate::ln::onion_utils::{ HTLCFailReason} ;
54
54
use crate::chain::BestBlock;
55
55
use crate::chain::chaininterface::{FeeEstimator, ConfirmationTarget, LowerBoundedFeeEstimator, fee_for_weight};
56
56
use crate::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
@@ -4933,7 +4933,7 @@ trait FailHTLCContents {
4933
4933
impl FailHTLCContents for msgs::OnionErrorPacket {
4934
4934
type Message = msgs::UpdateFailHTLC;
4935
4935
fn to_message(self, htlc_id: u64, channel_id: ChannelId) -> Self::Message {
4936
- msgs::UpdateFailHTLC { htlc_id, channel_id, reason: self }
4936
+ msgs::UpdateFailHTLC { htlc_id, channel_id, reason: self.data }
4937
4937
}
4938
4938
fn to_inbound_htlc_state(self) -> InboundHTLCState {
4939
4939
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(self))
@@ -6136,7 +6136,7 @@ impl<SP: Deref> FundedChannel<SP> where
6136
6136
require_commitment = true;
6137
6137
match fail_msg {
6138
6138
HTLCFailureMsg::Relay(msg) => {
6139
- htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(msg.reason. clone()));
6139
+ htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(msg.clone().into ()));
6140
6140
update_fail_htlcs.push(msg)
6141
6141
},
6142
6142
HTLCFailureMsg::Malformed(msg) => {
@@ -6844,7 +6844,7 @@ impl<SP: Deref> FundedChannel<SP> where
6844
6844
update_fail_htlcs.push(msgs::UpdateFailHTLC {
6845
6845
channel_id: self.context.channel_id(),
6846
6846
htlc_id: htlc.htlc_id,
6847
- reason: err_packet.clone()
6847
+ reason: err_packet.data. clone(),
6848
6848
});
6849
6849
},
6850
6850
&InboundHTLCRemovalReason::FailMalformed((ref sha256_of_onion, ref failure_code)) => {
@@ -10142,11 +10142,6 @@ fn get_initial_channel_type(config: &UserConfig, their_features: &InitFeatures)
10142
10142
const SERIALIZATION_VERSION: u8 = 4;
10143
10143
const MIN_SERIALIZATION_VERSION: u8 = 4;
10144
10144
10145
- impl_writeable_tlv_based_enum_legacy!(InboundHTLCRemovalReason,;
10146
- (0, FailRelay),
10147
- (1, FailMalformed),
10148
- (2, Fulfill),
10149
- );
10150
10145
10151
10146
impl Writeable for ChannelUpdateStatus {
10152
10147
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
@@ -10276,7 +10271,20 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10276
10271
},
10277
10272
&InboundHTLCState::LocalRemoved(ref removal_reason) => {
10278
10273
4u8.write(writer)?;
10279
- removal_reason.write(writer)?;
10274
+ match removal_reason {
10275
+ InboundHTLCRemovalReason::FailRelay(msgs::OnionErrorPacket { data }) => {
10276
+ 0u8.write(writer)?;
10277
+ data.write(writer)?;
10278
+ },
10279
+ InboundHTLCRemovalReason::FailMalformed((hash, code)) => {
10280
+ 1u8.write(writer)?;
10281
+ (hash, code).write(writer)?;
10282
+ },
10283
+ InboundHTLCRemovalReason::Fulfill(preimage) => {
10284
+ 2u8.write(writer)?;
10285
+ preimage.write(writer)?;
10286
+ },
10287
+ }
10280
10288
},
10281
10289
}
10282
10290
}
@@ -10355,7 +10363,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10355
10363
&HTLCUpdateAwaitingACK::FailHTLC { ref htlc_id, ref err_packet } => {
10356
10364
2u8.write(writer)?;
10357
10365
htlc_id.write(writer)?;
10358
- err_packet.write(writer)?;
10366
+ err_packet.data. write(writer)?;
10359
10367
}
10360
10368
&HTLCUpdateAwaitingACK::FailMalformedHTLC {
10361
10369
htlc_id, failure_code, sha256_of_onion
@@ -10364,10 +10372,9 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10364
10372
// `::FailHTLC` variant and write the real malformed error as an optional TLV.
10365
10373
malformed_htlcs.push((htlc_id, failure_code, sha256_of_onion));
10366
10374
10367
- let dummy_err_packet = msgs::OnionErrorPacket { data: Vec::new() };
10368
10375
2u8.write(writer)?;
10369
10376
htlc_id.write(writer)?;
10370
- dummy_err_packet .write(writer)?;
10377
+ Vec::<u8>::new() .write(writer)?;
10371
10378
}
10372
10379
}
10373
10380
}
@@ -10613,7 +10620,17 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10613
10620
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(resolution)
10614
10621
},
10615
10622
3 => InboundHTLCState::Committed,
10616
- 4 => InboundHTLCState::LocalRemoved(Readable::read(reader)?),
10623
+ 4 => {
10624
+ let reason = match <u8 as Readable>::read(reader)? {
10625
+ 0 => InboundHTLCRemovalReason::FailRelay(msgs::OnionErrorPacket {
10626
+ data: Readable::read(reader)?,
10627
+ }),
10628
+ 1 => InboundHTLCRemovalReason::FailMalformed(Readable::read(reader)?),
10629
+ 2 => InboundHTLCRemovalReason::Fulfill(Readable::read(reader)?),
10630
+ _ => return Err(DecodeError::InvalidValue),
10631
+ };
10632
+ InboundHTLCState::LocalRemoved(reason)
10633
+ },
10617
10634
_ => return Err(DecodeError::InvalidValue),
10618
10635
},
10619
10636
});
@@ -10669,7 +10686,9 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10669
10686
},
10670
10687
2 => HTLCUpdateAwaitingACK::FailHTLC {
10671
10688
htlc_id: Readable::read(reader)?,
10672
- err_packet: Readable::read(reader)?,
10689
+ err_packet: OnionErrorPacket {
10690
+ data: Readable::read(reader)?,
10691
+ },
10673
10692
},
10674
10693
_ => return Err(DecodeError::InvalidValue),
10675
10694
});
0 commit comments