Skip to content

Commit dad0ef2

Browse files
Move StaticInvoice outbounds out of map before converting to Retryable.
This will allow us to avoid cloning the invoice request when we move it into the new Retryable entry in the next commit.
1 parent 5f2c767 commit dad0ef2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lightning/src/ln/outbound_payment.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,19 +1315,23 @@ impl OutboundPayments {
13151315
debug_assert!(false);
13161316
return
13171317
},
1318-
PendingOutboundPayment::StaticInvoiceReceived {
1319-
payment_hash, keysend_preimage, retry_strategy, ..
1320-
} => {
1321-
let keysend_preimage = Some(*keysend_preimage);
1318+
PendingOutboundPayment::StaticInvoiceReceived { .. } => {
1319+
let (payment_hash, keysend_preimage, retry_strategy) =
1320+
if let PendingOutboundPayment::StaticInvoiceReceived {
1321+
payment_hash, keysend_preimage, retry_strategy, ..
1322+
} = payment.remove() {
1323+
(payment_hash, keysend_preimage, retry_strategy)
1324+
} else { debug_assert!(false); return };
1325+
let keysend_preimage = Some(keysend_preimage);
13221326
let total_amount = route_params.final_value_msat;
13231327
let recipient_onion = RecipientOnionFields::spontaneous_empty();
1324-
let retry_strategy = Some(*retry_strategy);
1328+
let retry_strategy = Some(retry_strategy);
13251329
let payment_params = Some(route_params.payment_params.clone());
13261330
let (retryable_payment, onion_session_privs) = self.create_pending_payment(
1327-
*payment_hash, recipient_onion.clone(), keysend_preimage, &route,
1328-
retry_strategy, payment_params, entropy_source, best_block_height
1331+
payment_hash, recipient_onion.clone(), keysend_preimage, &route, retry_strategy,
1332+
payment_params, entropy_source, best_block_height
13291333
);
1330-
*payment.into_mut() = retryable_payment;
1334+
outbounds.insert(payment_id, retryable_payment);
13311335
(total_amount, recipient_onion, keysend_preimage, onion_session_privs)
13321336
},
13331337
PendingOutboundPayment::Fulfilled { .. } => {

0 commit comments

Comments
 (0)