Skip to content

Commit f1cfa7d

Browse files
fixup: avoid doing core::mem:take on payment_queue
1 parent 695ecf9 commit f1cfa7d

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

lightning-liquidity/src/lsps2/service.rs

+18-19
Original file line numberDiff line numberDiff line change
@@ -1085,27 +1085,26 @@ where
10851085
),
10861086
})?;
10871087

1088-
let mut payment_queue =
1089-
if let OutboundJITChannelState::PendingChannelOpen { payment_queue, .. } =
1090-
&mut jit_channel.state
1091-
{
1092-
core::mem::take(payment_queue)
1093-
} else {
1094-
return Err(APIError::APIMisuseError {
1095-
err: "Channel is not in the PendingChannelOpen state.".to_string(),
1096-
});
1097-
};
1088+
if let OutboundJITChannelState::PendingChannelOpen { payment_queue, .. } =
1089+
&mut jit_channel.state
1090+
{
1091+
let intercepted_htlcs = payment_queue.clear();
1092+
for htlc in intercepted_htlcs {
1093+
self.channel_manager.get_cm().fail_htlc_backwards_with_reason(
1094+
&htlc.payment_hash,
1095+
FailureCode::TemporaryNodeFailure,
1096+
);
1097+
}
10981098

1099-
for htlc in payment_queue.clear() {
1100-
self.channel_manager.get_cm().fail_htlc_backwards_with_reason(
1101-
&htlc.payment_hash,
1102-
FailureCode::TemporaryNodeFailure,
1103-
);
1099+
jit_channel.state = OutboundJITChannelState::PendingInitialPayment {
1100+
payment_queue: PaymentQueue::new(),
1101+
};
1102+
Ok(())
1103+
} else {
1104+
Err(APIError::APIMisuseError {
1105+
err: "Channel is not in the PendingChannelOpen state.".to_string(),
1106+
})
11041107
}
1105-
1106-
jit_channel.state = OutboundJITChannelState::PendingInitialPayment { payment_queue };
1107-
1108-
Ok(())
11091108
}
11101109

11111110
/// Forward [`Event::ChannelReady`] event parameters into this function.

0 commit comments

Comments
 (0)