Created
July 23, 2019 23:11
-
-
Save garethtdavies/b95d59d081896ad5f667e82f50c68335 to your computer and use it in GitHub Desktop.
Outputs all shielded transactions from BlockSci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment