Skip to content

Commit a79c5de

Browse files
committed
cargo fmt
1 parent c5a7ab5 commit a79c5de

7 files changed

Lines changed: 118 additions & 57 deletions

File tree

lightning/src/chain/chainmonitor.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,9 @@ where
565565
};
566566

567567
let has_pending_claims = monitor_state.monitor.has_pending_claims();
568-
if has_pending_claims || get_partition_key(channel_id).is_some_and(|key| key % partition_factor == 0) {
568+
if has_pending_claims
569+
|| get_partition_key(channel_id).is_some_and(|key| key % partition_factor == 0)
570+
{
569571
log_trace!(logger, "Syncing Channel Monitor");
570572
// Even though we don't track monitor updates from chain-sync as pending, we still want
571573
// updates per-channel to be well-ordered so that users don't see a

lightning/src/ln/channel.rs

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,32 +3917,33 @@ impl<SP: SignerProvider> ChannelContext<SP> {
39173917
debug_assert!(our_funding_satoshis == 0 || msg_push_msat == 0);
39183918
let value_to_self_msat = our_funding_satoshis * 1000 + msg_push_msat;
39193919

3920-
let counterparty_shutdown_scriptpubkey =
3921-
if their_features.supports_upfront_shutdown_script() {
3922-
match &open_channel_fields.shutdown_scriptpubkey {
3923-
&Some(ref script) => {
3924-
// Peer is signaling upfront_shutdown and has opt-out with a 0-length script. We don't enforce anything
3925-
if script.len() == 0 {
3926-
None
3927-
} else {
3928-
if !script::is_bolt2_compliant(&script, their_features) {
3929-
return Err(ChannelError::close(format!(
3920+
let counterparty_shutdown_scriptpubkey = if their_features
3921+
.supports_upfront_shutdown_script()
3922+
{
3923+
match &open_channel_fields.shutdown_scriptpubkey {
3924+
&Some(ref script) => {
3925+
// Peer is signaling upfront_shutdown and has opt-out with a 0-length script. We don't enforce anything
3926+
if script.len() == 0 {
3927+
None
3928+
} else {
3929+
if !script::is_bolt2_compliant(&script, their_features) {
3930+
return Err(ChannelError::close(format!(
39303931
"Peer is signaling upfront_shutdown but has provided an unacceptable scriptpubkey format: {script}"
39313932
)));
3932-
}
3933-
Some(script.clone())
39343933
}
3935-
},
3936-
// Peer is signaling upfront shutdown but don't opt-out with correct mechanism (a.k.a 0-length script). Peer looks buggy, we fail the channel
3937-
&None => {
3938-
return Err(ChannelError::close(String::from(
3934+
Some(script.clone())
3935+
}
3936+
},
3937+
// Peer is signaling upfront shutdown but don't opt-out with correct mechanism (a.k.a 0-length script). Peer looks buggy, we fail the channel
3938+
&None => {
3939+
return Err(ChannelError::close(String::from(
39393940
"Peer is signaling upfront_shutdown but we don't get any script. Use 0-length script to opt-out"
39403941
)));
3941-
},
3942-
}
3943-
} else {
3944-
None
3945-
};
3942+
},
3943+
}
3944+
} else {
3945+
None
3946+
};
39463947

39473948
let shutdown_scriptpubkey =
39483949
if config.channel_handshake_config.commit_upfront_shutdown_pubkey {
@@ -4853,32 +4854,33 @@ impl<SP: SignerProvider> ChannelContext<SP> {
48534854
)));
48544855
}
48554856

4856-
let counterparty_shutdown_scriptpubkey =
4857-
if their_features.supports_upfront_shutdown_script() {
4858-
match &common_fields.shutdown_scriptpubkey {
4859-
&Some(ref script) => {
4860-
// Peer is signaling upfront_shutdown and has opt-out with a 0-length script. We don't enforce anything
4861-
if script.len() == 0 {
4862-
None
4863-
} else {
4864-
if !script::is_bolt2_compliant(&script, their_features) {
4865-
return Err(ChannelError::close(format!(
4857+
let counterparty_shutdown_scriptpubkey = if their_features
4858+
.supports_upfront_shutdown_script()
4859+
{
4860+
match &common_fields.shutdown_scriptpubkey {
4861+
&Some(ref script) => {
4862+
// Peer is signaling upfront_shutdown and has opt-out with a 0-length script. We don't enforce anything
4863+
if script.len() == 0 {
4864+
None
4865+
} else {
4866+
if !script::is_bolt2_compliant(&script, their_features) {
4867+
return Err(ChannelError::close(format!(
48664868
"Peer is signaling upfront_shutdown but has provided an unacceptable scriptpubkey format: {script}"
48674869
)));
4868-
}
4869-
Some(script.clone())
48704870
}
4871-
},
4872-
// Peer is signaling upfront shutdown but don't opt-out with correct mechanism (a.k.a 0-length script). Peer looks buggy, we fail the channel
4873-
&None => {
4874-
return Err(ChannelError::close(String::from(
4871+
Some(script.clone())
4872+
}
4873+
},
4874+
// Peer is signaling upfront shutdown but don't opt-out with correct mechanism (a.k.a 0-length script). Peer looks buggy, we fail the channel
4875+
&None => {
4876+
return Err(ChannelError::close(String::from(
48754877
"Peer is signaling upfront_shutdown but we don't get any script. Use 0-length script to opt-out"
48764878
)));
4877-
},
4878-
}
4879-
} else {
4880-
None
4881-
};
4879+
},
4880+
}
4881+
} else {
4882+
None
4883+
};
48824884

48834885
self.counterparty_dust_limit_satoshis = common_fields.dust_limit_satoshis;
48844886
self.counterparty_max_htlc_value_in_flight_msat = cmp::min(

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9623,7 +9623,8 @@ impl<
96239623
ComplFunc: FnOnce(
96249624
Option<u64>,
96259625
bool,
9626-
) -> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>),
9626+
)
9627+
-> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>),
96279628
>(
96289629
&self, prev_hop: HTLCPreviousHopData, payment_preimage: PaymentPreimage,
96299630
payment_info: Option<PaymentClaimDetails>, attribution_data: Option<AttributionData>,
@@ -9661,7 +9662,8 @@ impl<
96619662
ComplFunc: FnOnce(
96629663
Option<u64>,
96639664
bool,
9664-
) -> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>),
9665+
)
9666+
-> (Option<MonitorUpdateCompletionAction>, Option<RAAMonitorUpdateBlockingAction>),
96659667
>(
96669668
&self, prev_hop: HTLCClaimSource, payment_preimage: PaymentPreimage,
96679669
payment_info: Option<PaymentClaimDetails>, attribution_data: Option<AttributionData>,

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ pub fn test_justice_tx_htlc_timeout() {
858858
revoked_local_txn[1].input[0].witness.last().unwrap().len(),
859859
OFFERED_HTLC_SCRIPT_WEIGHT
860860
); // HTLC-Timeout
861-
// Revoke the old state
861+
// Revoke the old state
862862
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_3);
863863

864864
{
@@ -6155,7 +6155,7 @@ pub fn test_announce_disable_channels() {
61556155
match e {
61566156
MessageSendEvent::BroadcastChannelUpdate { ref msg, .. } => {
61576157
assert_eq!(msg.contents.channel_flags & (1 << 1), 1 << 1); // The "channel disabled" bit should be set
6158-
// Check that each channel gets updated exactly once
6158+
// Check that each channel gets updated exactly once
61596159
if chans_disabled
61606160
.insert(msg.contents.short_channel_id, msg.contents.timestamp)
61616161
.is_some()

lightning/src/ln/funding.rs

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,17 @@ impl FundingTemplate {
386386
return Err(FundingContributionError::InvalidSpliceValue);
387387
}
388388
let FundingTemplate { shared_input, min_rbf_feerate, .. } = self;
389-
build_funding_contribution!(value_added, vec![], shared_input, min_rbf_feerate, min_feerate, max_feerate, false, wallet, await)
389+
build_funding_contribution!(
390+
value_added,
391+
vec![],
392+
shared_input,
393+
min_rbf_feerate,
394+
min_feerate,
395+
max_feerate,
396+
false,
397+
wallet,
398+
await
399+
)
390400
}
391401

392402
/// Creates a [`FundingContribution`] for adding funds to a channel using `wallet` to perform
@@ -426,7 +436,17 @@ impl FundingTemplate {
426436
return Err(FundingContributionError::InvalidSpliceValue);
427437
}
428438
let FundingTemplate { shared_input, min_rbf_feerate, .. } = self;
429-
build_funding_contribution!(Amount::ZERO, outputs, shared_input, min_rbf_feerate, min_feerate, max_feerate, false, wallet, await)
439+
build_funding_contribution!(
440+
Amount::ZERO,
441+
outputs,
442+
shared_input,
443+
min_rbf_feerate,
444+
min_feerate,
445+
max_feerate,
446+
false,
447+
wallet,
448+
await
449+
)
430450
}
431451

432452
/// Creates a [`FundingContribution`] for removing funds from a channel using `wallet` to
@@ -467,7 +487,17 @@ impl FundingTemplate {
467487
return Err(FundingContributionError::InvalidSpliceValue);
468488
}
469489
let FundingTemplate { shared_input, min_rbf_feerate, .. } = self;
470-
build_funding_contribution!(value_added, outputs, shared_input, min_rbf_feerate, min_feerate, max_feerate, false, wallet, await)
490+
build_funding_contribution!(
491+
value_added,
492+
outputs,
493+
shared_input,
494+
min_rbf_feerate,
495+
min_feerate,
496+
max_feerate,
497+
false,
498+
wallet,
499+
await
500+
)
471501
}
472502

473503
/// Creates a [`FundingContribution`] for both adding and removing funds from a channel using
@@ -550,10 +580,30 @@ impl FundingTemplate {
550580
return Ok(adjusted);
551581
}
552582
}
553-
build_funding_contribution!(contribution.value_added, contribution.outputs, shared_input, min_rbf_feerate, rbf_feerate, max_feerate, true, wallet, await)
583+
build_funding_contribution!(
584+
contribution.value_added,
585+
contribution.outputs,
586+
shared_input,
587+
min_rbf_feerate,
588+
rbf_feerate,
589+
max_feerate,
590+
true,
591+
wallet,
592+
await
593+
)
554594
},
555595
None => {
556-
build_funding_contribution!(Amount::ZERO, vec![], shared_input, min_rbf_feerate, rbf_feerate, max_feerate, true, wallet, await)
596+
build_funding_contribution!(
597+
Amount::ZERO,
598+
vec![],
599+
shared_input,
600+
min_rbf_feerate,
601+
rbf_feerate,
602+
max_feerate,
603+
true,
604+
wallet,
605+
await
606+
)
557607
},
558608
}
559609
}

lightning/src/ln/htlc_reserve_unit_tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ pub fn test_channel_reserve_holding_cell_htlcs() {
294294
stat.value_to_self_msat
295295
- (stat.pending_outbound_htlcs_amount_msat
296296
+ recv_value_21 + recv_value_22
297-
+ total_fee_msat + total_fee_msat
297+
+ total_fee_msat
298+
+ total_fee_msat
298299
+ commit_tx_fee_3_htlcs),
299300
stat.channel_reserve_msat
300301
);
@@ -3000,7 +3001,8 @@ fn do_test_0reserve_no_outputs_keyed_anchors(payment_success: bool) {
30003001
// min opener balance is the fee for 4 HTLCs, the anchors, and the dust limit
30013002
let min_channel_size =
30023003
commit_tx_fee_sat(feerate_per_kw, MIN_AFFORDABLE_HTLC_COUNT, &channel_type)
3003-
+ anchors_sat + dust_limit_satoshis;
3004+
+ anchors_sat
3005+
+ dust_limit_satoshis;
30043006
assert!(min_channel_size > 1002);
30053007
min_channel_size
30063008
};

lightning/src/ln/msgs.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,8 @@ impl<NS: NodeSigner> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPaylo
38683868
used_aad,
38693869
} => {
38703870
if amt.is_some()
3871-
|| cltv_value.is_some() || total_msat.is_some()
3871+
|| cltv_value.is_some()
3872+
|| total_msat.is_some()
38723873
|| keysend_preimage.is_some()
38733874
|| invoice_request.is_some()
38743875
|| used_aad != TriPolyAADUsed::None
@@ -3890,7 +3891,8 @@ impl<NS: NodeSigner> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPaylo
38903891
used_aad,
38913892
} => {
38923893
if amt.is_some()
3893-
|| cltv_value.is_some() || total_msat.is_some()
3894+
|| cltv_value.is_some()
3895+
|| total_msat.is_some()
38943896
|| keysend_preimage.is_some()
38953897
|| invoice_request.is_some()
38963898
|| used_aad == TriPolyAADUsed::None
@@ -4038,7 +4040,8 @@ impl<NS: NodeSigner> ReadableArgs<(Option<PublicKey>, NS)> for InboundTrampoline
40384040
used_aad,
40394041
} => {
40404042
if amt.is_some()
4041-
|| cltv_value.is_some() || total_msat.is_some()
4043+
|| cltv_value.is_some()
4044+
|| total_msat.is_some()
40424045
|| keysend_preimage.is_some()
40434046
|| invoice_request.is_some()
40444047
|| used_aad != TriPolyAADUsed::None

0 commit comments

Comments
 (0)