Skip to content

Commit 2fbaf96

Browse files
committed
Rustfmt get_counterparty_output_claim_info
We plan to rework this method in the following commit, so we start by formatting it first.
1 parent faf7b8a commit 2fbaf96

File tree

1 file changed

+41
-16
lines changed

1 file changed

+41
-16
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4733,7 +4733,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47334733
}
47344734

47354735
/// Returns the HTLC claim package templates and the counterparty output info
4736-
#[rustfmt::skip]
47374736
fn get_counterparty_output_claim_info(
47384737
&self, funding_spent: &FundingScope, commitment_number: u64, commitment_txid: Txid,
47394738
tx: Option<&Transaction>,
@@ -4767,13 +4766,23 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47674766

47684767
if let Some(transaction) = tx {
47694768
let revocation_pubkey = RevocationKey::from_basepoint(
4770-
&self.onchain_tx_handler.secp_ctx, &self.holder_revocation_basepoint, &per_commitment_point);
4769+
&self.onchain_tx_handler.secp_ctx,
4770+
&self.holder_revocation_basepoint,
4771+
&per_commitment_point,
4772+
);
47714773

4772-
let delayed_key = DelayedPaymentKey::from_basepoint(&self.onchain_tx_handler.secp_ctx, &self.counterparty_commitment_params.counterparty_delayed_payment_base_key, &per_commitment_point);
4774+
let delayed_key = DelayedPaymentKey::from_basepoint(
4775+
&self.onchain_tx_handler.secp_ctx,
4776+
&self.counterparty_commitment_params.counterparty_delayed_payment_base_key,
4777+
&per_commitment_point,
4778+
);
47734779

4774-
let revokeable_p2wsh = chan_utils::get_revokeable_redeemscript(&revocation_pubkey,
4780+
let revokeable_p2wsh = chan_utils::get_revokeable_redeemscript(
4781+
&revocation_pubkey,
47754782
self.counterparty_commitment_params.on_counterparty_tx_csv,
4776-
&delayed_key).to_p2wsh();
4783+
&delayed_key,
4784+
)
4785+
.to_p2wsh();
47774786
for (idx, outp) in transaction.output.iter().enumerate() {
47784787
if outp.script_pubkey == revokeable_p2wsh {
47794788
to_counterparty_output_info =
@@ -4782,25 +4791,36 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47824791
}
47834792
}
47844793

4785-
for &(ref htlc, _) in per_commitment_claimable_data.iter() {
4794+
for &(ref htlc, _) in per_commitment_claimable_data.iter() {
47864795
if let Some(transaction_output_index) = htlc.transaction_output_index {
47874796
if let Some(transaction) = tx {
4788-
if transaction_output_index as usize >= transaction.output.len() ||
4789-
transaction.output[transaction_output_index as usize].value != htlc.to_bitcoin_amount() {
4790-
// per_commitment_data is corrupt or our commitment signing key leaked!
4791-
return (claimable_outpoints, to_counterparty_output_info);
4792-
}
4797+
if transaction_output_index as usize >= transaction.output.len()
4798+
|| transaction.output[transaction_output_index as usize].value
4799+
!= htlc.to_bitcoin_amount()
4800+
{
4801+
// per_commitment_data is corrupt or our commitment signing key leaked!
4802+
return (claimable_outpoints, to_counterparty_output_info);
4803+
}
47934804
}
4794-
let preimage = if htlc.offered { if let Some((p, _)) = self.payment_preimages.get(&htlc.payment_hash) { Some(*p) } else { None } } else { None };
4805+
let preimage = if htlc.offered {
4806+
if let Some((p, _)) = self.payment_preimages.get(&htlc.payment_hash) {
4807+
Some(*p)
4808+
} else {
4809+
None
4810+
}
4811+
} else {
4812+
None
4813+
};
47954814
if preimage.is_some() || !htlc.offered {
47964815
let counterparty_htlc_outp = if htlc.offered {
47974816
PackageSolvingData::CounterpartyOfferedHTLCOutput(
47984817
CounterpartyOfferedHTLCOutput::build(
4799-
*per_commitment_point, preimage.unwrap(),
4818+
*per_commitment_point,
4819+
preimage.unwrap(),
48004820
htlc.clone(),
48014821
funding_spent.channel_parameters.clone(),
48024822
confirmation_height,
4803-
)
4823+
),
48044824
)
48054825
} else {
48064826
PackageSolvingData::CounterpartyReceivedHTLCOutput(
@@ -4809,10 +4829,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
48094829
htlc.clone(),
48104830
funding_spent.channel_parameters.clone(),
48114831
confirmation_height,
4812-
)
4832+
),
48134833
)
48144834
};
4815-
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, counterparty_htlc_outp, htlc.cltv_expiry);
4835+
let counterparty_package = PackageTemplate::build_package(
4836+
commitment_txid,
4837+
transaction_output_index,
4838+
counterparty_htlc_outp,
4839+
htlc.cltv_expiry,
4840+
);
48164841
claimable_outpoints.push(counterparty_package);
48174842
}
48184843
}

0 commit comments

Comments
 (0)