Update to take an optional file of addresses
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user