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" };
7974
7976
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));
7975
7977
fail_htlc!(claimable_htlc, payment_hash);
7976
7978
}
7977
-
if let Some(earlier_fields) = &mut claimable_payment.onion_fields {
7978
-
if earlier_fields.check_merge(&mut onion_fields).is_err() {
let claimable = ClaimablePayment { purpose, htlcs, onion_fields: None };
17676
-
let existing_payment = claimable_payments.insert(payment_hash, claimable);
17677
-
if existing_payment.is_some() {
17678
-
return Err(DecodeError::InvalidValue);
17679
-
}
17680
-
}
17667
+
} else if !purposes.is_empty() || !claimable_htlcs_list.is_empty() {
17668
+
// `amountless_claimable_htlc_onion_fields` was first written in LDK 0.0.115. We no
17669
+
// haven't supported upgrade from 0.0.115 with pending HTLCs since 0.1.
17670
+
return Err(DecodeError::InvalidValue);
17681
17671
}
17682
17672
} else {
17683
17673
// LDK versions prior to 0.0.107 did not write a `pending_htlc_purposes`, but do
17684
17674
// include a `_legacy_hop_data` in the `OnionPayload`.
17685
-
for (payment_hash, htlcs) in claimable_htlcs_list.into_iter() {
17686
-
if htlcs.is_empty() {
17687
-
return Err(DecodeError::InvalidValue);
17688
-
}
17689
-
let purpose = match &htlcs[0].onion_payload {
17690
-
OnionPayload::Invoice { _legacy_hop_data } => {
17691
-
if let Some(hop_data) = _legacy_hop_data {
17692
-
events::PaymentPurpose::Bolt11InvoicePayment {
17693
-
payment_preimage: match inbound_payment::verify(
17694
-
payment_hash,
17695
-
&hop_data,
17696
-
0,
17697
-
&expanded_inbound_key,
17698
-
&args.logger,
17699
-
) {
17700
-
Ok((payment_preimage, _)) => payment_preimage,
17701
-
Err(()) => {
17702
-
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