Skip to content

Commit 2e4fab0

Browse files
author
Antoine Riard
committed
Increase visibility of protocol-level consts
1 parent 505102d commit 2e4fab0

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ use core::ops::Deref;
4141
use crate::chain;
4242
use 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 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.
4953
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;
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 claim as determined by analyzing 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

7790
impl 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

Comments
 (0)