@@ -41,13 +41,20 @@ use core::ops::Deref;
41
41
use crate :: chain;
42
42
use crate :: util:: crypto:: sign;
43
43
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 a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor variant.
47
+ pub const OFFERED_HTLC_SCRIPT_WEIGHT : usize = 133 ;
48
+ /// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, anchor variant.
49
+ pub const OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS : usize = 136 ;
50
+
51
+ /// The weight of a BIP141 witnessScript for a BOLT3's "received HTLC output" can vary in function of its CLTV argument value.
52
+ /// We define a range that encompasses both its non-anchors and anchors variants.
49
53
pub ( crate ) const MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 136 ;
50
- pub ( crate ) const MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 143 ;
54
+ /// The weight of a BIP141 witnessScript for a BOLT3's "received HTLC output" can vary in function of its CLTV argument value.
55
+ /// We define a range that encompasses both its non-anchors and anchors variants.
56
+ /// This is the maximum post-anchor value.
57
+ pub const MAX_ACCEPTED_HTLC_SCRIPT_WEIGHT : usize = 143 ;
51
58
52
59
/// Gets the weight for an HTLC-Success transaction.
53
60
#[ inline]
@@ -65,18 +72,24 @@ pub fn htlc_timeout_tx_weight(opt_anchors: bool) -> u64 {
65
72
if opt_anchors { HTLC_TIMEOUT_ANCHOR_TX_WEIGHT } else { HTLC_TIMEOUT_TX_WEIGHT }
66
73
}
67
74
75
+ /// Describes the type of HTLC claim as determined by analyzing the witness.
68
76
#[ 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.
70
79
OfferedTimeout ,
80
+ /// Claims an offered output on a commitment transaction through the success path.
71
81
OfferedPreimage ,
82
+ /// Claims an accepted output on a commitment transaction through the timeout path.
72
83
AcceptedTimeout ,
84
+ /// Claims an accepted output on a commitment transaction through the success path.
73
85
AcceptedPreimage ,
86
+ /// Claims an offered/accepted output on a commitment transaction through the revocation path.
74
87
Revocation ,
75
88
}
76
89
77
90
impl HTLCClaim {
78
91
/// 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 > {
80
93
debug_assert_eq ! ( OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS , MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
81
94
if witness. len ( ) < 2 {
82
95
return None ;
0 commit comments