From 668e060fc295c82c1efb47b24ab11d0ff2596874 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 22 Feb 2019 03:18:50 -0800 Subject: [PATCH] Hush sprout stats --- bin/hush_stats | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/hush_stats diff --git a/bin/hush_stats b/bin/hush_stats new file mode 100755 index 0000000..dc80d0b --- /dev/null +++ b/bin/hush_stats @@ -0,0 +1,27 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Data::Dumper; +use JSON::Any; + +# TODO: These RPCs are not atomic! coinsupply RPC from KMD could be ported +# But this is just to estimate Sprout %, so seems OK +my $j = JSON::Any->new; +my $json = qx/hush-cli gettxoutsetinfo/; +my $info = $j->decode($json); + +warn Dumper [ 'gettxoutsetinfo=', $info ] if $ENV{DEBUG}; + +my $total_supply = $info->{total_amount}; +my $snapshot = qx/hush-cli getsnapshot/; +my $taddr_total = $snapshot->{total}; + +warn Dumper [ 'getsnapshot=', $info ] if $ENV{DEBUG}; + +my $shielded = $total_supply - $taddr_total; +if ($shielded < 0.0) { + die "Inconsistent total supply! $total_supply in $taddr_total taddrs"; +} +# All shielded notes are Sprout on this chain +my $shielded_pct = $shielded / $total_supply; +printf "%.8f, %.2f\n", $shielded, $shielded_pct;