Skip to content

Commit 3598d42

Browse files
committed
fix Improve readability, minor simplification, typos
1 parent 9328962 commit 3598d42

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,26 +2243,27 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22432243
// Note: For the error case when the inputs are insufficient, it will be handled after
22442244
// the `calculate_change_output_value` call below
22452245
let mut funding_outputs = Vec::new();
2246-
let funding_output_value_satoshis = self.funding.get_value_satoshis();
2247-
let funding_output_script_pubkey = self.funding.get_funding_redeemscript().to_p2wsh();
2248-
let expected_remote_shared_funding_output = if self.funding.is_outbound() {
2249-
let tx_out = TxOut {
2250-
value: Amount::from_sat(funding_output_value_satoshis),
2251-
script_pubkey: funding_output_script_pubkey,
2252-
};
2253-
funding_outputs.push(
2254-
if self.dual_funding_context.their_funding_satoshis.unwrap_or(0) == 0 {
2255-
OutputOwned::SharedControlFullyOwned(tx_out)
2256-
} else {
2246+
let mut expected_remote_shared_funding_output = None;
2247+
2248+
let shared_funding_output = TxOut {
2249+
value: Amount::from_sat(self.funding.get_value_satoshis()),
2250+
script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
2251+
};
2252+
2253+
if self.funding.is_outbound() {
2254+
if self.dual_funding_context.their_funding_satoshis.unwrap_or(0) == 0 {
2255+
funding_outputs.push(OutputOwned::SharedControlFullyOwned(shared_funding_output));
2256+
} else {
2257+
funding_outputs.push(
22572258
OutputOwned::Shared(SharedOwnedOutput::new(
2258-
tx_out, self.dual_funding_context.our_funding_satoshis
2259+
shared_funding_output, self.dual_funding_context.our_funding_satoshis,
22592260
))
2260-
}
2261-
);
2262-
None
2261+
);
2262+
}
22632263
} else {
2264-
Some((funding_output_script_pubkey, funding_output_value_satoshis))
2265-
};
2264+
let TxOut { value, script_pubkey } = shared_funding_output;
2265+
expected_remote_shared_funding_output = Some((script_pubkey, value.to_sat()));
2266+
}
22662267

22672268
// Optionally add change output
22682269
let change_script = if let Some(script) = change_destination_opt {

lightning/src/ln/interactivetxs.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,9 +1680,9 @@ impl InteractiveTxConstructor {
16801680
/// Three outcomes are possible:
16811681
/// - Inputs are sufficient for intended contribution, fees, and a larger-than-dust change:
16821682
/// `Ok(Some(change_amount))`
1683-
/// - Inputs are sufficient for intended contribution and fees, but not for a change:
1683+
/// - Inputs are sufficient for intended contribution and fees, and a change output isn't needed:
16841684
/// `Ok(None)`
1685-
/// - Insputs are not sufficent to cover contribution and fees:
1685+
/// - Inputs are not sufficent to cover contribution and fees:
16861686
/// `Err(AbortReason::InsufficientFees)`
16871687
#[allow(dead_code)] // TODO(dual_funding): Remove once begin_interactive_funding_tx_construction() is used
16881688
pub(super) fn calculate_change_output_value(
@@ -2672,11 +2672,10 @@ mod tests {
26722672

26732673
#[test]
26742674
fn test_calculate_change_output_value_open() {
2675-
let input_prevouts_owned = vec![
2675+
let input_prevouts = vec![
26762676
TxOut { value: Amount::from_sat(70_000), script_pubkey: ScriptBuf::new() },
26772677
TxOut { value: Amount::from_sat(60_000), script_pubkey: ScriptBuf::new() },
26782678
];
2679-
let input_prevouts: Vec<&TxOut> = input_prevouts_owned.iter().collect();
26802679
let inputs = input_prevouts
26812680
.iter()
26822681
.map(|txout| {

0 commit comments

Comments
 (0)