Outputs all shielded transactions from BlockSci
import blocksci
import csv
chain = blocksci.Blockchain("/home/gareth/blocksci/zcash-data")
migration_tx = 0
sprout_tx = 0
sprout_fully_shielded = 0
sapling_tx = 0
sapling_fully_shielded = 0
with open('tx_data.csv', mode='w') as tx_data:
transaction_writer = csv.writer(
tx_data, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
transaction_writer.writerow(['Type', 'Hash', 'BlockTime'])
# Loop through all blocks - can filter by starting and end heights
for blk in chain:
for tx in blk:
if tx.is_sproutshielded and tx.is_saplingshielded:
# Migration transactions are unique in having both types
migration_tx += 1
transaction_writer.writerow(['migration', tx.hash, tx.block_time])
elif tx.is_saplingshielded: # this includes shielded, shielding, deshieling
sapling_tx += 1
# Only look for fully shielded
if tx.input_count == 0 and tx.output_count == 0:
sapling_fully_shielded += 1
transaction_writer.writerow(
['sapling', tx.hash, tx.block_time])
elif tx.is_sproutshielded: # this includes shielded, shielding, deshieling
sprout_tx += 1
# Only look for fully shielded
if tx.input_count == 0 and tx.output_count == 0:
sprout_fully_shielded += 1
transaction_writer.writerow(
['sprout', tx.hash, tx.block_time])
print("All Migration transactions: {}".format(migration_tx))
print("All Sprout transactions: {}".format(sprout_tx))
print("Sprout fully shielded transactions: {}".format(sprout_fully_shielded))
print("All Sapling transactions: {}".format(sapling_tx))
print("Sapling fully shielded transactions: {}".format(sapling_fully_shielded))