Skip to content

Commit 2e685ff

Browse files
Remove UserConfig::accept_mpp_keysend
This option was added to force users to opt into breaking compat with < 0.0.116, so it should be fine to remove for the 0.1 release. Otherwise, receiving to static invoices would always require flipping this on.
1 parent 726dd5c commit 2e685ff

File tree

6 files changed

+26
-119
lines changed

6 files changed

+26
-119
lines changed

lightning/src/ln/blinded_payment_tests.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,9 @@ fn conditionally_round_fwd_amt() {
12141214
#[test]
12151215
#[cfg(async_payments)]
12161216
fn blinded_keysend() {
1217-
let mut mpp_keysend_config = test_default_channel_config();
1218-
mpp_keysend_config.accept_mpp_keysend = true;
12191217
let chanmon_cfgs = create_chanmon_cfgs(3);
12201218
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1221-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, Some(mpp_keysend_config)]);
1219+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
12221220
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
12231221
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
12241222
let chan_upd_1_2 = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0).0.contents;
@@ -1254,11 +1252,9 @@ fn blinded_keysend() {
12541252
#[test]
12551253
#[cfg(async_payments)]
12561254
fn blinded_mpp_keysend() {
1257-
let mut mpp_keysend_config = test_default_channel_config();
1258-
mpp_keysend_config.accept_mpp_keysend = true;
12591255
let chanmon_cfgs = create_chanmon_cfgs(4);
12601256
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
1261-
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, Some(mpp_keysend_config)]);
1257+
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
12621258
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
12631259

12641260
create_announced_chan_between_nodes(&nodes, 0, 1);
@@ -1315,11 +1311,9 @@ fn blinded_mpp_keysend() {
13151311
#[test]
13161312
#[cfg(async_payments)]
13171313
fn invalid_keysend_payment_secret() {
1318-
let mut mpp_keysend_config = test_default_channel_config();
1319-
mpp_keysend_config.accept_mpp_keysend = true;
13201314
let chanmon_cfgs = create_chanmon_cfgs(3);
13211315
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
1322-
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, Some(mpp_keysend_config)]);
1316+
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
13231317
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
13241318
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
13251319
let chan_upd_1_2 = create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0).0.contents;

lightning/src/ln/channelmanager.rs

