Skip to content

Commit 2a3254d

Browse files
f fail to deser if PaymentClaimable has skimmed fee present
1 parent ca5ac4c commit 2a3254d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lightning/src/events/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl Writeable for Event {
848848
// We never write out FundingGenerationReady events as, upon disconnection, peers
849849
// drop any channels which have not yet exchanged funding_signed.
850850
},
851-
&Event::PaymentClaimable { ref payment_hash, ref amount_msat, ref counterparty_skimmed_fee_msat,
851+
&Event::PaymentClaimable { ref payment_hash, ref amount_msat, counterparty_skimmed_fee_msat,
852852
ref purpose, ref receiver_node_id, ref via_channel_id, ref via_user_channel_id,
853853
ref claim_deadline, ref onion_fields
854854
} => {
@@ -864,6 +864,8 @@ impl Writeable for Event {
864864
payment_preimage = Some(*preimage);
865865
}
866866
}
867+
let skimmed_fee_opt = if counterparty_skimmed_fee_msat == 0 { None }
868+
else { Some(counterparty_skimmed_fee_msat) };
867869
write_tlv_fields!(writer, {
868870
(0, payment_hash, required),
869871
(1, receiver_node_id, option),
@@ -875,7 +877,7 @@ impl Writeable for Event {
875877
(7, claim_deadline, option),
876878
(8, payment_preimage, option),
877879
(9, onion_fields, option),
878-
(11, counterparty_skimmed_fee_msat, required),
880+
(10, skimmed_fee_opt, option),
879881
});
880882
},
881883
&Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
@@ -1093,7 +1095,7 @@ impl MaybeReadable for Event {
10931095
(7, claim_deadline, option),
10941096
(8, payment_preimage, option),
10951097
(9, onion_fields, option),
1096-
(11, counterparty_skimmed_fee_msat_opt, option),
1098+
(10, counterparty_skimmed_fee_msat_opt, option),
10971099
});
10981100
let purpose = match payment_secret {
10991101
Some(secret) => PaymentPurpose::InvoicePayment {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Backwards Compat
2+
3+
* Setting `ChannelConfig::accept_underpaying_htlcs` may break compatibility with versions of LDK
4+
prior to 0.0.116, and unsetting the feature between restarts may lead to payment failures.

0 commit comments

Comments
 (0)