pub struct CommitmentTxBuilder {
pub fee_rate_sat_per_vb: u64,
pub protocol_id: [u8; 32],
pub max_fee_rate_sat_per_vb: u64,
pub dust_threshold_sat: u64,
}Expand description
Configuration for building commitment transactions
Fields§
§fee_rate_sat_per_vb: u64Fee rate in sat/vB
protocol_id: [u8; 32]Protocol ID for this commitment
max_fee_rate_sat_per_vb: u64Maximum fee rate to prevent overpaying
dust_threshold_sat: u64Dust threshold (satoshi)
Implementations§
Source§impl CommitmentTxBuilder
impl CommitmentTxBuilder
Sourcepub fn new(protocol_id: [u8; 32], fee_rate_sat_per_vb: u64) -> Self
pub fn new(protocol_id: [u8; 32], fee_rate_sat_per_vb: u64) -> Self
Create a new transaction builder
Sourcepub fn with_fee_rate(self, fee_rate: u64) -> Self
pub fn with_fee_rate(self, fee_rate: u64) -> Self
Set the fee rate
Sourcepub fn with_max_fee_rate(self, max_fee: u64) -> Self
pub fn with_max_fee_rate(self, max_fee: u64) -> Self
Set maximum fee rate (prevents overpaying during fee spikes)
Sourcepub fn estimate_vbytes(input_count: usize, output_count: usize) -> usize
pub fn estimate_vbytes(input_count: usize, output_count: usize) -> usize
Estimate virtual bytes for a commitment transaction
Sourcepub fn calculate_fee(&self, input_count: usize, output_count: usize) -> u64
pub fn calculate_fee(&self, input_count: usize, output_count: usize) -> u64
Calculate required fee
Sourcepub fn is_above_dust(&self, value_sat: u64) -> bool
pub fn is_above_dust(&self, value_sat: u64) -> bool
Check if an output amount is above the dust threshold
Sourcepub fn build_commitment_tx(
&self,
wallet: &SealWallet,
seal_utxo: &WalletUtxo,
commitment_hash: [u8; 32],
_change_path: Option<&Bip86Path>,
) -> Result<CommitmentTxResult, TxBuilderError>
pub fn build_commitment_tx( &self, wallet: &SealWallet, seal_utxo: &WalletUtxo, commitment_hash: [u8; 32], _change_path: Option<&Bip86Path>, ) -> Result<CommitmentTxResult, TxBuilderError>
Build a complete commitment transaction
This handles two cases:
-
Plain P2TR input (funded externally to a simple P2TR address): The input is spent via key-path using the tweaked keypair. The output uses a Tapret commitment with the same internal key.
-
Tapret input (previously committed): The input is spent via script-path using the tapret leaf.
For freshly funded UTXOs (case 1), this is the standard flow.
Sourcepub fn build_commitment_data(&self, commitment: Hash) -> CommitmentData
pub fn build_commitment_data(&self, commitment: Hash) -> CommitmentData
Build legacy commitment data (for backward compatibility)