-
Notifications
You must be signed in to change notification settings - Fork 8
/
forkexploreq
212 lines (189 loc) · 9.22 KB
/
forkexploreq
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#! /usr/bin/env bash
function print_usage () {
echo "forkexplore help:"
echo
echo "SYNOPSIS: 100% local address explorer. Gets your coin history with calls to your farmer RPC port, which itself"
echo " queries your local blockchain db."
echo " Does not require wallet sync, just a running farmer."
echo " If -a switch is not specified, forkexplore explores your target receive address."
echo " The -a switch allows you to specify any other receive address you wish to explore. Works for hot or"
echo " cold wallet addresses."
echo " forexplore allows filtering with all the same date range options that forklog has. The default date"
echo " ranges can be modified in ftconfigs/config.forkexplore, or overridden for a single forkexplore run with"
echo " the -l, -s and -u switches described below."
echo " Transactions that appear in pairs in most other explorers, such as the 1/8 farmer / 7/8 pool rewards"
echo " that most forks split their farmed block rewards up as, are summed and displayed as a single total reward in"
echo " the transaction list for easier legibility."
echo " If you specify the -p switch, forkexplore will attempt to use your hot wallet first receive address"
echo " instead of your target receive address."
echo " If you specify the -o switch, forkexplore will attempt to use whatever address is specified in"
echo " ftconfigs/config.nftaddress.forkname, if one exists. This would primarily be used by people who farm forks"
echo " with NFT plots and want to check this address for recovered NFT pool rewards. It is not limited to this use,"
echo " however, and you can specify any address you like with -o | --otherkey."
echo " The -d switch will summarize by day, and the -m switch will summarize by month, with separate lines for"
echo " farmed and non-farmed totals in the detail."
echo
echo "PARAMETERS/SWITCHES:"
echo " forkname Required. All switches optional."
echo " -a <address> | --address <address> To explore any address, pass it with this switch."
echo " -l 10 | --lastxdays 10 Show only results for the last 10 days."
echo " -s YYYY-MM-DD | --startdate YYYY-MM-DD Do not show results prior to this date. If both this and --lastxdays"
echo " are set, this is used."
echo " -u | --enddate YYYY-MM-DD Do not show results after this date."
echo " -p | --plotkey If set, the first 'First Wallet Address' returned by 'forkname keys show'"
echo " will be used instead of target address."
echo " -o | --otherkey If set, any address specified in ftconfigs/config.nftaddress.forkname,"
echo " (presumably your nft recovery address) for the fork will be used instead."
echo " -d Summarize by day."
echo " -m Summarize by month. Defaults to starting from 2021-03."
echo " -help | --help Show this information again."
echo
exit 0
}
VALIDATEFORKNAME='Yes'
. ftinit.sh
FORKNAME=$1
CURRENTCONFIG=$FORKTOOLSHIDDENDIRS/.$FORKNAME/mainnet/config/config.yaml
PROCESSEF=$( getproclist )
. $FORKTOOLSDIR/ftcheckprocs.sh
if [[ $FARMERRUNNING == 0 ]]; then
echo "forkexplore requires a running $FORKNAME farmer process, which is not detected. Aborting."
exit
fi
if [[ $FULLNODERUNNING == 0 ]]; then
echo "forkexplore requires a running $FORKNAME full node process, which is not detected. Aborting."
exit
fi
STARTDATE=$FORKEXPLORESTARTDATE
LASTXDAYS=$FORKEXPLORELASTXDAYS
ENDDATE=$FORKEXPLOREENDDATE # Tomorrow
FIRSTLOOP=1
while [[ $# -gt 0 ]]; do
if [[ $FIRSTLOOP = 1 ]]; then
FORKNAME="$1"
FIRSTLOOP=0
shift
continue
fi
opt="$1"
case "$opt" in
"-a"|"--address" ) shift; SPECIFIEDADDRESS=$1; shift;;
"-l"|"--lastxdays" ) shift; LASTXDAYS="$1";SETLASTXDAYS="$1"; shift;;
"-s"|"--startdate" ) shift; STARTDATE="$1";SETSTARTDATE="$1"; shift;;
"-u"|"--enddate" ) shift; ENDDATE="$1"; ENDDATE=$(DateOffset +1 $ENDDATE); shift;;
"-o"|"--otherkey" ) NFTSWITCH='on'; shift;;
"-p"|"--plotkey" ) HOTSWITCH='on'; shift;;
"-d"|"--daily" ) SUMMARIZEBYDAY='Yes'; shift;;
"-m"|"--monthly" ) SUMMARIZEBYMONTH='Yes'; shift;;
"-help"|"--help" ) print_usage; exit;;
* ) echo 'ERROR: Invalid option: '$opt >&2
exit 1;;
esac
done
if [[ $LASTXDAYS != '' ]]; then
STARTFROM=$(echo "(($LASTXDAYS - 1))" | bc)
STARTFROM=$(DateOffset -${STARTFROM})
fi
if [[ $SETSTARTDATE == '' && $SUMMARIZEBYMONTH = 'Yes' ]]; then
STARTFROM='2021-03'
fi
if [[ $STARTDATE != '' && ($SETLASTXDAYS = '' || $SETSTARTDATE != '') ]]; then
STARTFROM=$STARTDATE
fi
. $FORKTOOLSDIR/ftrpcinclude.sh
if [[ $SUMMARIZEBYDAY == 'Yes' || $SUMMARIZEBYMONTH == 'Yes' ]]; then
OLDIFS=$IFS
IFS=''
if [[ $SUMMARIZEBYDAY == 'Yes' ]]; then
STARTFROM=$(echo $STARTFROM | cut -c1-10 )
ENDDATE=$(echo $ENDDATE | cut -c1-10 )
MERGEDCOINLIST=$( echo $MERGEDCOINLIST | awk '{print substr($1,1,10) " " $2 " " $3 " N/A N/A"}' )
else
STARTFROM=$(echo $STARTFROM | cut -c1-7 )
ORIGENDDATE=$ENDDATE
ENDDATE=$(MonthOffset +1)
ENDDATE=$(echo $ENDDATE | cut -c1-7 )
MERGEDCOINLIST=$( echo $MERGEDCOINLIST | awk '{print substr($1,1,7) " " $2 " " $3 " N/A N/A"}' )
fi
IFS=$OLDIFS
fi
BUILDEXPR=$(echo 'awk -v start='"$STARTFROM"' -v end='"$ENDDATE")
BUILDEXPR=$(echo $BUILDEXPR "'"'$0 >= start && $0 <= end'"'")
BUILDEXPR=$(echo $BUILDEXPR '<<< "$MERGEDCOINLIST"')
IFS=''
TRANSACTIONLIST=$(eval $BUILDEXPR | sort)
echo " EXPLORING Address:"
echo " $ADDRESS"
echo
printf ' Balance: %10s %3s\n' "$ADDRESSBALANCE" "$COINNAME"
printf ' Today: %10s %3s\n' "$TODAYADDRESSCHANGE" "$COINNAME"
printf ' Yesterday: %10s %3s\n' "$YESTERDAYADDRESSCHANGE" "$COINNAME"
if [[ $TRANSACTIONLIST == '' ]]; then
printf ' No transactions from %10s to %10s\n' "$STARTFROM" "$ENDDATE"
echo
exit
fi
echo -e '---------------------------------------------------------------------'
printf ' Height Height Farmed Total\n'
printf 'DateTime Confirmed Spent Block? Amount\n'
echo -e '---------------------------------------------------------------------'
FIRSTLOOP=1
PREVBLOCKAMOUNT=0
TOTALFORRANGE=0
COUNTFORRANGE=0
while read line; do
DATETRANS=$(echo $line | awk '{print $1}')
COINBASE=$(echo $line | awk '{print $2}')
BLOCKAMOUNT=$(echo $line | awk '{print $3}')
HEIGHTCONFIRMED=$(echo $line | awk '{print $4}')
HEIGHTSPENT=$(echo $line | awk '{print $5}')
if [[ $FIRSTLOOP == 1 || ($HEIGHTCONFIRMED == $PREVHEIGHTCONFIRMED && $HEIGHTSPENT == $PREVHEIGHTSPENT && $COINBASE == $PREVCOINBASE && $DATETRANS == $PREVDATETRANS) ]]
then
BLOCKAMOUNT=$(echo "(($BLOCKAMOUNT+$PREVBLOCKAMOUNT))" | bc)
else
BUILDEXPR=$(echo "echo 'scale = 3; (($PREVBLOCKAMOUNT / $MMMULTIPLIER))' | bc -l")
PRINTAMOUNT=$(eval $BUILDEXPR)
TOTALFORRANGE=$(echo "(($TOTALFORRANGE + $PRINTAMOUNT))" | bc -l)
COUNTFORRANGE=$(echo "(($COUNTFORRANGE + 1))" | bc -l)
if [[ $PREVCOINBASE = true ]]; then
FARMEDBLOCK='Yes'
else
FARMEDBLOCK='No'
fi
printf '%-19s %-10s %-10s %-3s %12.3f %-5s\n' "$PREVDATETRANS" "$PREVHEIGHTCONFIRMED" "$PREVHEIGHTSPENT" "$FARMEDBLOCK" "$PRINTAMOUNT" "$COINNAME"
fi
FIRSTLOOP=0
PREVDATETRANS=$DATETRANS
PREVBLOCKAMOUNT=$BLOCKAMOUNT
PREVCOINBASE=$COINBASE
PREVHEIGHTCONFIRMED=$HEIGHTCONFIRMED
PREVHEIGHTSPENT=$HEIGHTSPENT
done <<< "$TRANSACTIONLIST"
# Add the last line.
BUILDEXPR=$(echo "echo 'scale = 3; (($PREVBLOCKAMOUNT / $MMMULTIPLIER))' | bc -l")
PRINTAMOUNT=$(eval $BUILDEXPR)
if [[ $PREVCOINBASE = true ]]; then
FARMEDBLOCK='Yes'
else
FARMEDBLOCK='No'
fi
printf '%-19s %-10s %-10s %-3s %12.3f %-5s\n' "$PREVDATETRANS" "$PREVHEIGHTCONFIRMED" "$PREVHEIGHTSPENT" "$FARMEDBLOCK" "$PRINTAMOUNT" "$COINNAME"
TOTALFORRANGE=$(echo "(($TOTALFORRANGE + $PRINTAMOUNT))" | bc -l)
COUNTFORRANGE=$(echo "(($COUNTFORRANGE + 1))" | bc)
echo -e '---------------------------------------------------------------------'
# Set ENDDATE one day (or one month) back for display purposes
if [[ $SUMMARIZEBYMONTH != 'Yes' ]]; then
ENDDATE=$(DateOffset -1 $ENDDATE)
else
ENDDATE=$(echo $ORIGENDDATE | cut -c1-7 )
fi
if [[ $SUMMARIZEBYDAY = 'Yes' ]]; then
printf 'Daily summary from %10s to %10s: %12s %-5s\n' "$STARTFROM" "$ENDDATE" "$TOTALFORRANGE" "$COINNAME"
elif [[ $SUMMARIZEBYMONTH = 'Yes' ]]; then
printf 'Monthly summary from %10s to %10s: %12s %-5s\n' "$STARTFROM" "$ENDDATE" "$TOTALFORRANGE" "$COINNAME"
else
printf '%6.6s transactions from %10s to %10s:%12s %-5s\n' "$COUNTFORRANGE" "$STARTFROM" "$ENDDATE" "$TOTALFORRANGE" "$COINNAME"
fi
echo
IFS=DEFAULT_IFS
. ftexit.sh