+8-71
Original file line numberDiff line numberDiff line change
@@ -4323,7 +4323,7 @@ where
43234323
let current_height: u32 = self.best_block.read().unwrap().height;
43244324
match create_recv_pending_htlc_info(next_hop_data, shared_secret, msg.payment_hash,
43254325
msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
4326-
current_height, self.default_configuration.accept_mpp_keysend)
4326+
current_height)
43274327
{
43284328
Ok(info) => {
43294329
// Note that we could obviously respond immediately with an update_fulfill_htlc
@@ -5750,7 +5750,7 @@ where
57505750
match create_recv_pending_htlc_info(hop_data,
57515751
incoming_shared_secret, payment_hash, outgoing_amt_msat,
57525752
outgoing_cltv_value, Some(phantom_shared_secret), false, None,
5753-
current_height, self.default_configuration.accept_mpp_keysend)
5753+
current_height)
57545754
{
57555755
Ok(info) => phantom_receives.push((
57565756
prev_short_channel_id, prev_counterparty_node_id, prev_funding_outpoint,
@@ -6061,10 +6061,6 @@ where
60616061
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));
60626062
fail_htlc!(claimable_htlc, payment_hash);
60636063
}
6064-
if !self.default_configuration.accept_mpp_keysend && is_keysend && !claimable_payment.htlcs.is_empty() {
6065-
log_trace!(self.logger, "Failing new keysend HTLC with payment_hash {} as we already had an existing keysend HTLC with the same payment hash and our config states we don't accept MPP keysend", &payment_hash);
6066-
fail_htlc!(claimable_htlc, payment_hash);
6067-
}
60686064
if let Some(earlier_fields) = &mut claimable_payment.onion_fields {
60696065
if earlier_fields.check_merge(&mut onion_fields).is_err() {
60706066
fail_htlc!(claimable_htlc, payment_hash);
@@ -14202,7 +14198,6 @@ where
1420214198
#[cfg(test)]
1420314199
mod tests {
1420414200
use bitcoin::hashes::Hash;
14205-
use bitcoin::hashes::sha256::Hash as Sha256;
1420614201
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
1420714202
use core::sync::atomic::Ordering;
1420814203
use crate::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, ClosureReason};
@@ -14419,26 +14414,16 @@ mod tests {
1441914414

1442014415
#[test]
1442114416
fn test_keysend_dup_payment_hash() {
14422-
do_test_keysend_dup_payment_hash(false);
14423-
do_test_keysend_dup_payment_hash(true);
14424-
}
14425-
14426-
fn do_test_keysend_dup_payment_hash(accept_mpp_keysend: bool) {
1442714417
// (1): Test that a keysend payment with a duplicate payment hash to an existing pending
1442814418
// outbound regular payment fails as expected.
1442914419
// (2): Test that a regular payment with a duplicate payment hash to an existing keysend payment
1443014420
// fails as expected.
1443114421
// (3): Test that a keysend payment with a duplicate payment hash to an existing keysend
14432-
// payment fails as expected. When `accept_mpp_keysend` is false, this tests that we
14433-
// reject MPP keysend payments, since in this case where the payment has no payment
14434-
// secret, a keysend payment with a duplicate hash is basically an MPP keysend. If
14435-
// `accept_mpp_keysend` is true, this tests that we only accept MPP keysends with
14436-
// payment secrets and reject otherwise.
14422+
// payment fails as expected. We only accept MPP keysends with payment secrets and reject
14423+
// otherwise.
1443714424
let chanmon_cfgs = create_chanmon_cfgs(2);
1443814425
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
14439-
let mut mpp_keysend_cfg = test_default_channel_config();
14440-
mpp_keysend_cfg.accept_mpp_keysend = accept_mpp_keysend;
14441-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(mpp_keysend_cfg)]);
14426+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
1444214427
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
1444314428
create_announced_chan_between_nodes(&nodes, 0, 1);
1444414429
let scorer = test_utils::TestScorer::new();
@@ -14618,53 +14603,6 @@ mod tests {
1461814603
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "Payment preimage didn't match payment hash", 1);
1461914604
}
1462014605

14621-
#[test]
14622-
fn test_keysend_msg_with_secret_err() {
14623-
// Test that we error as expected if we receive a keysend payment that includes a payment
14624-
// secret when we don't support MPP keysend.
14625-
let mut reject_mpp_keysend_cfg = test_default_channel_config();
14626-
reject_mpp_keysend_cfg.accept_mpp_keysend = false;
14627-
let chanmon_cfgs = create_chanmon_cfgs(2);
14628-
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
14629-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(reject_mpp_keysend_cfg)]);
14630-
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
14631-
14632-
let payer_pubkey = nodes[0].node.get_our_node_id();
14633-
let payee_pubkey = nodes[1].node.get_our_node_id();
14634-
14635-
let _chan = create_chan_between_nodes(&nodes[0], &nodes[1]);
14636-
let route_params = RouteParameters::from_payment_params_and_value(
14637-
PaymentParameters::for_keysend(payee_pubkey, 40, false), 10_000);
14638-
let network_graph = nodes[0].network_graph;
14639-
let first_hops = nodes[0].node.list_usable_channels();
14640-
let scorer = test_utils::TestScorer::new();
14641-
let random_seed_bytes = chanmon_cfgs[1].keys_manager.get_secure_random_bytes();
14642-
let route = find_route(
14643-
&payer_pubkey, &route_params, &network_graph, Some(&first_hops.iter().collect::<Vec<_>>()),
14644-
nodes[0].logger, &scorer, &Default::default(), &random_seed_bytes
14645-
).unwrap();
14646-
14647-
let test_preimage = PaymentPreimage([42; 32]);
14648-
let test_secret = PaymentSecret([43; 32]);
14649-
let payment_hash = PaymentHash(Sha256::hash(&test_preimage.0).to_byte_array());
14650-
let session_privs = nodes[0].node.test_add_new_pending_payment(payment_hash,
14651-
RecipientOnionFields::secret_only(test_secret), PaymentId(payment_hash.0), &route).unwrap();
14652-
nodes[0].node.test_send_payment_internal(&route, payment_hash,
14653-
RecipientOnionFields::secret_only(test_secret), Some(test_preimage),
14654-
PaymentId(payment_hash.0), None, session_privs).unwrap();
14655-
check_added_monitors!(nodes[0], 1);
14656-
14657-
let updates = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
14658-
assert_eq!(updates.update_add_htlcs.len(), 1);
14659-
assert!(updates.update_fulfill_htlcs.is_empty());
14660-
assert!(updates.update_fail_htlcs.is_empty());
14661-
assert!(updates.update_fail_malformed_htlcs.is_empty());
14662-
assert!(updates.update_fee.is_none());
14663-
nodes[1].node.handle_update_add_htlc(nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
14664-
14665-
nodes[1].logger.assert_log_contains("lightning::ln::channelmanager", "We don't support MPP keysend payments", 1);
14666-
}
14667-
1466814606
#[test]
1466914607
fn test_multi_hop_missing_secret() {
1467014608
let chanmon_cfgs = create_chanmon_cfgs(4);
@@ -15299,7 +15237,7 @@ mod tests {
1529915237
if let Err(crate::ln::channelmanager::InboundHTLCErr { err_code, .. }) =
1530015238
create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1530115239
sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat),
15302-
current_height, node[0].node.default_configuration.accept_mpp_keysend)
15240+
current_height)
1530315241
{
1530415242
assert_eq!(err_code, 19);
1530515243
} else { panic!(); }
@@ -15318,7 +15256,7 @@ mod tests {
1531815256
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
1531915257
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1532015258
sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat),
15321-
current_height, node[0].node.default_configuration.accept_mpp_keysend).is_ok());
15259+
current_height).is_ok());
1532215260
}
1532315261

