@@ -387,7 +387,7 @@ def getblockheader(self, block_hash, verbose=False):
387
387
try :
388
388
block_hash = b2lx (block_hash )
389
389
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' %
391
391
(self .__class__ .__name__ , block_hash .__class__ ))
392
392
try :
393
393
r = self ._call ('getblockheader' , block_hash , verbose )
@@ -418,7 +418,6 @@ def getblockfilter(self, block_hash, filter_type="basic"):
418
418
Default filter_type must be changed
419
419
#UNTESTED
420
420
"""
421
- # ALLOWED FOR str blockhash as well
422
421
if type (block_hash ) != str :
423
422
try :
424
423
block_hash = b2lx (block_hash )
@@ -476,9 +475,9 @@ def getblockstats(self, hash_or_height, *args):
476
475
# On clients before PR #17831, passing hash as bytes will result in Block not found
477
476
"""Return a JSON object containing block stats"""
478
477
479
- try :
478
+ if isinstance ( hash_or_height , bytes ):
480
479
hval = b2lx (hash_or_height )
481
- except TypeError :
480
+ else : #int or str of block_hash or height
482
481
hval = hash_or_height
483
482
try :
484
483
r = self ._call ('getblockstats' , hval , args )
@@ -517,7 +516,6 @@ def getmempoolancestors(self, txid, verbose=False):
517
516
518
517
def getmempooldescendants (self , txid , verbose = False ):
519
518
"""Returns a list of txids for descendant transactions"""
520
- # Added str capacity
521
519
if type (txid ) != str :
522
520
try :
523
521
txid = b2lx (txid )
@@ -561,12 +559,11 @@ def getrawmempool(self, verbose=False):
561
559
562
560
def gettxout (self , outpoint , includemempool = True ):
563
561
"""Return details about an unspent transaction output.
564
-
562
+ outpoint - COutPoint or tuple (<txid>, n)
565
563
Raises IndexError if outpoint is not found or was spent.
566
564
567
565
includemempool - Include mempool txouts
568
566
"""
569
- # CHANGED TO ALLOW TUPLE (str(<txid>), n)
570
567
if isinstance (outpoint , COutPoint ):
571
568
r = self ._call ('gettxout' , b2lx (outpoint .hash ), outpoint .n , includemempool )
572
569
else :
@@ -737,7 +734,6 @@ def submitblock(self, block, params=None):
737
734
params is optional and is currently ignored by bitcoind. See
738
735
https://en.bitcoin.it/wiki/BIP_0022 for full specification.
739
736
"""
740
- # Allow for hex directly
741
737
if type (block ) == str :
742
738
hexblock = block
743
739
else :
@@ -858,7 +854,7 @@ def createpsbt(self, vins, vouts, data="", locktime=0, replaceable=False):
858
854
vout = i .prevout .n
859
855
sequence = i .nSequence
860
856
ins .append ({"txid" : txid , "vout" : vout , "sequence" : sequence })
861
- vins = ins #Allow for JSON data to be passed straight to vins
857
+ vins = ins
862
858
if isinstance (vouts [0 ], COutPoint ):
863
859
outs = []
864
860
for o in vouts :
@@ -931,7 +927,6 @@ def getrawtransaction(self, txid, verbose=False, block_hash=None):
931
927
enabled the transaction may not be available.
932
928
"""
933
929
#Timeout issues depending on tx / machine
934
- # Allow handling strings. Desirable?
935
930
if type (txid ) != str :
936
931
txid = b2lx (txid )
937
932
if type (block_hash ) != str :
@@ -1043,12 +1038,11 @@ def signrawtransactionwithkey(self, tx, privkeys, prevtxs=None, sighashtype=None
1043
1038
prevtxs - JSON object containing info
1044
1039
sighashtype - numeric sighashtype default=SIGHASH_ALL
1045
1040
"""
1046
- # THIS ALLOWS FOR str, bytes, and CBitcoinSecret. desirable?
1047
1041
if type (tx ) != str :
1048
1042
tx = hexlify (tx .serialize ())
1049
- if isinstance (privkeys [0 ], CBitcoinSecret ): # IS THIS CORRECT
1043
+ if isinstance (privkeys [0 ], CBitcoinSecret ):
1050
1044
privkeys = [str (sk ) for sk in privkeys ]
1051
- elif isinstance (privkeys [0 ], bytes ): # ALLOW FOR BYTES
1045
+ elif isinstance (privkeys [0 ], bytes ):
1052
1046
privkeys = [sk .hex () for sk in privkeys ]
1053
1047
r = self ._call ('signrawtransactionwithkey' , privkeys , prevtxs , )
1054
1048
r ['tx' ] = CTransaction .deserialize (unhexlify (r ['hex' ]))
@@ -1098,12 +1092,11 @@ def deriveaddresses(self, descriptor, _range=None):
1098
1092
"""Returns addresses from descriptor
1099
1093
1100
1094
"""
1101
- #TODODescriptors need Implementing
1095
+ #TODO Descriptors need Implementing
1102
1096
return self ._call ('deriveaddresses' , descriptor , _range )
1103
1097
1104
1098
def estimatesmartfee (self , conf_target , estimate_mode = None ):
1105
1099
"""Returns a JSON object with feerate, errors, and block estimate
1106
- #Fix description?
1107
1100
conf_target - attempted number of blocks from current tip to place tx
1108
1101
estimate_mode:
1109
1102
"UNSET"
@@ -1150,7 +1143,6 @@ def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
1150
1143
#TODO see if CPubKey.__str__() is used elsewhere or can be changed.
1151
1144
if isinstance (keys [0 ], CBitcoinAddress ):
1152
1145
keys = [str (k ) for k in keys ]
1153
- #included CPubKey for clarity. Could possibly remove
1154
1146
elif isinstance (keys [0 ], (CPubKey , bytes )):
1155
1147
keys = [k .hex () for k in keys ]
1156
1148
r = self ._call ('addmultisigaddress' , nrequired , keys , label , address_type )
0 commit comments