#!/usr/bin/perl # # Copright (c) 2021 Jahway603 & The Hush Developers under GPLv3 License # # forked from https://github.com/ChileBob/ShieldedOutputs # Copyright (c) 2021 ChileBob under MIT License # package common; use Data::Dumper; use JSON; my $node_client = 'hush-cli'; # hush-cli client #my $block_height = 570000; # start block my $block_height = 699000; # changed start block my $blockchaininfo = node_cli('getblockchaininfo'); print "Block\tEpoch\tShieldedOutputs\n"; while ( $block_height < $blockchaininfo->{'blocks'} ) { my $block = node_cli("getblock $block_height 2"); my $shielded_outputs = 0; foreach my $txn ( @{ $block->{'tx'} } ) { if ($txn->{'vShieldedOutput'}) { # shielded outputs $shielded_outputs += scalar @{$txn->{'vShieldedOutput'}}; } } print "$block_height\t$block->{'time'}\t$shielded_outputs\n"; $block_height++; } ####################################################################################################################################### # # Safely parse JSON string # sub read_json { my ($raw) = @_; eval { decode_json($raw) }; # eval first, bad JSON kills puppies if (!$@) { return(decode_json($raw)); } } ############################################################################################################################################################################# # # query node client, return JSON # sub node_cli { my ($command, $data) = @_; my $response = `$node_client $command $data 2>/dev/null`; # every time you use backticks a puppy dies :-( my $json = read_json($response); # bad JSON kills puppies too if ($json) { return($json); } }