Skip to content

Commit

Permalink
Removed unused RevokedOutput fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tankyleo committed Jan 7, 2025
1 parent 3f3d4e7 commit 4b5c6fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3513,7 +3513,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
// First, process non-htlc outputs (to_holder & to_counterparty)
for (idx, outp) in tx.output.iter().enumerate() {
if outp.script_pubkey == revokeable_spk {
let revk_outp = RevokedOutput::build(per_commitment_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key, self.counterparty_commitment_params.counterparty_htlc_base_key, per_commitment_key, outp.value, self.counterparty_commitment_params.on_counterparty_tx_csv, self.onchain_tx_handler.channel_type_features().supports_anchors_zero_fee_htlc_tx(), punishment_witness_weight);
let revk_outp = RevokedOutput::build(per_commitment_point, per_commitment_key, outp.value, self.onchain_tx_handler.channel_type_features().supports_anchors_zero_fee_htlc_tx(), punishment_witness_weight);
let justice_package = PackageTemplate::build_package(
commitment_txid, idx as u32,
PackageSolvingData::RevokedOutput(revk_outp),
Expand Down Expand Up @@ -3693,9 +3693,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
if input.previous_output.txid == *commitment_txid && input.witness.len() == 5 && tx.output.get(idx).is_some() {
log_error!(logger, "Got broadcast of revoked counterparty HTLC transaction, spending {}:{}", htlc_txid, idx);
let revk_outp = RevokedOutput::build(
per_commitment_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key,
self.counterparty_commitment_params.counterparty_htlc_base_key, per_commitment_key,
tx.output[idx].value, self.counterparty_commitment_params.on_counterparty_tx_csv,
per_commitment_point,
per_commitment_key,
tx.output[idx].value,
false, punishment_witness_weight,
);
let justice_package = PackageTemplate::build_package(
Expand Down
22 changes: 11 additions & 11 deletions lightning/src/chain/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,38 @@ const HIGH_FREQUENCY_BUMP_INTERVAL: u32 = 1;
#[derive(Clone, PartialEq, Eq)]
pub(crate) struct RevokedOutput {
per_commitment_point: PublicKey,
counterparty_delayed_payment_base_key: DelayedPaymentBasepoint,
counterparty_htlc_base_key: HtlcBasepoint,
counterparty_delayed_payment_base_key: Option<DelayedPaymentBasepoint>,
counterparty_htlc_base_key: Option<HtlcBasepoint>,
per_commitment_key: SecretKey,
weight: u64,
amount: Amount,
on_counterparty_tx_csv: u16,
on_counterparty_tx_csv: Option<u16>,
is_counterparty_balance_on_anchors: Option<()>,
}

impl RevokedOutput {
pub(crate) fn build(per_commitment_point: PublicKey, counterparty_delayed_payment_base_key: DelayedPaymentBasepoint, counterparty_htlc_base_key: HtlcBasepoint, per_commitment_key: SecretKey, amount: Amount, on_counterparty_tx_csv: u16, is_counterparty_balance_on_anchors: bool, weight: u64) -> Self {
pub(crate) fn build(per_commitment_point: PublicKey, per_commitment_key: SecretKey, amount: Amount, is_counterparty_balance_on_anchors: bool, weight: u64) -> Self {
RevokedOutput {
per_commitment_point,
counterparty_delayed_payment_base_key,
counterparty_htlc_base_key,
counterparty_delayed_payment_base_key: None,
counterparty_htlc_base_key: None,
per_commitment_key,
weight,
amount,
on_counterparty_tx_csv,
on_counterparty_tx_csv: None,
is_counterparty_balance_on_anchors: if is_counterparty_balance_on_anchors { Some(()) } else { None }
}
}
}

impl_writeable_tlv_based!(RevokedOutput, {
(0, per_commitment_point, required),
(2, counterparty_delayed_payment_base_key, required),
(4, counterparty_htlc_base_key, required),
(2, counterparty_delayed_payment_base_key, option),
(4, counterparty_htlc_base_key, option),
(6, per_commitment_key, required),
(8, weight, required),
(10, amount, required),
(12, on_counterparty_tx_csv, required),
(12, on_counterparty_tx_csv, option),
(14, is_counterparty_balance_on_anchors, option)
});

Expand Down Expand Up @@ -1363,7 +1363,7 @@ mod tests {
let secp_ctx = Secp256k1::new();
let dumb_scalar = SecretKey::from_slice(&<Vec<u8>>::from_hex("0101010101010101010101010101010101010101010101010101010101010101").unwrap()[..]).unwrap();
let dumb_point = PublicKey::from_secret_key(&secp_ctx, &dumb_scalar);
PackageSolvingData::RevokedOutput(RevokedOutput::build(dumb_point, DelayedPaymentBasepoint::from(dumb_point), HtlcBasepoint::from(dumb_point), dumb_scalar, Amount::ZERO, 0, $is_counterparty_balance_on_anchors, WEIGHT_REVOKED_OUTPUT))
PackageSolvingData::RevokedOutput(RevokedOutput::build(dumb_point, dumb_scalar, Amount::ZERO, $is_counterparty_balance_on_anchors, WEIGHT_REVOKED_OUTPUT))
}
}
}
Expand Down

0 comments on commit 4b5c6fc

Please sign in to comment.