@@ -9,6 +9,8 @@ usage () {
9
9
echo " -s INTERGER Index of starting transaction Default: 0"
10
10
echo " -e INTERGER Index of ending transaction Default: 999999"
11
11
echo " -o INTERGER 0 for ascending, 1 for descending Default: 0"
12
+ echo " -min AMOUNT Only transactions greater than AMOUNT Default: 0"
13
+ echo " -max AMOUNT Only transactions less than AMOUNT Default: 999999"
12
14
echo " -t INTERGER -1 for all transaction types Default: -1"
13
15
echo " 0 for INCOMING_TX"
14
16
echo " 1 for OUTGOING_TX"
@@ -55,6 +57,8 @@ trx_start=0
55
57
trx_end=999999
56
58
trx_order=0
57
59
desired_type=-1
60
+ trx_max=999999
61
+ trx_min=0
58
62
59
63
# Handle the command line options. Set variable based on input
60
64
# be sure not to shift after an option that is only has one term
67
71
-e) trx_end=$2 && shift ;;
68
72
-o) trx_order=$2 && shift ;;
69
73
-t) desired_type=$2 && shift ;;
74
+ -min) trx_min=$2 && shift ;;
75
+ -max) trx_max=$2 && shift ;;
70
76
-v) verbose=" true" ;;
71
77
-h) usage && exit 1 ;;
72
78
--) shift && break ;;
75
81
shift
76
82
done
77
83
78
- # DEBUG
79
- # echo "WalletID=$wallet_id, Year=$year, Verbose=$verbose, Start=$trx_start, End=$trx_end, Sort=$trx_order, Desired Type = $desired_type"
80
-
81
84
# Make a call against the chia wallet_rpc_api to get transactions, then use jq to write the json to a file
82
85
query_parameters=" {\" wallet_id\" :$wallet_id ,\" start\" :$trx_start ,\" end\" :$trx_end ,\" reverse\" :$trx_order }"
83
86
curl -s -X POST --insecure \
@@ -120,16 +123,31 @@ jq -c '.transactions[]' alltxs.json | while read trx; do
120
123
tx_type=` echo " $trx " | jq -r ' .type' `
121
124
tx_wallet_id=` echo " $trx " | jq -r ' .wallet_id' `
122
125
126
+ # If there was a desired type, lets limit the results down to only that transaction type
127
+ if [[ $desired_type -ge 0 ]] && [[ $desired_type -ne $tx_type ]]; then
128
+ continue
129
+ fi
130
+
123
131
# placeholder for the current price of XCH
124
132
current_price=0
125
133
126
134
# call function to switch amount from mojo to xch
127
135
mojo2xch && tx_amount=$xch
128
136
137
+ # filter based on min/max
138
+ if [[ " $tx_amount " > " $trx_max " ]] || [[ " $tx_amount " < " $trx_min " ]]; then
139
+ continue
140
+ fi
141
+
129
142
# build datetime from epoch
130
143
tx_datetime=$( date --date=@$tx_created_at_time +" %Y-%m-%d %T" )
131
144
tx_year=` echo $tx_datetime | cut -c1-4`
132
145
146
+ # jump to next record if we want a specific year and the transaction doesn't match
147
+ if [ " $year " != " all" ] && [ " $year " != " $tx_year " ]; then
148
+ continue
149
+ fi
150
+
133
151
# set a good description for the transaction type
134
152
case $tx_type in
135
153
0) tx_typedesc=" INCOMING_TX" ;;
@@ -161,49 +179,45 @@ jq -c '.transactions[]' alltxs.json | while read trx; do
161
179
mojo2xch && tx_amount=$xch
162
180
fi
163
181
164
- # If year is passed in as an option we only want to print that year
165
- if [ " $year " == " all" ] || [ " $year " == " $tx_year " ]; then
166
-
167
- # If there was a desired type, lets limit the results down to only that transaction type
168
- if [[ $desired_type -lt 0 ]] || [[ $desired_type -eq $tx_type ]]; then
169
-
170
- # write out to screen
171
- # to save to file the user must use redirection on the command line
172
- if [ " $verbose " == " true" ]; then
173
- row=" $tx_name ,$tx_datetime ,$tx_typedesc ,$tx_amount ,$current_price ,$tx_additions ,$tx_confirmed ,$tx_confirmed_at_height ,$tx_fee_amount ,$tx_memos ,$tx_removals ,$tx_sent ,$tx_sent_to ,$tx_spend_bundle ,$tx_to_address ,$tx_to_puzzle_hash ,$tx_trade_id ,$tx_wallet_id "
174
- else
175
- row=" $tx_name ,$tx_datetime ,$tx_typedesc ,$tx_amount ,$current_price "
176
- fi
177
- echo " $row "
178
- fi
182
+ # write out to screen
183
+ # to save to file the user must use redirection on the command line
184
+ if [ " $verbose " == " true" ]; then
185
+ row=" $tx_name ,$tx_datetime ,$tx_typedesc ,$tx_amount ,$current_price ,$tx_additions ,$tx_confirmed ,$tx_confirmed_at_height ,$tx_fee_amount ,$tx_memos ,$tx_removals ,$tx_sent ,$tx_sent_to ,$tx_spend_bundle ,$tx_to_address ,$tx_to_puzzle_hash ,$tx_trade_id ,$tx_wallet_id "
186
+ else
187
+ row=" $tx_name ,$tx_datetime ,$tx_typedesc ,$tx_amount ,$current_price "
179
188
fi
189
+ echo " $row "
190
+
180
191
done
181
192
182
193
# Version History
183
194
#
184
- # v0.1 - Initial Release:
185
- # - Basic functionality. Will generate a list of transactions for Chia (XCH) and
186
- # put into a CSV file. Pulls only a list of transaction ids from wallet then looped on those
187
- # ids and used Chia commands to get more details for each transaction.
188
- # - Output was sent to the screen and also saved to a file. This required defaults for path &
189
- # filenames and also command options from user to specify each as well.
195
+ # v0.1.0 - Initial Release:
196
+ # - Basic functionality. Will generate a list of transactions for Chia (XCH) and
197
+ # put into a CSV file. Pulls only a list of transaction ids from wallet then looped on those
198
+ # ids and used Chia commands to get more details for each transaction.
199
+ # - Output was sent to the screen and also saved to a file. This required defaults for path &
200
+ # filenames and also command options from user to specify each as well.
190
201
#
191
- # v0.2 - Changes:
192
- # - Rebuilt the query against the wallet db to pull all the transaction data and write into a
193
- # json file that can be used in the rest of the script without having to run Chia commands.
194
- # - Changed output to screen only and updated Usage to tell user how to redirect to a file from
195
- # the command line.
196
- # New features:
197
- # - Added command option to specify a year for the transactions. If the transacion year doesn't
198
- # match the value from the command option, then it doesn't get writtent to the CSV.
199
- # - Added command option for verbose which will include all fields in the CSV. The default is now
200
- # a condensed version with fewer fields.
202
+ # v0.2.0 - Changes:
203
+ # - Rebuilt the query against the wallet db to pull all the transaction data and write into a
204
+ # json file that can be used in the rest of the script without having to run Chia commands.
205
+ # - Changed output to screen only and updated Usage to tell user how to redirect to a file from
206
+ # the command line.
207
+ # New features:
208
+ # - Added command option to specify a year for the transactions. If the transacion year doesn't
209
+ # match the value from the command option, then it doesn't get writtent to the CSV.
210
+ # - Added command option for verbose which will include all fields in the CSV. The default is now
211
+ # a condensed version with fewer fields.
201
212
#
202
- # v0.3 - New features:
203
- # - Add a command option for sorting. Either ASC for ascending (oldest to newest) or DESC for
204
- # descending (newest to oldest).
205
- # - Add a command option for selecting wallet id to pull transactions from.
206
- # - Add a command option for start & end indexes for transactions to pull out of the wallet db.
207
- # - Add a command option for selecting a specific Transaction Type to filter the list by.
213
+ # v0.3.0 - New features:
214
+ # - Add a command option for sorting. Either ASC for ascending (oldest to newest) or DESC for
215
+ # descending (newest to oldest).
216
+ # - Add a command option for selecting wallet id to pull transactions from.
217
+ # - Add a command option for start & end indexes for transactions to pull out of the wallet db.
218
+ # - Add a command option for selecting a specific Transaction Type to filter the list by.
208
219
#
209
-
220
+ # v0.3.1 - Changes
221
+ # - Rewrite so filters are in a big nested if statement. Use continue to jump to next iteration instead.
222
+ # New features:
223
+ # - Add a command option for filtering based on transaction amount.
0 commit comments