@@ -41,13 +41,20 @@ use core::ops::Deref;
4141use crate :: chain;
4242use crate :: util:: crypto:: sign;
4343
44- pub ( crate ) const MAX_HTLCS : u16 = 483 ;
45- pub ( crate ) const OFFERED_HTLC_SCRIPT_WEIGHT : usize = 133 ;
46- pub ( crate ) const OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS : usize = 136 ;
47- // The weight of `accepted_htlc_script` can vary in function of its CLTV argument value. We define a
48- // range that encompasses both its non-anchors and anchors variants.
44+ /// Maximum number of one-way in-flight HTLC (protocol-level value).
45+ pub const MAX_HTLCS : u16 = 483 ;
46+ /// The weight of HTLC second-stage `offered_htlc_script` non-anchor variant.
47+ pub const OFFERED_HTLC_SCRIPT_WEIGHT : usize = 133 ;
48+ /// The weight of HTLC second-stage `offered_htlc_script` anchor variant.
49+ pub const OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS : usize = 136 ;
50+
51+ /// The weight of `accepted_htlc_script` can vary in function of its CLTV argument value.
52+ /// We define a range that encompasses both its non-anchors and anchors variants.
4953pub ( crate ) const MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 136 ;
50- pub ( crate ) const MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 143 ;
54+ /// The weight of `accepted_htlc_script` can vary in function of its CLTV argument value.
55+ /// We define a range that encompasses both its non-anchors and anchors variants.
56+ /// The maximum post-anchor value.
57+ pub const MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 143 ;
5158
5259/// Gets the weight for an HTLC-Success transaction.
5360#[ inline]
@@ -65,18 +72,24 @@ pub fn htlc_timeout_tx_weight(opt_anchors: bool) -> u64 {
6572 if opt_anchors { HTLC_TIMEOUT_ANCHOR_TX_WEIGHT } else { HTLC_TIMEOUT_TX_WEIGHT }
6673}
6774
75+ /// Describes the type of HTLC output claim in function of the witness.
6876#[ derive( PartialEq , Eq ) ]
69- pub ( crate ) enum HTLCClaim {
77+ pub enum HTLCClaim {
78+ /// Claims an offered output on a commitment transaction through the timeout path.
7079 OfferedTimeout ,
80+ /// Claims an offered output on a commitment transaction through the success path.
7181 OfferedPreimage ,
82+ /// Claims an accepted output on a commitment transaction through the timeout path.
7283 AcceptedTimeout ,
84+ /// Claims an accepted output on a commitment transaction through the success path.
7385 AcceptedPreimage ,
86+ /// Claims an offered/accepted output on a commitment transaction through the revocation path.
7487 Revocation ,
7588}
7689
7790impl HTLCClaim {
7891 /// Check if a given input witness attempts to claim a HTLC.
79- pub ( crate ) fn from_witness ( witness : & Witness ) -> Option < Self > {
92+ pub fn from_witness ( witness : & Witness ) -> Option < Self > {
8093 debug_assert_eq ! ( OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS , MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
8194 if witness. len ( ) < 2 {
8295 return None ;
0 commit comments