Skip to content

Commit

Permalink
delete provide channel parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tankyleo committed Feb 22, 2025
1 parent 73dd9c7 commit c562911
Showing 1 changed file with 2 additions and 45 deletions.
47 changes: 2 additions & 45 deletions lightning/src/sign/tx_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Defines the `TxBuilder` trait, and the `SpecTxBuilder` type
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]

use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
use bitcoin::{Amount, Transaction};
Expand All @@ -10,13 +11,6 @@ use crate::prelude::*;

/// A trait for types that can build commitment transactions, both for the holder, and the counterparty.
pub trait TxBuilder {
/// Set the counterparty static channel data, including basepoints,
/// `counterparty_selected`/`holder_selected_contest_delay` and funding outpoint.
///
/// This data is static, and will never change for a channel once set.
///
/// channel_parameters.is_populated() MUST be true.
fn provide_channel_parameters(&mut self, channel_parameters: &ChannelTransactionParameters);
/// Build a commitment transaction, and populate the elements of `htlcs` with their output indices.
/// Do not sort `htlcs`; this will be done by the caller as needed.
/// This method will be called only after all the channel parameters have been provided via `provide_channel_parameters`.
Expand All @@ -30,52 +24,15 @@ pub trait TxBuilder {

/// A type that builds commitment transactions according to the Lightning Specification.
#[derive(Clone, Debug, Default)]
pub struct SpecTxBuilder {
channel_parameters: Option<ChannelTransactionParameters>,
}
pub struct SpecTxBuilder {}

impl TxBuilder for SpecTxBuilder {
fn provide_channel_parameters(&mut self, channel_parameters: &ChannelTransactionParameters) {
assert!(
self.channel_parameters.is_none()
|| self.channel_parameters.as_ref().unwrap() == channel_parameters
);
if self.channel_parameters.is_some() {
// The channel parameters were already set and they match, return early.
return;
}
assert!(channel_parameters.is_populated(), "Channel parameters must be fully populated");
self.channel_parameters = Some(channel_parameters.clone());
}
fn build_commitment_transaction(
&self, is_holder_tx: bool, commitment_number: u64, per_commitment_point: &PublicKey,
to_broadcaster_value_sat: Amount, to_countersignatory_value_sat: Amount,
trimmed_value_sat: Amount, htlcs: Vec<&mut HTLCOutputInCommitment>,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Transaction {
let params = if is_holder_tx {
self.channel_parameters.as_ref().unwrap().as_holder_broadcastable()
} else {
self.channel_parameters.as_ref().unwrap().as_counterparty_broadcastable()
};
let keys = TxCreationKeys::from_channel_static_keys(
per_commitment_point,
params.broadcaster_pubkeys(),
params.countersignatory_pubkeys(),
secp_ctx,
);
/*
let (obscured_commitment_transaction_number, txins) =
internal_build_inputs(commitment_number, &params);
let txouts = internal_build_outputs(
&keys,
to_broadcaster_value_sat,
to_countersignatory_value_sat,
htlcs,
&params,
);
make_transaction(obscured_commitment_transaction_number, txins, txouts)
*/
todo!();
}
}

0 comments on commit c562911

Please sign in to comment.