Skip to content

Commit e6660be

Browse files
committed
Merge #173: Make a couple of the functions on CheckedHrpstring struct public
bde1df5 Make validate_witness_program_length public (Tobin C. Harding) bdd6855 Make validate_padding public (Tobin C. Harding) Pull request description: These two functions are useful to users of the lib, lets make them public. ACKs for top commit: apoelstra: ACK bde1df5 Tree-SHA512: dc59f120a9cee1ae00007e14901feae3127e54d0f9d6f34204fc0909d890a84a3c9357066600f0ca203e21b91825365d32284e5acabde3f662aae25f772e7194
2 parents de97a8e + bde1df5 commit e6660be

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/primitives/decode.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl<'s> CheckedHrpstring<'s> {
397397
let witness_version = Fe32::from_char(self.ascii[0].into()).unwrap();
398398
self.ascii = &self.ascii[1..]; // Remove the witness version byte.
399399

400-
self.validate_padding()?;
400+
self.validate_segwit_padding()?;
401401
self.validate_witness_program_length(witness_version)?;
402402

403403
Ok(SegwitHrpstring { hrp: self.hrp(), witness_version, ascii: self.ascii })
@@ -410,7 +410,8 @@ impl<'s> CheckedHrpstring<'s> {
410410
/// From BIP-173:
411411
/// > Re-arrange those bits into groups of 8 bits. Any incomplete group at the
412412
/// > end MUST be 4 bits or less, MUST be all zeroes, and is discarded.
413-
fn validate_padding(&self) -> Result<(), PaddingError> {
413+
#[inline]
414+
pub fn validate_segwit_padding(&self) -> Result<(), PaddingError> {
414415
if self.ascii.is_empty() {
415416
return Ok(()); // Empty data implies correct padding.
416417
}
@@ -443,7 +444,8 @@ impl<'s> CheckedHrpstring<'s> {
443444
/// Validates the segwit witness length rules.
444445
///
445446
/// Must be called after the witness version byte is removed from the data part.
446-
fn validate_witness_program_length(
447+
#[inline]
448+
pub fn validate_witness_program_length(
447449
&self,
448450
witness_version: Fe32,
449451
) -> Result<(), WitnessLengthError> {

0 commit comments

Comments
 (0)