Skip to content

Commit 5b57776

Browse files
committed
Removed unused field in HolderFundingOutput
1 parent 00bb409 commit 5b57776

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: ChannelSigner> {
878878
prev_counterparty_commitment_txid: Option<Txid>,
879879

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

14061407
counterparty_commitment_params,
1407-
funding_redeemscript,
1408+
funding_redeemscript: ScriptBuf::new(),
14081409
channel_value_satoshis,
14091410
their_cur_per_commitment_points: None,
14101411

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

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

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

55335533
let chan_id = monitor.inner.lock().unwrap().channel_id();

lightning/src/chain/package.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,14 @@ impl Readable for HolderHTLCOutput {
455455
/// Note that on upgrades, some features of existing outputs may be missed.
456456
#[derive(Clone, PartialEq, Eq)]
457457
pub(crate) struct HolderFundingOutput {
458-
funding_redeemscript: ScriptBuf,
459458
pub(crate) funding_amount: Option<u64>,
460459
channel_type_features: ChannelTypeFeatures,
461460
}
462461

463462

464463
impl HolderFundingOutput {
465-
pub(crate) fn build(funding_redeemscript: ScriptBuf, funding_amount: u64, channel_type_features: ChannelTypeFeatures) -> Self {
464+
pub(crate) fn build(funding_amount: u64, channel_type_features: ChannelTypeFeatures) -> Self {
466465
HolderFundingOutput {
467-
funding_redeemscript,
468466
funding_amount: Some(funding_amount),
469467
channel_type_features,
470468
}
@@ -475,7 +473,7 @@ impl Writeable for HolderFundingOutput {
475473
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
476474
let legacy_deserialization_prevention_marker = chan_utils::legacy_deserialization_prevention_marker_for_channel_type_features(&self.channel_type_features);
477475
write_tlv_fields!(writer, {
478-
(0, self.funding_redeemscript, required),
476+
(0, None::<ScriptBuf>, option),
479477
(1, self.channel_type_features, required),
480478
(2, legacy_deserialization_prevention_marker, option),
481479
(3, self.funding_amount, option),
@@ -486,13 +484,13 @@ impl Writeable for HolderFundingOutput {
486484

487485
impl Readable for HolderFundingOutput {
488486
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
489-
let mut funding_redeemscript = RequiredWrapper(None);
487+
let mut _funding_redeemscript: Option<ScriptBuf> = None;
490488
let mut _legacy_deserialization_prevention_marker: Option<()> = None;
491489
let mut channel_type_features = None;
492490
let mut funding_amount = None;
493491

494492
read_tlv_fields!(reader, {
495-
(0, funding_redeemscript, required),
493+
(0, _funding_redeemscript, option),
496494
(1, channel_type_features, option),
497495
(2, _legacy_deserialization_prevention_marker, option),
498496
(3, funding_amount, option),
@@ -501,7 +499,6 @@ impl Readable for HolderFundingOutput {
501499
verify_channel_type_features(&channel_type_features, None)?;
502500

503501
Ok(Self {
504-
funding_redeemscript: funding_redeemscript.0.unwrap(),
505502
channel_type_features: channel_type_features.unwrap_or(ChannelTypeFeatures::only_static_remote_key()),
506503
funding_amount
507504
})
@@ -1420,7 +1417,7 @@ mod tests {
14201417

14211418
macro_rules! dumb_funding_output {
14221419
() => {
1423-
PackageSolvingData::HolderFundingOutput(HolderFundingOutput::build(ScriptBuf::new(), 0, ChannelTypeFeatures::only_static_remote_key()))
1420+
PackageSolvingData::HolderFundingOutput(HolderFundingOutput::build(0, ChannelTypeFeatures::only_static_remote_key()))
14241421
}
14251422
}
14261423

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
16191619
shutdown_script, context.get_holder_selected_contest_delay(),
16201620
&context.destination_script, (funding_txo, funding_txo_script),
16211621
&context.channel_transaction_parameters, context.is_outbound(),
1622-
funding_redeemscript.clone(), context.channel_value_satoshis,
1622+
context.channel_value_satoshis,
16231623
obscure_factor,
16241624
holder_commitment_tx, best_block, context.counterparty_node_id, context.channel_id());
16251625
channel_monitor.provide_initial_counterparty_commitment_tx(

0 commit comments

Comments
 (0)