| 1 | package Hush::RPC; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Bitcoin::RPC::Client; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Hush::Util qw/barf/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::Spec::Functions; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #use Carp::Always; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use URL::Encode qw/url_encode/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | my $port = $ENV{HUSH_RPC_PORT} || 8822; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'HUSH_RPC_PORT'} || 8822
MC/DC0%0/1
$ENV{'HUSH_RPC_PORT'} || 8822
$ENV{'HUSH_RPC_PORT'}
Truth table0%0/2
A
A= $ENV{'HUSH_RPC_PORT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | my $host = $ENV{HUSH_RPC_HOST} || "127.0.0.1"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'HUSH_RPC_HOST'} || '127.0.0.1'
MC/DC0%0/1
$ENV{'HUSH_RPC_HOST'} || '127.0.0.1'
$ENV{'HUSH_RPC_HOST'}
Truth table0%0/2
A
A= $ENV{'HUSH_RPC_HOST'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my $HOME = $ENV{HOME}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my $config = catfile($HOME, qw/.hush hush.conf/); | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my ($user,$password) = ('',''); | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | if (-e $config) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | open(my $fh, '<', $config) or die $!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | while(<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if (m!^rpcuser=(.*)$!) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | $user = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | }elsif (m!^rpcpassword=(.*)$!) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # default Hush instructions use base62 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $password = url_encode($1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | last if ($user && $password); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$user and $password
MC/DC0%0/2
$user and $password
$user
$password
Truth table0%0/3
A and B
A= $userB= $password
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my $rpc = Bitcoin::RPC::Client->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | port => $port, # set this to 18822 to use testnet | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | user => $ENV{HUSH_RPC_USERNAME} || $user, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | password => $ENV{HUSH_RPC_PASSWORD} || $password, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # rpc calls, how do they work? | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | debug => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | debug => $ENV{HUSH_DEBUG} || 0, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$ENV{'HUSH_RPC_USERNAME'} || $user
$ENV{'HUSH_RPC_PASSWORD'} || $password
$ENV{'HUSH_DEBUG'} || 0
MC/DC0%0/2
$ENV{'HUSH_RPC_USERNAME'} || $user
$ENV{'HUSH_RPC_USERNAME'}
$user
MC/DC0%0/2
$ENV{'HUSH_RPC_PASSWORD'} || $password
$ENV{'HUSH_RPC_PASSWORD'}
$password
MC/DC0%0/1
$ENV{'HUSH_DEBUG'} || 0
$ENV{'HUSH_DEBUG'}
Truth table0%0/3
A || B
A= $ENV{'HUSH_RPC_USERNAME'}B= $user
Truth table0%0/3
A || B
A= $ENV{'HUSH_RPC_PASSWORD'}B= $password
Truth table0%0/2
A
A= $ENV{'HUSH_DEBUG'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $info = $rpc->getinfo; | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($info) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $rpc, | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $coins = { | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8822 => 'HUSH', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 18822 => 'TUSH', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 7770 => 'KMD', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 17770 => 'KMD-test', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 8232 => 'ZEC', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 18232 => 'TAZ', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1989 => 'BTCZ', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 11989 => 'BTCZ-test', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $sites = { | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | "HUSH" => 'https://myhush.org', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | "TUSH" => 'https://myhush.org', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | "KMD" => 'https://komodoplatform.com', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | "ZEC" => 'https://z.cash', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | "TAZ" => 'https://z.cash', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $coin = $coins->{$port} || 'cryptocoin'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$coins->{$port} || 'cryptocoin'
MC/DC0%0/1
$coins->{$port} || 'cryptocoin'
$coins->{$port}
Truth table0%0/2
A
A= $coins->{$port}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $site = $sites->{$coin} || 'https://github.com/leto/hushlist'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$sites->{$coin} || 'https://github.com/leto/hushlist'
MC/DC0%0/1
$sites->{$coin} || 'https://github.com/leto/hushlist'
$sites->{$coin}
Truth table0%0/2
A
A= $sites->{$coin}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | print "Unable to make RPC connection to $coin full node at $host:$port !\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | print "Your $coin full node is not running, or not accessible at that port :(\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | print "See $site for more information about this privacy coin\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | exit(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||||||||