Skip to content

Commit 0987b32

Browse files
committed
Pass FailureCode to fail_htlc_backwards by ownership
`FaliureCode` is a trivial enum with no body, so we shouldn't be passing it by reference. Its sufficiently strange that the Java bindings aren't happy with it, which is fine, we should just fix it here.
1 parent 6ddf69c commit 0987b32

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,14 +3653,14 @@ where
36533653
/// [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
36543654
/// startup during which time claims that were in-progress at shutdown may be replayed.
36553655
pub fn fail_htlc_backwards(&self, payment_hash: &PaymentHash) {
3656-
self.fail_htlc_backwards_with_reason(payment_hash, &FailureCode::IncorrectOrUnknownPaymentDetails);
3656+
self.fail_htlc_backwards_with_reason(payment_hash, FailureCode::IncorrectOrUnknownPaymentDetails);
36573657
}
36583658

36593659
/// This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
36603660
/// reason for the failure.
36613661
///
36623662
/// See [`FailureCode`] for valid failure codes.
3663-
pub fn fail_htlc_backwards_with_reason(&self, payment_hash: &PaymentHash, failure_code: &FailureCode) {
3663+
pub fn fail_htlc_backwards_with_reason(&self, payment_hash: &PaymentHash, failure_code: FailureCode) {
36643664
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
36653665

36663666
let removed_source = self.claimable_payments.lock().unwrap().claimable_htlcs.remove(payment_hash);
@@ -3675,14 +3675,14 @@ where
36753675
}
36763676

36773677
/// Gets error data to form an [`HTLCFailReason`] given a [`FailureCode`] and [`ClaimableHTLC`].
3678-
fn get_htlc_fail_reason_from_failure_code(&self, failure_code: &FailureCode, htlc: &ClaimableHTLC) -> HTLCFailReason {
3678+
fn get_htlc_fail_reason_from_failure_code(&self, failure_code: FailureCode, htlc: &ClaimableHTLC) -> HTLCFailReason {
36793679
match failure_code {
3680-
FailureCode::TemporaryNodeFailure => HTLCFailReason::from_failure_code(*failure_code as u16),
3681-
FailureCode::RequiredNodeFeatureMissing => HTLCFailReason::from_failure_code(*failure_code as u16),
3680+
FailureCode::TemporaryNodeFailure => HTLCFailReason::from_failure_code(failure_code as u16),
3681+
FailureCode::RequiredNodeFeatureMissing => HTLCFailReason::from_failure_code(failure_code as u16),
36823682
FailureCode::IncorrectOrUnknownPaymentDetails => {
36833683
let mut htlc_msat_height_data = htlc.value.to_be_bytes().to_vec();
36843684
htlc_msat_height_data.extend_from_slice(&self.best_block.read().unwrap().height().to_be_bytes());
3685-
HTLCFailReason::reason(*failure_code as u16, htlc_msat_height_data)
3685+
HTLCFailReason::reason(failure_code as u16, htlc_msat_height_data)
36863686
}
36873687
}
36883688
}

lightning/src/ln/onion_route_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ fn do_test_fail_htlc_backwards_with_reason(failure_code: FailureCode) {
848848

849849
expect_pending_htlcs_forwardable!(nodes[1]);
850850
expect_payment_claimable!(nodes[1], payment_hash, payment_secret, payment_amount);
851-
nodes[1].node.fail_htlc_backwards_with_reason(&payment_hash, &failure_code);
851+
nodes[1].node.fail_htlc_backwards_with_reason(&payment_hash, failure_code);
852852

853853
expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::FailedPayment { payment_hash: payment_hash }]);
854854
check_added_monitors!(nodes[1], 1);

0 commit comments

Comments
 (0)