Skip to content

Commit 359b3d5

Browse files
Antoine RiardTheBlueMatt
authored andcommitted
Dry-up InputMaterial::Funding
As channel_value last usage was for computing feerate but as this one is static per-commitment and will always-be following specification, we remove it.
1 parent 4dc0dd1 commit 359b3d5

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,7 @@ pub(crate) enum InputMaterial {
442442
preimage: Option<PaymentPreimage>,
443443
amount: u64,
444444
},
445-
Funding {
446-
channel_value: u64,
447-
}
445+
Funding {}
448446
}
449447

450448
impl Writeable for InputMaterial {
@@ -471,9 +469,8 @@ impl Writeable for InputMaterial {
471469
preimage.write(writer)?;
472470
writer.write_all(&byte_utils::be64_to_array(*amount))?;
473471
},
474-
&InputMaterial::Funding { ref channel_value } => {
472+
&InputMaterial::Funding {} => {
475473
writer.write_all(&[3; 1])?;
476-
channel_value.write(writer)?;
477474
}
478475
}
479476
Ok(())
@@ -520,10 +517,7 @@ impl Readable for InputMaterial {
520517
}
521518
},
522519
3 => {
523-
let channel_value = Readable::read(reader)?;
524-
InputMaterial::Funding {
525-
channel_value
526-
}
520+
InputMaterial::Funding {}
527521
}
528522
_ => return Err(DecodeError::InvalidValue),
529523
};
@@ -1864,7 +1858,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
18641858
}
18651859
let should_broadcast = self.would_broadcast_at_height(height);
18661860
if should_broadcast {
1867-
claimable_outpoints.push(ClaimRequest { absolute_timelock: height, aggregable: false, outpoint: BitcoinOutPoint { txid: self.funding_info.0.txid.clone(), vout: self.funding_info.0.index as u32 }, witness_data: InputMaterial::Funding { channel_value: self.channel_value_satoshis }});
1861+
claimable_outpoints.push(ClaimRequest { absolute_timelock: height, aggregable: false, outpoint: BitcoinOutPoint { txid: self.funding_info.0.txid.clone(), vout: self.funding_info.0.index as u32 }, witness_data: InputMaterial::Funding {}});
18681862
}
18691863
if should_broadcast {
18701864
if let Some(commitment_tx) = self.onchain_tx_handler.get_fully_signed_local_tx() {

lightning/src/ln/onchaintx.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,11 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
531531
}
532532
return None;
533533
},
534-
&InputMaterial::Funding { ref channel_value } => {
534+
&InputMaterial::Funding {} => {
535535
let signed_tx = self.get_fully_signed_local_tx().unwrap();
536-
let mut amt_outputs = 0;
537-
for outp in signed_tx.output.iter() {
538-
amt_outputs += outp.value;
539-
}
540-
let feerate = (channel_value - amt_outputs) * 1000 / signed_tx.get_weight() as u64;
541536
// Timer set to $NEVER given we can't bump tx without anchor outputs
542537
log_trace!(self, "Going to broadcast Local Transaction {} claiming funding output {} from {}...", signed_tx.txid(), outp.vout, outp.txid);
543-
return Some((None, feerate, signed_tx));
538+
return Some((None, self.local_commitment.as_ref().unwrap().feerate_per_kw, signed_tx));
544539
}
545540
_ => unreachable!()
546541
}

0 commit comments

Comments
 (0)