From 8d022201f3763b0c5b9551cf6a2734c364bc7106 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 3 Dec 2017 22:43:18 -0800 Subject: [PATCH] Make viewing a hushlist memo possible --- lib/Hush/List.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/Hush/List.pm b/lib/Hush/List.pm index 60486fe..0527a38 100644 --- a/lib/Hush/List.pm +++ b/lib/Hush/List.pm @@ -6,6 +6,7 @@ use Try::Tiny; use File::Spec::Functions; use Hush::Util qw/barf is_valid_zaddr/; use File::Slurp; +use Hush::Memo; use Hush::Logger qw/debug/; use Hush::Contact; use Data::Dumper; @@ -163,7 +164,8 @@ sub show { # 2) any xtns TO this zaddr are Hushlist memos # 3) iterate over these and grab memo field (only available locally on the # full node which has the xtn, unles txindex=1 on hush full node!) - my @memos = find_memos($name); + #TODO: sometimes you can send from a taddr + my @memos = find_memos($name, $sending_zaddr); if (@memos) { print "Found memos!\n"; @@ -175,6 +177,7 @@ sub show { sub find_memos { my ($name,$zaddr) = @_; + #warn "looking up xtns for $zaddr"; my @xtns = $rpc->z_listreceivedbyaddress($zaddr); if (@xtns) { @@ -183,8 +186,21 @@ sub find_memos { my @memos = map { Hush::Memo->new($rpc, $_) } @xtns; # debugging - for my $xtn (@xtns) { - printf "txid=%s memo=%s\n", $xtn->{txid}, $xtn->{memo}; + for my $xtn (map { $_->[0] } @xtns) { + #printf "txid=%s memo=%s\n", $xtn->{txid}, $xtn->{memo}; + my $txid = $xtn->{txid}; + my $memo = pack('h*', $xtn->{memo}); + printf "=" x 80; + print "\n"; + printf <