Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 3278b18

Browse files
committed
Remove max invoice fee
1 parent 0214f3f commit 3278b18

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

mutiny-core/src/node.rs

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use lightning::{
6565
};
6666
use lightning_invoice::payment::PaymentError;
6767
use lightning_invoice::{
68-
payment::{pay_invoice, pay_zero_value_invoice},
6968
utils::{create_invoice_from_channelmanager_and_duration_since_epoch, create_phantom_invoice},
7069
Bolt11Invoice,
7170
};
@@ -1120,27 +1119,19 @@ impl<S: MutinyStorage> Node<S> {
11201119
if amt_sats.is_none() {
11211120
return Err(MutinyError::InvoiceInvalid);
11221121
}
1123-
let amt_msats = amt_sats.unwrap() * 1_000;
1122+
let amount_msats = amt_sats.unwrap() * 1_000;
11241123
(
1125-
pay_zero_value_invoice(
1126-
invoice,
1127-
amt_msats,
1128-
Self::retry_strategy(),
1129-
self.channel_manager.as_ref(),
1130-
),
1131-
amt_msats,
1124+
self.pay_invoice_internal(invoice, amount_msats),
1125+
amount_msats,
11321126
)
11331127
} else {
11341128
if amt_sats.is_some() {
11351129
return Err(MutinyError::InvoiceInvalid);
11361130
}
1131+
let amount_msats = invoice.amount_milli_satoshis().unwrap();
11371132
(
1138-
pay_invoice(
1139-
invoice,
1140-
Self::retry_strategy(),
1141-
self.channel_manager.as_ref(),
1142-
),
1143-
invoice.amount_milli_satoshis().unwrap(),
1133+
self.pay_invoice_internal(invoice, amount_msats),
1134+
amount_msats,
11441135
)
11451136
};
11461137

@@ -1209,6 +1200,46 @@ impl<S: MutinyStorage> Node<S> {
12091200
}
12101201
}
12111202

1203+
// copied from LDK, modified to change a couple params
1204+
fn pay_invoice_internal(
1205+
&self,
1206+
invoice: &Bolt11Invoice,
1207+
amount_msats: u64,
1208+
) -> Result<PaymentId, PaymentError> {
1209+
let payment_id = PaymentId(invoice.payment_hash().into_inner());
1210+
let payment_hash = PaymentHash((*invoice.payment_hash()).into_inner());
1211+
let mut recipient_onion = RecipientOnionFields::secret_only(*invoice.payment_secret());
1212+
recipient_onion.payment_metadata = invoice.payment_metadata().cloned();
1213+
let mut payment_params = PaymentParameters::from_node_id(
1214+
invoice.recover_payee_pub_key(),
1215+
invoice.min_final_cltv_expiry_delta() as u32,
1216+
)
1217+
.with_expiry_time(invoice.expires_at().unwrap().as_secs())
1218+
.with_route_hints(invoice.route_hints())
1219+
.unwrap();
1220+
if let Some(features) = invoice.features() {
1221+
payment_params = payment_params
1222+
.with_bolt11_features(features.clone())
1223+
.unwrap();
1224+
}
1225+
let route_params = RouteParameters {
1226+
payment_params,
1227+
final_value_msat: amount_msats,
1228+
max_total_routing_fee_msat: None, // main change from LDK, we just want payment to succeed
1229+
};
1230+
1231+
match self.channel_manager.as_ref().send_payment(
1232+
payment_hash,
1233+
recipient_onion,
1234+
payment_id,
1235+
route_params,
1236+
Self::retry_strategy(),
1237+
) {
1238+
Ok(()) => Ok(payment_id),
1239+
Err(e) => Err(PaymentError::Sending(e)),
1240+
}
1241+
}
1242+
12121243
async fn await_payment(
12131244
&self,
12141245
payment_id: PaymentId,
@@ -1283,8 +1314,7 @@ impl<S: MutinyStorage> Node<S> {
12831314

12841315
let amt_msats = amt_sats * 1000;
12851316

1286-
// TODO retry with allow_mpp false just in case recipient does not support
1287-
let payment_params = PaymentParameters::for_keysend(to_node, 40, true);
1317+
let payment_params = PaymentParameters::for_keysend(to_node, 40, false);
12881318
let route_params: RouteParameters = RouteParameters {
12891319
final_value_msat: amt_msats,
12901320
payment_params,

0 commit comments

Comments
 (0)