@@ -387,7 +387,7 @@ def getblockheader(self, block_hash, verbose=False):
387387 try :
388388 block_hash = b2lx (block_hash )
389389 except TypeError :
390- raise TypeError ('%s.getblockheader(): block_hash must be bytes; got %r instance' %
390+ raise TypeError ('%s.getblockheader(): block_hash must be bytes or str ; got %r instance' %
391391 (self .__class__ .__name__ , block_hash .__class__ ))
392392 try :
393393 r = self ._call ('getblockheader' , block_hash , verbose )
@@ -418,7 +418,6 @@ def getblockfilter(self, block_hash, filter_type="basic"):
418418 Default filter_type must be changed
419419 #UNTESTED
420420 """
421- # ALLOWED FOR str blockhash as well
422421 if type (block_hash ) != str :
423422 try :
424423 block_hash = b2lx (block_hash )
@@ -476,9 +475,9 @@ def getblockstats(self, hash_or_height, *args):
476475 # On clients before PR #17831, passing hash as bytes will result in Block not found
477476 """Return a JSON object containing block stats"""
478477
479- try :
478+ if isinstance ( hash_or_height , bytes ):
480479 hval = b2lx (hash_or_height )
481- except TypeError :
480+ else : #int or str of block_hash or height
482481 hval = hash_or_height
483482 try :
484483 r = self ._call ('getblockstats' , hval , args )
@@ -517,7 +516,6 @@ def getmempoolancestors(self, txid, verbose=False):
517516
518517 def getmempooldescendants (self , txid , verbose = False ):
519518 """Returns a list of txids for descendant transactions"""
520- # Added str capacity
521519 if type (txid ) != str :
522520 try :
523521 txid = b2lx (txid )
@@ -561,12 +559,11 @@ def getrawmempool(self, verbose=False):
561559
562560 def gettxout (self , outpoint , includemempool = True ):
563561 """Return details about an unspent transaction output.
564-
562+ outpoint - COutPoint or tuple (<txid>, n)
565563 Raises IndexError if outpoint is not found or was spent.
566564
567565 includemempool - Include mempool txouts
568566 """
569- # CHANGED TO ALLOW TUPLE (str(<txid>), n)
570567 if isinstance (outpoint , COutPoint ):
571568 r = self ._call ('gettxout' , b2lx (outpoint .hash ), outpoint .n , includemempool )
572569 else :
@@ -737,7 +734,6 @@ def submitblock(self, block, params=None):
737734 params is optional and is currently ignored by bitcoind. See
738735 https://en.bitcoin.it/wiki/BIP_0022 for full specification.
739736 """
740- # Allow for hex directly
741737 if type (block ) == str :
742738 hexblock = block
743739 else :
@@ -858,7 +854,7 @@ def createpsbt(self, vins, vouts, data="", locktime=0, replaceable=False):
858854 vout = i .prevout .n
859855 sequence = i .nSequence
860856 ins .append ({"txid" : txid , "vout" : vout , "sequence" : sequence })
861- vins = ins #Allow for JSON data to be passed straight to vins
857+ vins = ins
862858 if isinstance (vouts [0 ], COutPoint ):
863859 outs = []
864860 for o in vouts :
@@ -931,7 +927,6 @@ def getrawtransaction(self, txid, verbose=False, block_hash=None):
931927 enabled the transaction may not be available.
932928 """
933929 #Timeout issues depending on tx / machine
934- # Allow handling strings. Desirable?
935930 if type (txid ) != str :
936931 txid = b2lx (txid )
937932 if type (block_hash ) != str :
@@ -1043,12 +1038,11 @@ def signrawtransactionwithkey(self, tx, privkeys, prevtxs=None, sighashtype=None
10431038 prevtxs - JSON object containing info
10441039 sighashtype - numeric sighashtype default=SIGHASH_ALL
10451040 """
1046- # THIS ALLOWS FOR str, bytes, and CBitcoinSecret. desirable?
10471041 if type (tx ) != str :
10481042 tx = hexlify (tx .serialize ())
1049- if isinstance (privkeys [0 ], CBitcoinSecret ): # IS THIS CORRECT
1043+ if isinstance (privkeys [0 ], CBitcoinSecret ):
10501044 privkeys = [str (sk ) for sk in privkeys ]
1051- elif isinstance (privkeys [0 ], bytes ): # ALLOW FOR BYTES
1045+ elif isinstance (privkeys [0 ], bytes ):
10521046 privkeys = [sk .hex () for sk in privkeys ]
10531047 r = self ._call ('signrawtransactionwithkey' , privkeys , prevtxs , )
10541048 r ['tx' ] = CTransaction .deserialize (unhexlify (r ['hex' ]))
@@ -1098,12 +1092,11 @@ def deriveaddresses(self, descriptor, _range=None):
10981092 """Returns addresses from descriptor
10991093
11001094 """
1101- #TODODescriptors need Implementing
1095+ #TODO Descriptors need Implementing
11021096 return self ._call ('deriveaddresses' , descriptor , _range )
11031097
11041098 def estimatesmartfee (self , conf_target , estimate_mode = None ):
11051099 """Returns a JSON object with feerate, errors, and block estimate
1106- #Fix description?
11071100 conf_target - attempted number of blocks from current tip to place tx
11081101 estimate_mode:
11091102 "UNSET"
@@ -1150,7 +1143,6 @@ def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
11501143 #TODO see if CPubKey.__str__() is used elsewhere or can be changed.
11511144 if isinstance (keys [0 ], CBitcoinAddress ):
11521145 keys = [str (k ) for k in keys ]
1153- #included CPubKey for clarity. Could possibly remove
11541146 elif isinstance (keys [0 ], (CPubKey , bytes )):
11551147 keys = [k .hex () for k in keys ]
11561148 r = self ._call ('addmultisigaddress' , nrequired , keys , label , address_type )
0 commit comments