11
11
//! largely of interest for those implementing the traits on [`crate::sign`] by hand.
12
12
13
13
use bitcoin:: amount:: Amount ;
14
+ use bitcoin:: constants:: WITNESS_SCALE_FACTOR ;
14
15
use bitcoin:: opcodes;
15
16
use bitcoin:: script:: { Builder , Script , ScriptBuf } ;
16
17
use bitcoin:: sighash;
@@ -96,7 +97,7 @@ pub const P2A_ANCHOR_INPUT_WITNESS_WEIGHT: u64 = 1;
96
97
pub const P2A_MAX_VALUE : u64 = 240 ;
97
98
98
99
/// The maximum weight of a TRUC transaction.
99
- pub const TRUC_MAX_WEIGHT : u64 = 10_000 * bitcoin :: constants :: WITNESS_SCALE_FACTOR as u64 ;
100
+ pub const TRUC_MAX_WEIGHT : u64 = 10_000 * WITNESS_SCALE_FACTOR as u64 ;
100
101
101
102
/// The upper bound weight of an HTLC timeout input from a commitment transaction with keyed anchor outputs.
102
103
pub const HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT : u64 = 288 ;
@@ -137,6 +138,15 @@ pub fn htlc_success_tx_weight(channel_type_features: &ChannelTypeFeatures) -> u6
137
138
if channel_type_features. supports_anchors_zero_fee_htlc_tx ( ) { HTLC_SUCCESS_ANCHOR_TX_WEIGHT } else { HTLC_SUCCESS_TX_WEIGHT }
138
139
}
139
140
141
+ /// Gets the weight of a single input-output pair in HTLC-success transactions
142
+ pub fn htlc_success_input_output_pair_weight ( channel_type_features : & ChannelTypeFeatures ) -> u64 {
143
+ const TXIN_WEIGHT : u64 = 41 * WITNESS_SCALE_FACTOR as u64 ;
144
+ const TXOUT_WEIGHT : u64 = 43 * WITNESS_SCALE_FACTOR as u64 ;
145
+ let witness_weight =
146
+ if channel_type_features. supports_anchors_zero_fee_htlc_tx ( ) { 327 } else { 324 } ;
147
+ TXIN_WEIGHT + TXOUT_WEIGHT + witness_weight
148
+ }
149
+
140
150
/// Gets the weight for an HTLC-Timeout transaction.
141
151
#[ inline]
142
152
#[ rustfmt:: skip]
@@ -146,6 +156,15 @@ pub fn htlc_timeout_tx_weight(channel_type_features: &ChannelTypeFeatures) -> u6
146
156
if channel_type_features. supports_anchors_zero_fee_htlc_tx ( ) { HTLC_TIMEOUT_ANCHOR_TX_WEIGHT } else { HTLC_TIMEOUT_TX_WEIGHT }
147
157
}
148
158
159
+ /// Gets the weight of a single input-output pair in HTLC-timeout transactions
160
+ pub fn htlc_timeout_input_output_pair_weight ( channel_type_features : & ChannelTypeFeatures ) -> u64 {
161
+ const TXIN_WEIGHT : u64 = 41 * WITNESS_SCALE_FACTOR as u64 ;
162
+ const TXOUT_WEIGHT : u64 = 43 * WITNESS_SCALE_FACTOR as u64 ;
163
+ let witness_weight =
164
+ if channel_type_features. supports_anchors_zero_fee_htlc_tx ( ) { 288 } else { 285 } ;
165
+ TXIN_WEIGHT + TXOUT_WEIGHT + witness_weight
166
+ }
167
+
149
168
/// Describes the type of HTLC claim as determined by analyzing the witness.
150
169
#[ derive( PartialEq , Eq ) ]
151
170
pub enum HTLCClaim {
0 commit comments