-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChainscope-Demo.txt
288 lines (271 loc) · 4.72 KB
/
Chainscope-Demo.txt
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# Chainscope Demo
# See http://localhost:9200/_plugin/marvel/sense/index.html
# Block Count
#
# Gets the total number of blocks
# currently indexed by Elasticsearch
GET _search
{
"query": {
"match": { "_type": "block" }
},
"fields": [],
"size": 0
}
# Block Height (Max and Min)
#
# Uses aggregations to detect highest and lowest height
# of blocks currently indexed by Elasticsearch
GET _search
{
"query": {
"match": { "_type": "block" }
},
"aggregations": {
"min_height": {"min": { "field": "height" }},
"max_height": {"max": { "field": "height" }}
},
"fields": [],
"size": 0
}
# Block Difficulty (Max and Min)
#
# Uses aggregations for max and min difficulty
GET _search
{
"query": {
"match": { "_type": "block" }
},
"aggregations": {
"min_difficulty": {"min": { "field": "difficulty" }},
"max_difficulty": {"max": { "field": "difficulty" }}
},
"fields": [],
"size": 0
}
# Block Size (Average, Min, Max)
#
# Uses aggregations for max, min and average size
# of blocks indexed by Elasticsearch
GET _search
{
"query": {
"match": { "_type": "block" }
},
"aggregations": {
"avg_size": {"avg": { "field": "size" }},
"min_size": {"min": { "field": "size" }},
"max_size": {"max": { "field": "size" }}
},
"fields": [],
"size": 0
}
# Block Data
#
# Uses partial_fields to get block information,
# without transaction data
GET _search
{
"partial_fields": {
"BLOCK": {
"include": [],
"exclude": ["txinfo.*", "tx"]
}
},
"query": {
"match": { "_type": "block" }
},
"from": 1000,
"size": 5
}
# Multiple Blocks starting at Height
#
# Uses a range query on block height
GET _search
{
"query": {
"range": {
"height": {
"gte": "300100"
}
}
},
"partial_fields": {
"BLOCK": {
"include": [],
"exclude": ["tx", "txinfo.*"]
}
},
"size": 2
}
# First 5 Blocks
#
# Gets the first five blocks indexed by ES.
# Note, this doesn't include block 0, the genesis block!
GET _search
{
"query": {
"range": {
"height": {
"gte": "0",
"lte": "5"
}
}
},
"partial_fields": {
"BLOCK": {
"include": []
}
},
"size": 5,
"sort": [
{
"height": {
"order": "asc"
}
}
]
}
# Coinbase Transaction Data
#
# Gets data for the coinbase transaction,
# the first transaction in a block
GET _search
{
"query": {
"range": {
"height": {
"gte": "300100"
}
}
},
"script_fields": {
"TX0": {
"script": "_source.txinfo[0]"
}
},
"size": 5
}
# Script Fields (and Coinbase)
#
# Uses dynamic scripting to create a new field
# Supports groovy, JavaScript, Python, and others
#
# Here we pluck the COINBASE field
GET _search
{
"query": {
"range": {
"height": {
"gte": "300100"
}
}
},
"script_fields": {
"COINBASE": {
"script": "_source.txinfo[0].vin[0].coinbase"
}
},
"size": 2
}
# Human-readable Coinbase
# See python's binascii.unhexlify(hex_str), "".decode('hex')
# Or elasticsearch.js and String.fromCharCode(parseInt(hexCode))
# Transaction Data
#
# Gets first transaction from series of blocks,
# using script fields to pluck transaction info
GET _search
{
"query": {
"range": {
"height": {
"gte": "300100"
}
}
},
"script_fields": {
"TX0": {
"script": "_source.txinfo[1]"
}
},
"size": 5
}
# ScriptPubKey (Lock, TxOut)
#
# Selects script pub key object from
# first transaction in a series of blocks
GET _search
{
"query": {
"range": {
"height": {
"gte": "300100"
}
}
},
"script_fields": {
"SCRIPT_PUB_KEY": {
"script": "_source.txinfo[1].vout.scriptPubKey"
}
},
"size": 10
}
# Output Scripts
#
# Selects the scriptPubKey ASM from every output
# of first transaction in a series of blocks
GET _search
{
"query": {
"range": {
"height": {
"gte": "300200"
}
}
},
"script_fields": {
"OUTPUT_SCRIPTS": {
"script": "_source.txinfo[1].vout.scriptPubKey*.asm"
}
},
"size": 3
}
# Input Scripts
#
# Selects the scriptSig ASM from every input
# of first transaction in a series of blocks
GET _search
{
"query": {
"range": {
"height": {
"gte": "300200"
}
}
},
"script_fields": {
"INPUT_SCRIPTS": {
"script": "_source.txinfo[1].vin.scriptSig*.asm"
}
},
"size": 3
}
# Op Return
#
# Selects the output scripts (and embedded data)
# for blocks with transactions using OP_RETURN
GET _search
{
"query": {
"match": {
"txinfo.vout.scriptPubKey.asm": "OP_RETURN"
}
},
"script_fields": {
"OUTPUT_SCRIPTS": {
"script": "_source.txinfo*.vout.scriptPubKey.asm"
}
},
"size": 3
}