@@ -824,21 +824,33 @@ def taproot_tree_helper(scripts):
824
824
h = TaggedHash ("TapBranch" , left_h + right_h )
825
825
return (left + right , h )
826
826
827
+ # A TaprootInfo object has the following fields:
828
+ # - scriptPubKey: the scriptPubKey (witness v1 CScript)
829
+ # - inner_pubkey: the inner pubkey (32 bytes)
830
+ # - negflag: whether the pubkey in the scriptPubKey was negated from inner_pubkey+tweak*G (bool).
831
+ # - tweak: the tweak (32 bytes)
832
+ # - leaves: a dict of name -> TaprootLeafInfo objects for all known leaves
827
833
TaprootInfo = namedtuple ("TaprootInfo" , "scriptPubKey,inner_pubkey,negflag,tweak,leaves" )
834
+
835
+ # A TaprootLeafInfo object has the following fields:
836
+ # - script: the leaf script (CScript or bytes)
837
+ # - version: the leaf version (0xc0 for BIP342 tapscript)
838
+ # - merklebranch: the merkle branch to use for this leaf (32*N bytes)
828
839
TaprootLeafInfo = namedtuple ("TaprootLeafInfo" , "script,version,merklebranch" )
829
840
830
841
def taproot_construct (pubkey , scripts = None ):
831
842
"""Construct a tree of Taproot spending conditions
832
843
833
- pubkey: an ECPubKey object for the internal pubkey
844
+ pubkey: a 32-byte xonly pubkey for the internal pubkey (bytes)
834
845
scripts: a list of items; each item is either:
835
- - a (name, CScript) tuple
836
- - a (name, CScript, leaf version ) tuple
846
+ - a (name, CScript or bytes, leaf version ) tuple
847
+ - a (name, CScript or bytes ) tuple (defaulting to leaf version 0xc0)
837
848
- another list of items (with the same structure)
838
- - a function, which specifies how to compute the hashing partner
839
- in function of the hash of whatever it is combined with
849
+ - a list of two items; the first of which is an item itself, and the
850
+ second is a function. The function takes as input the Merkle root of the
851
+ first item, and produces a (fictitious) partner to hash with.
840
852
841
- Returns: script (sPK or redeemScript), tweak, {name:(script, leaf version, negation flag, innerkey, merklepath), ...}
853
+ Returns: a TaprootInfo object
842
854
"""
843
855
if scripts is None :
844
856
scripts = []
0 commit comments