You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Require RecipientOnionFields in the claimable HTLC pipeline
We added `RecipientOnionFields` in the
`ClaimablePayment`/`ClaimingPayment` structs in 0.0.115/0.0.124,
always writing them for new HTLCs. As of 0.1, we do not support
upgrading from 0.0.123 or earlier with pending HTLCs to forward or
claim. Thus, we already don't support upgrading in cases where no
`RecipientOnionFields` is set and we can thus go ahead and mark it
as non-`Option`al.
Further, there's some super ancient upgrade logic in
`ChannelManager` deserialization we can remove at the same time.
let log_keysend = |keysend| if keysend { "keysend" } else { "non-keysend" };
7962
7964
log_trace!(self.logger, "Failing new {} HTLC with payment_hash {} as we already had an existing {} HTLC with the same payment hash", log_keysend(is_keysend), &payment_hash, log_keysend(!is_keysend));
7963
7965
fail_htlc!(claimable_htlc, payment_hash);
7964
7966
}
7965
-
if let Some(earlier_fields) = &mut claimable_payment.onion_fields {
7966
-
if earlier_fields.check_merge(&mut onion_fields).is_err() {
let claimable = ClaimablePayment { purpose, htlcs, onion_fields: None };
17833
-
let existing_payment = claimable_payments.insert(payment_hash, claimable);
17834
-
if existing_payment.is_some() {
17835
-
return Err(DecodeError::InvalidValue);
17836
-
}
17837
-
}
17824
+
} else if !purposes.is_empty() || !claimable_htlcs_list.is_empty() {
17825
+
// `amountless_claimable_htlc_onion_fields` was first written in LDK 0.0.115. We no
17826
+
// haven't supported upgrade from 0.0.115 with pending HTLCs since 0.1.
17827
+
return Err(DecodeError::InvalidValue);
17838
17828
}
17839
17829
} else {
17840
17830
// LDK versions prior to 0.0.107 did not write a `pending_htlc_purposes`, but do
17841
17831
// include a `_legacy_hop_data` in the `OnionPayload`.
17842
-
for (payment_hash, htlcs) in claimable_htlcs_list.into_iter() {
17843
-
if htlcs.is_empty() {
17844
-
return Err(DecodeError::InvalidValue);
17845
-
}
17846
-
let purpose = match &htlcs[0].onion_payload {
17847
-
OnionPayload::Invoice { _legacy_hop_data } => {
17848
-
if let Some(hop_data) = _legacy_hop_data {
17849
-
events::PaymentPurpose::Bolt11InvoicePayment {
17850
-
payment_preimage: match inbound_payment::verify(
17851
-
payment_hash,
17852
-
&hop_data,
17853
-
0,
17854
-
&expanded_inbound_key,
17855
-
&args.logger,
17856
-
) {
17857
-
Ok((payment_preimage, _)) => payment_preimage,
17858
-
Err(()) => {
17859
-
log_error!(args.logger, "Failed to read claimable payment data for HTLC with payment hash {} - was not a pending inbound payment and didn't match our payment key", &payment_hash);
0 commit comments