Blockchain

class blocksci.Blockchain(loc, max_block=0)

Class representing the blockchain. This class is constructed by passing it a string representing a file path to your BlockSci data files generated by blocksci_parser

address_count(address_type: blocksci.address_type)int

Get an upper bound of the number of address of a given type (This reflects the number of type equivlant addresses of that type).

address_from_index(index: int, type: blocksci.address_type) → Address

Construct an address object from an address num and type

address_from_string(address_string: str) → Optional[Address]

Construct an address object from an address string

addresses(address_type: blocksci.address_type) → Union[blocksci.NonstandardAddressRange, blocksci.PubkeyAddressRange, blocksci.PubkeyHashAddressRange, blocksci.MultisigPubkeyRange, blocksci.ScriptHashAddressRange, blocksci.MultisigAddressRange, blocksci.OpReturnRange, blocksci.WitnessPubkeyHashAddressRange, blocksci.WitnessScriptHashAddressRange, blocksci.WitnessUnknownAddressRange]

Return a range of all addresses of the given type.

addresses_with_prefix(prefix: str)list

Find all addresses beginning with the given prefix

property blocks

Returns a range of all the blocks in the chain

property config_location

Returns the location of the configuration file that this Blockchain object represents.

property data_location

Returns the location of the data directory that this Blockchain object represents.

filter_blocks(filter_func, start=None, end=None, cpu_count=4)

Return all blocks in range which match the given criteria

filter_blocks_legacy(filter_func, start=None, end=None, cpu_count=4)

Return all blocks in range which match the given criteria

filter_txes(filter_func, start=None, end=None, cpu_count=4)

Return all transactions in range which match the given criteria

filter_txes_legacy(filter_func, start=None, end=None, cpu_count=4)

Return all transactions in range which match the given criteria

heights_to_dates(df)

Convert a pandas data frame with a block height index into a frame with a block time index

is_parser_running()bool

Returns whether the parser is currently operating on this chain’s data directory.

map_blocks(block_func, start=None, end=None, cpu_count=4)

Runs the given function over each block in range and returns a list of the results

mapreduce_block_ranges(map_func, reduce_func, init=(no default), start=None, end=None, cpu_count=4)

Initialized multithreaded map reduce function over a stream of block ranges

mapreduce_blocks(map_func, reduce_func, init=(no default), start=None, end=None, cpu_count=4)

Initialized multithreaded map reduce function over a stream of blocks

mapreduce_txes(map_func, reduce_func, init=(no default), start=None, end=None, cpu_count=4)

Initialized multithreaded map reduce function over a stream of transactions

range(start, end=None)blocksci.BlockRange

Return the range of blocks mined between the given dates

reload()None

Reload the blockchain to make new blocks visible (Invalidates current BlockSci objects).

tx_with_hash(tx_hash: str)blocksci.Tx

This functions gets the transaction with given hash.

tx_with_index(index: int)blocksci.Tx

This functions gets the transaction with given index.