@@ -566,24 +566,30 @@ def getrawmempool(self, verbose=False):
566
566
r = [lx (txid ) for txid in r ]
567
567
return r
568
568
569
- def getrawtransaction (self , txid , verbose = False ):
569
+ def getrawtransaction (self , txid , verbose = False , block_hash = None ):
570
570
"""Return transaction with hash txid
571
571
572
572
Raises IndexError if transaction not found.
573
573
574
574
verbose - If true a dict is returned instead with additional
575
575
information on the transaction.
576
576
577
+ block_hash - Hash of the block containing the transaction
578
+ (required when transaction not currently indexed by Bitcoin Core)
579
+
577
580
Note that if all txouts are spent and the transaction index is not
578
581
enabled the transaction may not be available.
579
582
"""
580
583
try :
581
- r = self ._call ('getrawtransaction' , b2lx (txid ), 1 if verbose else 0 )
584
+ if block_hash is None :
585
+ r = self ._call ('getrawtransaction' , b2lx (txid ), 1 if verbose else 0 )
586
+ else :
587
+ r = self ._call ('getrawtransaction' , b2lx (txid ), 1 if verbose else 0 , b2lx (block_hash ))
582
588
except InvalidAddressOrKeyError as ex :
583
589
raise IndexError ('%s.getrawtransaction(): %s (%d)' %
584
590
(self .__class__ .__name__ , ex .error ['message' ], ex .error ['code' ]))
585
591
if verbose :
586
- r ['tx' ] = CTransaction .deserialize (unhexlify_str (r ['hex' ]))
592
+ r ['tx' ] = CTransaction .deserialize (unhexlify (r ['hex' ]))
587
593
del r ['hex' ]
588
594
del r ['txid' ]
589
595
del r ['version' ]
@@ -592,8 +598,7 @@ def getrawtransaction(self, txid, verbose=False):
592
598
del r ['vout' ]
593
599
r ['blockhash' ] = lx (r ['blockhash' ]) if 'blockhash' in r else None
594
600
else :
595
- r = CTransaction .deserialize (unhexlify_str (r ))
596
-
601
+ r = CTransaction .deserialize (unhexlify (r ))
597
602
return r
598
603
599
604
def getreceivedbyaddress (self , addr , minconf = 1 ):
0 commit comments