1532415262
#[test]
@@ -15338,8 +15276,7 @@ mod tests {
1533815276
payment_secret: PaymentSecret([0; 32]), total_msat: 100,
1533915277
}),
1534015278
custom_tlvs: Vec::new(),
15341-
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height,
15342-
node[0].node.default_configuration.accept_mpp_keysend);
15279+
}, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None, current_height);
1534315280

1534415281
// Should not return an error as this condition:
1534515282
// https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334

lightning/src/ln/onion_payment.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub(super) fn create_fwd_pending_htlc_info(
131131
pub(super) fn create_recv_pending_htlc_info(
132132
hop_data: msgs::InboundOnionPayload, shared_secret: [u8; 32], payment_hash: PaymentHash,
133133
amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
134-
counterparty_skimmed_fee_msat: Option<u64>, current_height: u32, accept_mpp_keysend: bool,
134+
counterparty_skimmed_fee_msat: Option<u64>, current_height: u32
135135
) -> Result<PendingHTLCInfo, InboundHTLCErr> {
136136
let (
137137
payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, onion_cltv_expiry,
@@ -227,13 +227,6 @@ pub(super) fn create_recv_pending_htlc_info(
227227
msg: "Payment preimage didn't match payment hash",
228228
});
229229
}
230-
if !accept_mpp_keysend && payment_data.is_some() {
231-
return Err(InboundHTLCErr {
232-
err_code: 0x4000|22,
233-
err_data: Vec::new(),
234-
msg: "We don't support MPP keysend payments",
235-
});
236-
}
237230
PendingHTLCRouting::ReceiveKeysend {
238231
payment_data,
239232
payment_preimage,
@@ -282,7 +275,7 @@ pub(super) fn create_recv_pending_htlc_info(
282275
/// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
283276
pub fn peel_payment_onion<NS: Deref, L: Deref, T: secp256k1::Verification>(
284277
msg: &msgs::UpdateAddHTLC, node_signer: NS, logger: L, secp_ctx: &Secp256k1<T>,
285-
cur_height: u32, accept_mpp_keysend: bool, allow_skimmed_fees: bool,
278+
cur_height: u32, allow_skimmed_fees: bool,
286279
) -> Result<PendingHTLCInfo, InboundHTLCErr>
287280
where
288281
NS::Target: NodeSigner,
@@ -333,7 +326,7 @@ where
333326
onion_utils::Hop::Receive(received_data) => {
334327
create_recv_pending_htlc_info(
335328
received_data, shared_secret, msg.payment_hash, msg.amount_msat, msg.cltv_expiry,
336-
None, allow_skimmed_fees, msg.skimmed_fee_msat, cur_height, accept_mpp_keysend,
329+
None, allow_skimmed_fees, msg.skimmed_fee_msat, cur_height
337330
)?
338331
}
339332
})
@@ -576,7 +569,7 @@ mod tests {
576569
let msg = make_update_add_msg(amount_msat, cltv_expiry, payment_hash, onion);
577570
let logger = test_utils::TestLogger::with_id("bob".to_string());
578571

579-
let peeled = peel_payment_onion(&msg, &bob, &logger, &secp_ctx, cur_height, true, false)
572+
let peeled = peel_payment_onion(&msg, &bob, &logger, &secp_ctx, cur_height, false)
580573
.map_err(|e| e.msg).unwrap();
581574

582575
let next_onion = match peeled.routing {
@@ -587,7 +580,7 @@ mod tests {
587580
};
588581

589582
let msg2 = make_update_add_msg(amount_msat, cltv_expiry, payment_hash, next_onion);
590-
let peeled2 = peel_payment_onion(&msg2, &charlie, &logger, &secp_ctx, cur_height, true, false)
583+
let peeled2 = peel_payment_onion(&msg2, &charlie, &logger, &secp_ctx, cur_height, false)
591584
.map_err(|e| e.msg).unwrap();
592585

593586
match peeled2.routing {

lightning/src/ln/payment_tests.rs

+7-14
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ fn do_test_keysend_payments(public_node: bool, with_retry: bool) {
432432

433433
#[test]
434434
fn test_mpp_keysend() {
435-
let mut mpp_keysend_config = test_default_channel_config();
436-
mpp_keysend_config.accept_mpp_keysend = true;
437435
let chanmon_cfgs = create_chanmon_cfgs(4);
438436
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
439-
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, Some(mpp_keysend_config)]);
437+
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
440438
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
441439

442440
create_announced_chan_between_nodes(&nodes, 0, 1);
@@ -478,19 +476,14 @@ fn test_mpp_keysend() {
478476
}
479477

480478
#[test]
481-
fn test_reject_mpp_keysend_htlc() {
482-
// This test enforces that we reject MPP keysend HTLCs if our config states we don't support
483-
// MPP keysend. When receiving a payment, if we don't support MPP keysend we'll reject the
484-
// payment if it's keysend and has a payment secret, never reaching our payment validation
485-
// logic. To check that we enforce rejecting MPP keysends in our payment logic, here we send
479+
fn test_reject_mpp_keysend_htlc_mismatching_secret() {
480+
// This test enforces that we reject MPP keysend HTLCs if the payment_secrets between MPP parts
481+
// don't match. To check that we enforce rejecting MPP keysends in our payment logic, here we send
486482
// keysend payments without payment secrets, then modify them by adding payment secrets in the
487483
// final node in between receiving the HTLCs and actually processing them.
488-
let mut reject_mpp_keysend_cfg = test_default_channel_config();
489-
reject_mpp_keysend_cfg.accept_mpp_keysend = false;
490-
491484
let chanmon_cfgs = create_chanmon_cfgs(4);
492485
let node_cfgs = create_node_cfgs(4, &chanmon_cfgs);
493-
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, Some(reject_mpp_keysend_cfg)]);
486+
let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]);
494487
let nodes = create_network(4, &node_cfgs, &node_chanmgrs);
495488
let chan_1_id = create_announced_chan_between_nodes(&nodes, 0, 1).0.contents.short_channel_id;
496489
let chan_2_id = create_announced_chan_between_nodes(&nodes, 0, 2).0.contents.short_channel_id;
@@ -571,7 +564,7 @@ fn test_reject_mpp_keysend_htlc() {
571564
match forward_info.routing {
572565
PendingHTLCRouting::ReceiveKeysend { ref mut payment_data, .. } => {
573566
*payment_data = Some(msgs::FinalOnionHopData {
574-
payment_secret: PaymentSecret([42; 32]),
567+
payment_secret: PaymentSecret([43; 32]), // Doesn't match the secret used above
575568
total_msat: amount * 2,
576569
});
577570
},
@@ -4282,7 +4275,7 @@ fn peel_payment_onion_custom_tlvs() {
42824275
};
42834276
let peeled_onion = crate::ln::onion_payment::peel_payment_onion(
42844277
&update_add, &chanmon_cfgs[1].keys_manager, &chanmon_cfgs[1].logger, &secp_ctx,
4285-
nodes[1].best_block_info().1, true, false
4278+
nodes[1].best_block_info().1, false
42864279
).unwrap();
42874280
assert_eq!(peeled_onion.incoming_amt_msat, Some(amt_msat));
42884281
match peeled_onion.routing {

lightning/src/util/config.rs

-13
Original file line numberDiff line numberDiff line change
@@ -844,17 +844,6 @@ pub struct UserConfig {
844844
/// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
845845
/// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
846846
pub accept_intercept_htlcs: bool,
847-
/// If this is set to `false`, when receiving a keysend payment we'll fail it if it has multiple
848-
/// parts. If this is set to `true`, we'll accept the payment.
849-
///
850-
/// Setting this to `true` will break backwards compatibility upon downgrading to an LDK
851-
/// version prior to 0.0.116 while receiving an MPP keysend. If we have already received an MPP
852-
/// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`].
853-
///
854-
/// Default value: `false`
855-
///
856-
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
857-
pub accept_mpp_keysend: bool,
858847
/// If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received.
859848
///
860849
/// When set to `true`, [`Event::InvoiceReceived`] will be generated for each received
@@ -881,7 +870,6 @@ impl Default for UserConfig {
881870
accept_inbound_channels: true,
882871
manually_accept_inbound_channels: false,
883872
accept_intercept_htlcs: false,
884-
accept_mpp_keysend: false,
885873
manually_handle_bolt12_invoices: false,
886874
}
887875
}
@@ -901,7 +889,6 @@ impl Readable for UserConfig {
901889
accept_inbound_channels: Readable::read(reader)?,
902890
manually_accept_inbound_channels: Readable::read(reader)?,
903891
accept_intercept_htlcs: Readable::read(reader)?,
904-
accept_mpp_keysend: Readable::read(reader)?,
905892
manually_handle_bolt12_invoices: Readable::read(reader)?,
906893
})
907894
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Backwards Compatibility
2+
* The presence of pending inbound MPP keysend payments breaks downgrades to LDK versions 0.0.115 and
3+
earlier.

0 commit comments

Comments
 (0)