-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbalance
More file actions
executable file
·109 lines (104 loc) · 3.69 KB
/
balance
File metadata and controls
executable file
·109 lines (104 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Show an extremely abbreviated summary of the current account line balances and
# XRP balance. Account can be provided on the command line or stored in a file
# called "ripple-account.txt" in the same directory that this script runs from.
defaultaccount=( rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh )
for accountfile in "$( dirname $0 )/ripple-accounts.txt" \
"$( dirname $0)/ripple-account.txt"
do
if [ -r ${accountfile} ]
then
defaultaccount=( $(cat ${accountfile}) )
break
fi
done
RIPPLED=${1:-$( dirname $0 )/rippled}
RPC_IP=${2:-127.0.0.1}
RPC_PORT=${3:-51235}
shift 3
accounts=( ${@:-${defaultaccount[@]}} )
name()
{
curl https://data.ripple.com/v2/gateways/$1 2>/dev/null | \
json_pp | \
gawk '(/"name"/) { print $3; }'
}
for account in ${accounts[@]}
do
# echo $account
${RIPPLED} -q \
--rpc_ip=${RPC_IP}:${RPC_PORT} account_lines ${account} "" \
validated | grep -e balance -e currency -e account \
-e limit -e quality -e error_message \
| gawk '
function currencyname(c)
{
switch(c)
{
case "534F4C4F00000000000000000000000000000000":
return "SOLO";
case "0158415500000000C1F76FF6ECB0BAC600000000":
return "XAU";
case "524C555344000000000000000000000000000000":
return "RLUSD";
default: return c;
}
}
function gatewayname(c)
{
switch(c)
{
case "razqQKzJRdB4UxFPWf5NEpEG3WMkmwgcXA":
return "RippleChina";
case "r3ADD8kXSUKHd6zTCKfnKT3zV9EZHjzp1S":
return "RippleUnion";
case "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B" :
return "Bitstamp ";
case "rrh7rf1gV2pXAoqA8oYbpHd8TKv5ZQeo67" :
return "GBI ";
case "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq" :
return "Gatehub ";
case "rMAz5ZnK73nyNUL4foAvaxdreczCkG3vA6" :
return "Ripple Trade Japan";
case "r94s8px6kSw1uZ1MV98dhSRTvc6VMPoPcN" :
return "tokyojpy ";
case "rG6FZ31hDHN1K5Dkbma3PSB5uVCuVVRzfn" :
return "Bitso ";
case "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q" :
return "SnapSwap ";
case "rcA8X3TVMST1n3CJeAdGk1RdRCHii7N2h" :
case "rchGBxcD1A1C2tdxF6papQYZ8kjRKMYcL" :
case "rDAN8tzydyNfnNf2bfUQY6iR96UbpvNsze" :
case "rckzVpTnKpP4TJ1puQe827bV3X4oYtdTP" :
return "Gatehub Fifth";
case "rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz" :
return "Sologenic ";
case "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De" :
return "Ripple Stable";
default: return c;
}
}
{ sub(/^ */, ""); gsub(/[,"]/, "", $3); }
( /account/ ) { account = $3; }
( /balance/ ) { balance = $3; }
( /limit/ && $3 > limit ) { limit = $3; }
( /currency/ ) { currency = $3; }
(/quality_out/ && balance != 0 ) { print currencyname(currency) " / " gatewayname(account) " : " balance " / " limit; }
( balance == "" && account == "" ) { print; }
( /quality_out/ ) { balance=""; account=""; limit=0; }' \
&& ${RIPPLED} -q \
--rpc_ip=${RPC_IP}:${RPC_PORT} account_info ${account} validated \
| jq -rc '
if .error then
{ error, error_message }
elif .result.error then
.result |
{ error, error_message }
else
.result.account_data |
{ Account,
"Balance" : (.Balance | tonumber / 1000000),
"LastLedger" : .PreviousTxnLgrSeq
}
end'
done