-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-argLength.sh
executable file
·95 lines (68 loc) · 2.17 KB
/
test-argLength.sh
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
#!/bin/bash
#{
export PATH=$PATH:./:/usr/bin
#1) primecoind getblockhash
blockhash=$(primecoind getblockhash $1)
: || {
grep -B1 rgu debug2
138241
./block2JSON.sh: line 37: /usr/bin/primecoind: Argument list too long
--
160236
./block2JSON.sh: line 37: /usr/bin/primecoind: Argument list too long
--
160559
./block2JSON.sh: line 37: /usr/bin/primecoind: Argument list too long
}
#2) primecoind getblock
#testing - a transaction that i know about
#blockhash="abae9a5b0bc6ee0a1aa1461778631f9f1fa83f426a6bd2613b1ec193b5560b17"
block=$(primecoind getblock $blockhash)
trans=$(echo $block | jq '.tx')
confirmations=$(echo $block | jq '.confirmations')
time=$(echo $block | jq '.time')
prev=$(echo $block | jq '.previousblockhash')
next=$(echo $block | jq '.nextblockhash')
#echo $1 $blockhash $confirmations $time $prev $next
#exit
php ./insertBlock.php $1 $blockhash $confirmations $time $prev $next
transArray=( $( echo $trans | jq -r '.[]' ) )
#echo ${transArray[@]} > /var/www/html/xpm-bal/debug
for i in ${transArray[@]}; do
#echo $i
#3) primecoind getrawtransaction
raw=$(primecoind getrawtransaction "$i")
#echo $raw
#4) primecoind decoderawtransaction
echo $i
#echo ${#raw}
#exit
singleTrans=$(primecoind decoderawtransaction "$raw")
echo $i
#exit
#echo primecoind decoderawtransaction $raw
#echo $singleTrans >> /var/www/html/xpm-bal/debug
#top level transaction id
txid=$( echo $singleTrans | jq -r '.txid' )
addressesArray=( $( echo $singleTrans | jq -r '.vout[] .scriptPubKey .addresses[]' ) )
valuesArray=( $( echo $singleTrans | jq -r '.vout[] .value' ) )
hexArray=( $( echo $singleTrans | jq -r '.vout[] .scriptPubKey .hex' ) )
#echo $singleTrans
if [ ${#addressesArray[@]} == ${#valuesArray[@]} ] && [ ${#addressesArray[@]} == ${#hexArray[@]} ] && [ ${#valuesArray[@]} == ${#hexArray[@]} ]
then
k='feeling fine!'
#echo $k
#exit
else
echo "NOT"
exit
fi
for ((j=0; j<${#addressesArray[@]}; j++)); do
#block_id, tx_id, hex, value, address
php ./insertTrans.php $1 $txid ${hexArray[$j]} ${addressesArray[$j]} ${valuesArray[$j]}
#echo
done
#echo $txid $value $address >> /var/www/html/xpm-bal/debug
#exit
done
#} >> debug2