@@ -105,8 +105,14 @@ def to_bytes(self) -> bytes:
105105 pub_key = bytes .fromhex (self .pubkey .to_x_only_hex ())
106106 return leaf_version + pub_key + self .merkle_path
107107
108- def to_hex (self ):
109- """Converts object to hexadecimal string"""
108+ def to_hex (self ) -> str :
109+ """Converts object to hexadecimal string
110+
111+ Returns
112+ -------
113+ str
114+ The control block as a hexadecimal string
115+ """
110116 return b_to_h (self .to_bytes ())
111117
112118
@@ -302,8 +308,17 @@ def get_transaction_length(data: bytes) -> int:
302308
303309
304310def is_address_bech32 (address : str ) -> bool :
305- """
306- Returns if an address (string) is bech32 or not
311+ """Returns if an address (string) is bech32 or not
312+
313+ Parameters
314+ ----------
315+ address : str
316+ The address to check
317+
318+ Returns
319+ -------
320+ bool
321+ True if the address is bech32, False otherwise
307322 """
308323 if not address :
309324 return False
@@ -398,15 +413,39 @@ def calculate_tweak(
398413
399414
400415def tapleaf_tagged_hash (script : Script ) -> bytes :
401- """Calculates the tagged hash for a tapleaf"""
416+ """Calculates the tagged hash for a tapleaf
417+
418+ Parameters
419+ ----------
420+ script : Script
421+ The script to calculate the tagged hash for
422+
423+ Returns
424+ -------
425+ bytes
426+ The tagged hash of the tapleaf
427+ """
402428 script_part = bytes ([LEAF_VERSION_TAPSCRIPT ]) + prepend_compact_size (
403429 script .to_bytes ()
404430 )
405431 return tagged_hash (script_part , "TapLeaf" )
406432
407433
408434def tapbranch_tagged_hash (thashed_a : bytes , thashed_b : bytes ) -> bytes :
409- """Calculates the tagged hash for a tapbranch"""
435+ """Calculates the tagged hash for a tapbranch
436+
437+ Parameters
438+ ----------
439+ thashed_a : bytes
440+ First tagged hash
441+ thashed_b : bytes
442+ Second tagged hash
443+
444+ Returns
445+ -------
446+ bytes
447+ The tagged hash of the tapbranch
448+ """
410449 # order - smaller left side
411450 if thashed_a < thashed_b :
412451 return tagged_hash (thashed_a + thashed_b , "TapBranch" )
@@ -555,4 +594,4 @@ def i_to_b(i: int) -> bytes:
555594 return i .to_bytes (byte_length , "big" )
556595
557596
558- # TODO are these required - maybe bytestoint and inttobytes are only required?!?
597+ # TODO are these required - maybe bytestoint and inttobytes are only required?!?
0 commit comments