Skip to content

Commit

Permalink
Removed unused field in HolderFundingOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
tankyleo committed Jan 10, 2025
1 parent bb8f796 commit bd00296
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: ChannelSigner> {
prev_counterparty_commitment_txid: Option<Txid>,

counterparty_commitment_params: CounterpartyCommitmentParameters,
// this field is not used, but kept for backwards compatibility
funding_redeemscript: ScriptBuf,
channel_value_satoshis: u64,
// first is the idx of the first of the two per-commitment points
Expand Down Expand Up @@ -1340,7 +1341,7 @@ impl<Signer: ChannelSigner> ChannelMonitor<Signer> {
pub(crate) fn new(secp_ctx: Secp256k1<secp256k1::All>, mut keys: Signer, shutdown_script: Option<ScriptBuf>,
on_counterparty_tx_csv: u16, destination_script: &Script, funding_info: (OutPoint, ScriptBuf),
channel_parameters: &ChannelTransactionParameters, holder_pays_commitment_tx_fee: bool,
funding_redeemscript: ScriptBuf, channel_value_satoshis: u64,
channel_value_satoshis: u64,
commitment_transaction_number_obscure_factor: u64,
initial_holder_commitment_tx: HolderCommitmentTransaction,
best_block: BestBlock, counterparty_node_id: PublicKey, channel_id: ChannelId,
Expand Down Expand Up @@ -1404,7 +1405,7 @@ impl<Signer: ChannelSigner> ChannelMonitor<Signer> {
prev_counterparty_commitment_txid: None,

counterparty_commitment_params,
funding_redeemscript,
funding_redeemscript: ScriptBuf::new(),
channel_value_satoshis,
their_cur_per_commitment_points: None,

Expand Down Expand Up @@ -3069,7 +3070,6 @@ impl<Signer: ChannelSigner> ChannelMonitorImpl<Signer> {

fn generate_claimable_outpoints_and_watch_outputs(&mut self, reason: ClosureReason) -> (Vec<PackageTemplate>, Vec<TransactionOutputs>) {
let funding_outp = HolderFundingOutput::build(
self.funding_redeemscript.clone(),
self.channel_value_satoshis,
self.onchain_tx_handler.channel_type_features().clone()
);
Expand Down Expand Up @@ -5277,7 +5277,7 @@ mod tests {
let monitor = ChannelMonitor::new(Secp256k1::new(), keys,
Some(ShutdownScript::new_p2wpkh_from_pubkey(shutdown_pubkey).into_inner()), 0, &ScriptBuf::new(),
(OutPoint { txid: Txid::from_slice(&[43; 32]).unwrap(), index: 0 }, ScriptBuf::new()),
&channel_parameters, true, ScriptBuf::new(), 46, 0, HolderCommitmentTransaction::dummy(&mut Vec::new()),
&channel_parameters, true, 46, 0, HolderCommitmentTransaction::dummy(&mut Vec::new()),
best_block, dummy_key, channel_id);

let mut htlcs = preimages_slice_to_htlcs!(preimages[0..10]);
Expand Down Expand Up @@ -5527,7 +5527,7 @@ mod tests {
let monitor = ChannelMonitor::new(Secp256k1::new(), keys,
Some(ShutdownScript::new_p2wpkh_from_pubkey(shutdown_pubkey).into_inner()), 0, &ScriptBuf::new(),
(OutPoint { txid: Txid::from_slice(&[43; 32]).unwrap(), index: 0 }, ScriptBuf::new()),
&channel_parameters, true, ScriptBuf::new(), 46, 0, HolderCommitmentTransaction::dummy(&mut Vec::new()),
&channel_parameters, true, 46, 0, HolderCommitmentTransaction::dummy(&mut Vec::new()),
best_block, dummy_key, channel_id);

let chan_id = monitor.inner.lock().unwrap().channel_id();
Expand Down
13 changes: 5 additions & 8 deletions lightning/src/chain/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,14 @@ impl Readable for HolderHTLCOutput {
/// Note that on upgrades, some features of existing outputs may be missed.
#[derive(Clone, PartialEq, Eq)]
pub(crate) struct HolderFundingOutput {
funding_redeemscript: ScriptBuf,
pub(crate) funding_amount: Option<u64>,
channel_type_features: ChannelTypeFeatures,
}


impl HolderFundingOutput {
pub(crate) fn build(funding_redeemscript: ScriptBuf, funding_amount: u64, channel_type_features: ChannelTypeFeatures) -> Self {
pub(crate) fn build(funding_amount: u64, channel_type_features: ChannelTypeFeatures) -> Self {
HolderFundingOutput {
funding_redeemscript,
funding_amount: Some(funding_amount),
channel_type_features,
}
Expand All @@ -475,7 +473,7 @@ impl Writeable for HolderFundingOutput {
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
let legacy_deserialization_prevention_marker = chan_utils::legacy_deserialization_prevention_marker_for_channel_type_features(&self.channel_type_features);
write_tlv_fields!(writer, {
(0, self.funding_redeemscript, required),
(0, None::<ScriptBuf>, option),
(1, self.channel_type_features, required),
(2, legacy_deserialization_prevention_marker, option),
(3, self.funding_amount, option),
Expand All @@ -486,13 +484,13 @@ impl Writeable for HolderFundingOutput {

impl Readable for HolderFundingOutput {
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
let mut funding_redeemscript = RequiredWrapper(None);
let mut _funding_redeemscript: Option<ScriptBuf> = None;
let mut _legacy_deserialization_prevention_marker: Option<()> = None;
let mut channel_type_features = None;
let mut funding_amount = None;

read_tlv_fields!(reader, {
(0, funding_redeemscript, required),
(0, _funding_redeemscript, option),
(1, channel_type_features, option),
(2, _legacy_deserialization_prevention_marker, option),
(3, funding_amount, option),
Expand All @@ -501,7 +499,6 @@ impl Readable for HolderFundingOutput {
verify_channel_type_features(&channel_type_features, None)?;

Ok(Self {
funding_redeemscript: funding_redeemscript.0.unwrap(),
channel_type_features: channel_type_features.unwrap_or(ChannelTypeFeatures::only_static_remote_key()),
funding_amount
})
Expand Down Expand Up @@ -1420,7 +1417,7 @@ mod tests {

macro_rules! dumb_funding_output {
() => {
PackageSolvingData::HolderFundingOutput(HolderFundingOutput::build(ScriptBuf::new(), 0, ChannelTypeFeatures::only_static_remote_key()))
PackageSolvingData::HolderFundingOutput(HolderFundingOutput::build(0, ChannelTypeFeatures::only_static_remote_key()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
shutdown_script, context.get_holder_selected_contest_delay(),
&context.destination_script, (funding_txo, funding_txo_script),
&context.channel_transaction_parameters, context.is_outbound(),
funding_redeemscript.clone(), context.channel_value_satoshis,
context.channel_value_satoshis,
obscure_factor,
holder_commitment_tx, best_block, context.counterparty_node_id, context.channel_id());
channel_monitor.provide_initial_counterparty_commitment_tx(
Expand Down

0 comments on commit bd00296

Please sign in to comment.