From cb60ecaef95123f886de1fe6752b7403e873993e Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 19 Nov 2023 08:32:23 -0500 Subject: [PATCH] Update to take an optional file of addresses --- util/gen_scriptpubs.pl | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/util/gen_scriptpubs.pl b/util/gen_scriptpubs.pl index 765bca54c..0127e1564 100755 --- a/util/gen_scriptpubs.pl +++ b/util/gen_scriptpubs.pl @@ -7,17 +7,34 @@ use strict; use JSON; # Generates taddrs/scriptpubs for testing the decentralized devtax -# all generated taddrs/scriptpubs will be part of existing wallet.dat +# where all generated taddrs/scriptpubs will be part of existing wallet.dat +# OR generates scriptpubs for addresses if given a file argument +# addresses must be one-per-line in the file -my $N = shift || 20; +my $file = shift; +my $N = 20; # hushd is currently hardcoded to use 20 addresses my $hush = "./src/hush-cli"; my $getnew = "$hush getnewaddress"; my $validate = "$hush validateaddress"; +my $fh; + +if($file) { + open($fh, '<', $file) or die $!; +} print "std::string DEVTAX_DATA[DEVTAX_NUM][2] = {\n"; for my $i (1 .. $N) { - my $taddr = qx{$getnew}; + my $taddr; + if ($file) { + $taddr = <$fh>; + unless($taddr) { + print "Error: Less than $N addresses in $file !\n"; + exit(1); + } + } else { + $taddr = qx{$getnew}; + } chomp $taddr; my $j = qx{$validate $taddr}; my $json = decode_json($j); @@ -26,3 +43,4 @@ for my $i (1 .. $N) { } print "};\n"; +close($fh) if $file;