Browse Source

Fucking JSON

master
Jonathan "Duke" Leto 7 years ago
parent
commit
0b87a3b8bb
  1. 4
      lib/Hush/List.pm
  2. 4
      lib/Hush/Logger.pm
  3. 2
      lib/Hush/RPC.pm

4
lib/Hush/List.pm

@ -7,6 +7,7 @@ use File::Spec::Functions;
use Hush::Util qw/barf/; use Hush::Util qw/barf/;
use File::Slurp; use File::Slurp;
use Hush::Logger qw/debug/; use Hush::Logger qw/debug/;
use JSON;
# as per z_sendmany rpc docs # as per z_sendmany rpc docs
my $MAX_RECIPIENTS = 54; my $MAX_RECIPIENTS = 54;
@ -297,7 +298,8 @@ sub send_message {
# }, ... ] # }, ... ]
# 3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times. # 3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.
# 4. fee (numeric, optional, default=0.0001) The fee amount to attach to this transaction. # 4. fee (numeric, optional, default=0.0001) The fee amount to attach to this transaction.
my $opid = $rpc->z_sendmany($from, [ $list_addrs ]); my $json = encode_json( $list_addrs );
my $opid = $rpc->z_sendmany($from, [$json]);
if (defined $opid) { if (defined $opid) {
debug("send_message: z_sendmany opid=$opid from $from"); debug("send_message: z_sendmany opid=$opid from $from");
} else { } else {

4
lib/Hush/Logger.pm

@ -14,7 +14,9 @@ sub debug {
my $time = localtime(); my $time = localtime();
my $debug = catfile($HUSHLIST_CONFIG_DIR, 'debug.log'); my $debug = catfile($HUSHLIST_CONFIG_DIR, 'debug.log');
open(my $log, '>>', $debug) or barf("Could not open $debug for writing!!!"); open(my $log, '>>', $debug) or barf("Could not open $debug for writing!!!");
print $log "[$time] [$$] $msg"; my $stuff = "[$time] [$$] $msg\n";
print $stuff;
print $log $stuff;
close $log; close $log;
} }

2
lib/Hush/RPC.pm

@ -13,6 +13,8 @@ sub new {
host => $host, host => $host,
user => $ENV{HUSH_RPC_USERNAME} || "hush", user => $ENV{HUSH_RPC_USERNAME} || "hush",
password => $ENV{HUSH_RPC_PASSWORD} || "hushmegently", password => $ENV{HUSH_RPC_PASSWORD} || "hushmegently",
# rpc calls, how do they work?
debug => 1,
); );
my $info = $rpc->getinfo; my $info = $rpc->getinfo;
if ($info) { if ($info) {

Loading…
Cancel
Save