MCPcopy
hub / github.com/petertodd/python-bitcoinlib / getrawtransaction

Method getrawtransaction

bitcoin/rpc.py:571–604  ·  view source on GitHub ↗

Return transaction with hash txid Raises IndexError if transaction not found. verbose - If true a dict is returned instead with additional information on the transaction. block_hash - Hash of the block containing the transaction (required when transaction n

(self, txid, verbose=False, block_hash=None)

Source from the content-addressed store, hash-verified

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

Callers 1

publish-text.pyFile · 0.45

Calls 5

b2lxFunction · 0.90
lxFunction · 0.90
unhexlify_strFunction · 0.85
_callMethod · 0.45
deserializeMethod · 0.45

Tested by

no test coverage detected