Skip to content

Commit df57978

Browse files
authored
Merge pull request #4373 from TheBlueMatt/2026-02-partial-mpp-payments
Support payments for less than the total MPP value
2 parents eb3980d + a28e7e6 commit df57978

31 files changed

Lines changed: 1303 additions & 683 deletions

fuzz/src/chanmon_consistency.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ fn send_payment(
613613
}],
614614
route_params: Some(route_params.clone()),
615615
};
616-
let onion = RecipientOnionFields::secret_only(payment_secret);
616+
let onion = RecipientOnionFields::secret_only(payment_secret, amt);
617617
let res = source.send_payment_with_route(route, payment_hash, onion, payment_id);
618618
match res {
619619
Err(err) => {
@@ -683,7 +683,7 @@ fn send_hop_payment(
683683
}],
684684
route_params: Some(route_params.clone()),
685685
};
686-
let onion = RecipientOnionFields::secret_only(payment_secret);
686+
let onion = RecipientOnionFields::secret_only(payment_secret, amt);
687687
let res = source.send_payment_with_route(route, payment_hash, onion, payment_id);
688688
match res {
689689
Err(err) => {
@@ -748,7 +748,7 @@ fn send_mpp_payment(
748748
amt,
749749
);
750750
let route = Route { paths, route_params: Some(route_params) };
751-
let onion = RecipientOnionFields::secret_only(payment_secret);
751+
let onion = RecipientOnionFields::secret_only(payment_secret, amt);
752752
let res = source.send_payment_with_route(route, payment_hash, onion, payment_id);
753753
match res {
754754
Err(_) => false,
@@ -844,7 +844,7 @@ fn send_mpp_hop_payment(
844844
amt,
845845
);
846846
let route = Route { paths, route_params: Some(route_params) };
847-
let onion = RecipientOnionFields::secret_only(payment_secret);
847+
let onion = RecipientOnionFields::secret_only(payment_secret, amt);
848848
let res = source.send_payment_with_route(route, payment_hash, onion, payment_id);
849849
match res {
850850
Err(_) => false,

fuzz/src/full_stack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger + MaybeSend + MaybeSync>
743743
payments_sent += 1;
744744
let _ = channelmanager.send_payment(
745745
payment_hash,
746-
RecipientOnionFields::spontaneous_empty(),
746+
RecipientOnionFields::spontaneous_empty(final_value_msat),
747747
PaymentId(payment_hash.0),
748748
params,
749749
Retry::Attempts(2),
@@ -765,7 +765,7 @@ pub fn do_test(mut data: &[u8], logger: &Arc<dyn Logger + MaybeSend + MaybeSync>
765765
payments_sent += 1;
766766
let _ = channelmanager.send_payment(
767767
payment_hash,
768-
RecipientOnionFields::secret_only(payment_secret),
768+
RecipientOnionFields::secret_only(payment_secret, final_value_msat),
769769
PaymentId(payment_hash.0),
770770
params,
771771
Retry::Attempts(2),

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6850,7 +6850,7 @@ mod tests {
68506850
// the update through to the ChannelMonitor which will refuse it (as the channel is closed).
68516851
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[1], nodes[0], 100_000);
68526852
nodes[1].node.send_payment_with_route(route, payment_hash,
6853-
RecipientOnionFields::secret_only(payment_secret), PaymentId(payment_hash.0)
6853+
RecipientOnionFields::secret_only(payment_secret, 100_000), PaymentId(payment_hash.0)
68546854
).unwrap();
68556855
check_added_monitors(&nodes[1], 1);
68566856

lightning/src/events/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ use crate::types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
4141
use crate::types::string::UntrustedString;
4242
use crate::util::errors::APIError;
4343
use crate::util::ser::{
44-
BigSize, FixedLengthReader, MaybeReadable, Readable, RequiredWrapper, UpgradableRequired,
45-
WithoutLength, Writeable, Writer,
44+
BigSize, FixedLengthReader, MaybeReadable, Readable, ReadableArgs, RequiredWrapper,
45+
UpgradableRequired, WithoutLength, Writeable, Writer,
4646
};
4747

4848
use crate::io;
@@ -2378,7 +2378,7 @@ impl MaybeReadable for Event {
23782378
(6, _user_payment_id, option),
23792379
(7, claim_deadline, option),
23802380
(8, payment_preimage, option),
2381-
(9, onion_fields, option),
2381+
(9, onion_fields, (option: ReadableArgs, amount_msat)),
23822382
(10, counterparty_skimmed_fee_msat_opt, option),
23832383
(11, payment_context, option),
23842384
(13, payment_id, option),
@@ -2710,7 +2710,8 @@ impl MaybeReadable for Event {
27102710
(4, amount_msat, required),
27112711
(5, htlcs, optional_vec),
27122712
(7, sender_intended_total_msat, option),
2713-
(9, onion_fields, option),
2713+
(9, onion_fields, (option: ReadableArgs,
2714+
sender_intended_total_msat.unwrap_or(amount_msat))),
27142715
(11, payment_id, option),
27152716
});
27162717
Ok(Some(Event::PaymentClaimed {

lightning/src/ln/accountable_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn test_accountable_forwarding_with_override(
3232
PaymentParameters::from_node_id(nodes[2].node.get_our_node_id(), TEST_FINAL_CLTV),
3333
100_000,
3434
);
35-
let onion_fields = RecipientOnionFields::secret_only(payment_secret);
35+
let onion_fields = RecipientOnionFields::secret_only(payment_secret, 100_000);
3636
let payment_id = PaymentId(payment_hash.0);
3737
nodes[0]
3838
.node

lightning/src/ln/async_payments_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ fn invalid_keysend_payment_secret() {
615615
.node
616616
.send_spontaneous_payment(
617617
Some(keysend_preimage),
618-
RecipientOnionFields::spontaneous_empty(),
618+
RecipientOnionFields::spontaneous_empty(amt_msat),
619619
PaymentId(keysend_preimage.0),
620620
route_params,
621621
Retry::Attempts(0),

lightning/src/ln/async_signer_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn do_test_async_commitment_signature_for_commitment_signed_revoke_and_ack(
296296

297297
let (route, our_payment_hash, _our_payment_preimage, our_payment_secret) =
298298
get_route_and_payment_hash!(src, dst, 8000000);
299-
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret);
299+
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret, 8000000);
300300
let payment_id = PaymentId(our_payment_hash.0);
301301
src.node
302302
.send_payment_with_route(route, our_payment_hash, recipient_fields, payment_id)
@@ -520,7 +520,7 @@ fn do_test_async_raa_peer_disconnect(
520520

521521
let (route, our_payment_hash, _our_payment_preimage, our_payment_secret) =
522522
get_route_and_payment_hash!(src, dst, 8000000);
523-
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret);
523+
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret, 8000000);
524524
let payment_id = PaymentId(our_payment_hash.0);
525525
src.node
526526
.send_payment_with_route(route, our_payment_hash, recipient_fields, payment_id)
@@ -669,7 +669,7 @@ fn do_test_async_commitment_signature_peer_disconnect(
669669

670670
let (route, our_payment_hash, _our_payment_preimage, our_payment_secret) =
671671
get_route_and_payment_hash!(src, dst, 8000000);
672-
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret);
672+
let recipient_fields = RecipientOnionFields::secret_only(our_payment_secret, 8000000);
673673
let payment_id = PaymentId(our_payment_hash.0);
674674
src.node
675675
.send_payment_with_route(route, our_payment_hash, recipient_fields, payment_id)
@@ -804,7 +804,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
804804
// to the peer.
805805
let (route, payment_hash_2, payment_preimage_2, payment_secret_2) =
806806
get_route_and_payment_hash!(nodes[0], nodes[1], 1000000);
807-
let recipient_fields = RecipientOnionFields::secret_only(payment_secret_2);
807+
let recipient_fields = RecipientOnionFields::secret_only(payment_secret_2, 1000000);
808808
let payment_id = PaymentId(payment_hash_2.0);
809809
nodes[0]
810810
.node
@@ -1343,14 +1343,14 @@ fn test_no_disconnect_while_async_revoke_and_ack_expecting_remote_commitment_sig
13431343
// We'll send a payment from both nodes to each other.
13441344
let (route1, payment_hash1, _, payment_secret1) =
13451345
get_route_and_payment_hash!(&nodes[0], &nodes[1], payment_amount);
1346-
let onion1 = RecipientOnionFields::secret_only(payment_secret1);
1346+
let onion1 = RecipientOnionFields::secret_only(payment_secret1, payment_amount);
13471347
let payment_id1 = PaymentId(payment_hash1.0);
13481348
nodes[0].node.send_payment_with_route(route1, payment_hash1, onion1, payment_id1).unwrap();
13491349
check_added_monitors(&nodes[0], 1);
13501350

13511351
let (route2, payment_hash2, _, payment_secret2) =
13521352
get_route_and_payment_hash!(&nodes[1], &nodes[0], payment_amount);
1353-
let onion2 = RecipientOnionFields::secret_only(payment_secret2);
1353+
let onion2 = RecipientOnionFields::secret_only(payment_secret2, payment_amount);
13541354
let payment_id2 = PaymentId(payment_hash2.0);
13551355
nodes[1].node.send_payment_with_route(route2, payment_hash2, onion2, payment_id2).unwrap();
13561356
check_added_monitors(&nodes[1], 1);

0 commit comments

Comments
 (0)