From 614b80a069a4241b402d96e210f612efaf31661e Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 5 Nov 2017 20:13:25 -0800 Subject: [PATCH] create new zaddr/taddr when creating a new config file --- bin/hushlist | 4 ++-- lib/Hush/List.pm | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/hushlist b/bin/hushlist index 37fe2bf..88e268e 100755 --- a/bin/hushlist +++ b/bin/hushlist @@ -20,7 +20,6 @@ my $total_balance = $balance->{total}; print "Hushlist running on $chain chain, $blocks blocks\n"; print "Balances: transparent $tbalance HUSH, private $zbalance HUSH\n"; -exit; # we only need one my $list = Hush::List->new; @@ -34,6 +33,7 @@ my $COMMANDS = { "send" => \&send, }; run(); +exit; sub help { print "It would be nice to give some help\n"; @@ -42,7 +42,7 @@ sub help { sub contact { my $cmd = shift || ''; if ($cmd eq 'new') { - # add a hust contact, yay + # add a hush contact, yay my ($name,$zaddr) = @ARGV; die Dumper [ $name, $zaddr ]; } diff --git a/lib/Hush/List.pm b/lib/Hush/List.pm index 5aed72f..e44d323 100644 --- a/lib/Hush/List.pm +++ b/lib/Hush/List.pm @@ -54,11 +54,20 @@ sub create_default_conf { my ($list_conf) = @_; my $time = time; open my $fh, ">", $list_conf or die "Could not write file $list_conf ! : $!"; - print $fh "# hushlist config\n"; - print $fh "funding_zaddr=\n"; - print $fh "introducer_zaddr=\n"; + + # when we create a brand new conf, we create brand new funding+nym addrs + my $rpc = Hush::RPC->new; + my $funding_zaddr = $rpc->z_getnewaddress; + die "Unable to create funding zaddr" unless $funding_zaddr; + + my $pseudonym_taddr = $rpc->getnewaddress; + die "Unable to create pseudonym taddr" unless $pseudonym_taddr; + + print $fh "# hushlist config v$Hush::List::VERSION\n"; + print $fh "funding_zaddr=$funding_zaddr\n"; + print $fh "pseudonym_taddr=$pseudonym_taddr\n"; print $fh "generated=$time\n"; - print $fh "generated_by=Hush::List $Hush::List::VERSION\n"; + close $fh; } sub new { @@ -114,7 +123,8 @@ sub new_list { sub add_zaddr { my ($self,$name,$zaddr) = @_; - die "Invalid zaddr=$zaddr" unless $zaddr; + $zaddr||= ''; + die "Invalid zaddr=$zaddr" unless $zaddr =~ m/^z/; my $lists = $self->{lists}; my $list = $lists->{$name};