1
- dcrspy
2
- ====
3
-
4
- ** WORK IN PROGRESS**
1
+ # dcrspy
5
2
6
3
[ ![ Gitter] ( https://badges.gitter.im/chappjc/dcrspy.svg )] ( https://gitter.im/chappjc/dcrspy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge )
7
4
8
5
dcrspy is a program to continuously monitor and log changes in various data
9
6
on the Decred network. It works by connecting to both dcrd and dcrwallet
10
7
and responding when a new block is detected via a notifier registered with
11
- dcrd.
8
+ dcrd. Communication with dcrd and dcrwallet uses the Decred JSON-RPC API.
12
9
13
10
## Types of Data
14
11
15
12
Two types of information are monitored:
16
13
17
14
* Block chain data (from dcrd)
18
- * Stake information (from your wallet), more wallet info in to-do .
15
+ * Stake and wallet information (from your wallet).
19
16
20
- A connection to dcrwallet is optional, but for stake information it is required.
17
+ A connection to dcrwallet is optional. Only block data will be obtained when no
18
+ wallet connection is available.
21
19
22
- See [ Data Details] ( #data-details ) below for details .
20
+ See [ Data Details] ( #data-details ) below for more information .
23
21
24
22
25
23
## Output
26
24
27
25
Multiple destinations for the data are planned:
28
26
29
- 1 . ** stdout** . JSON-formatted data is send to stdout. IMPLEMENTED.
30
- 2 . ** File system** . JSON-formatted data is written to the file system.
31
- TESTING on branch [ ` json_file_output ` ] ( https://github.com/chappjc/dcrspy/tree/json_file_output ) .
32
- 3 . ** Database** . Data is inserted into a MySQL database. NOT IMPLEMENTED.
33
- 4 . ** Plain text summary** : balances, votes, current ticket price, mean fees, wallet status. NEXT.
34
- 5 . HTTP access via ** RESTful API** . NOT IMPLEMENTED.
27
+ 1 . ** stdout** . JSON-formatted data is send to stdout. ** DONE** .
28
+ 2 . ** File system** . JSON-formatted data is written to the file system. ** DONE** .
29
+ 3 . ** Database** . Data is inserted into a MySQL database. NOT IMPLEMENTED.
30
+ 4 . ** Plain text summary** : balances, votes, current ticket price, mean fees,
31
+ wallet status. ** DONE** .
32
+ 5 . ** RESTful API** over HTTPS. NOT IMPLEMENTED.
33
+
34
+ Details of the JSON output may be found in [ Data Details] ( #data-details ) . The
35
+ plain text summary looks something like the following (_ wallet data redacted_ ):
36
+
37
+ ~~~ none
38
+ Block 35561:
39
+ Stake difficulty: 22.663 -> 22.663 (current -> next block)
40
+ Estimated price in next window: 25.279 / [24.63, 26.68] ([min, max])
41
+ Window progress: 138 / 144 of price window number 246
42
+ Ticket fees: 0.0101, 0.0101, 0.0000 (mean, median, std), n=1
43
+ Ticket pool: 42048 (size), 17.721 (avg. price), 745115.63 (total DCR locked)
44
+
45
+ Wallet and Stake Info at Height 35561:
46
+ - Balances
47
+ Balances (spendable): 0.0000 (default), 0.0000 (all)
48
+ Balances (locked): xxx.xxxx (default), xxxx.xxxx (all), xxxx.xxxx (imported)
49
+ Balances (any): xxxx.xxxx (default), xxxx.xxxx (all)
50
+ - Stake Info
51
+ ===> Mining enabled: true; Unlocked: true <===
52
+ Mined tickets: 4 (immature), 43 (live)
53
+ mempool tickets: 0 (own), 6 (all)
54
+ Ticket price: 22.663 | Window progress: 138 / 144
55
+ Wallet's price: 23.8100; fee: 0.1940 / KiB
56
+ Totals: 541 votes, 919.84 subsidy
57
+ 1 missed, 1 revoked
58
+ ~~~
35
59
36
60
## TO-DO
37
61
62
+ dcrspy is functional, but also a ** work-in-progress** . However, I will try to keep
63
+ ` master ` as stable as possible, and develop new features in separate branches.
64
+
38
65
There is a [ very long to-do list] ( https://drive.google.com/open?id=1Z057i7tGfnATWu0w7loetIkGElteNnlx2bJSxPvVOqE ) .
39
66
40
67
## Requirements
41
68
42
- - [ Go] ( http://golang.org ) 1.6 or newer.
43
- - Running ` dcrd ` synchronized to the current best block on the network.
44
- - (Optional, for stake info) ` dcrwallet ` connected to ` dcrd ` .
69
+ * [ Go] ( http://golang.org ) 1.6 or newer.
70
+ * Running ` dcrd ` synchronized to the current best block on the network.
71
+ * (Optional, for stake info) ` dcrwallet ` connected to ` dcrd ` .
45
72
46
73
## Installation
47
74
48
- #### Build from Source
75
+ ### Build from Source
49
76
50
- - Install Go:
77
+ * Install Go:
51
78
http://golang.org/doc/install
52
79
53
- - Verify Go installation:
80
+ * Verify Go installation:
54
81
55
- ` go env GOROOT GOPATH `
82
+ ` go env GOROOT GOPATH `
56
83
57
- - Build executable
84
+ * Build executable
58
85
59
- ` go get -u -v github.com/chappjc/dcrspy `
86
+ ` go get -u -v github.com/chappjc/dcrspy `
60
87
61
- - Find dcrspy executable in ` $GOPATH/bin ` , and copy elsewhere (recommended).
88
+ * Find dcrspy executable in ` $GOPATH/bin ` , and copy elsewhere (recommended).
62
89
63
90
## Updating
64
91
@@ -68,55 +95,94 @@ Run the same command used to build:
68
95
69
96
## Getting Started
70
97
71
- By default, dcrspy will monitor both block data and your wallet's stake info,
72
- and write the data to stdout in JSON format .
98
+ By default, dcrspy will monitor both block data and your wallet, and write a
99
+ plain text summary of the data to stdout for each new block that is detected .
73
100
74
101
There are several program options, which may be utilized via:
75
102
76
103
1 . Command line arguments
77
- 2 . Config file (e.g. dcrspy.conf)
104
+ 1 . Config file (e.g. dcrspy.conf)
78
105
79
106
### Command line
80
107
81
- ```
108
+ Quick tips:
109
+
110
+ * Get a quick summary and exit, with ` -e, --nomonitor ` .
111
+ * Stay connected and monitor for new blocks, writting:
112
+ * Plain text summary to stdout, with ` -s, --summary ` .
113
+ * JSON to stdout, with ` -o, --save-jsonstdout ` .
114
+ * JSON to file system, with ` -o, --save-jsonfile ` .
115
+ * To monitor only block data (no wallet connection), use ` --nostakeinfo ` .
116
+
117
+ The full list of command line switches is below.
118
+
119
+ ~~~ none
82
120
Usage:
83
- dcrspy [OPTIONS]
121
+ dcrspy.exe [OPTIONS]
84
122
85
123
Application Options:
86
- -C, --configfile= Path to configuration file (.../dcrspy.conf)
87
- -V, --version Display version information and exit
88
- --testnet Use the test network (default mainnet)
89
- --simnet Use the simulation test network (default mainnet)
90
- -d, --debuglevel= Logging level {trace, debug, info, warn, error, critical} (info)
91
- --logdir= Directory to log output (.../logs)
92
- --noblockdata Collect block data (default true)
93
- --nostakeinfo Collect stake info (default true). Requires wallet connection
94
- --dcrduser= Daemon RPC user name
95
- --dcrdpass= Daemon RPC password
96
- --dcrdserv= Hostname/IP and port of dcrd RPC server to connect to (default localhost:9109, testnet: localhost:19109, simnet:
97
- localhost:19556)
98
- --dcrdcert= File containing the dcrd certificate file (${HOME}/.dcrd/rpc.cert)
99
- --dcrwuser= Wallet RPC user name
100
- --dcrwpass= Wallet RPC password
101
- --dcrwserv= Hostname/IP and port of dcrwallet RPC server to connect to (default localhost:9110, testnet: localhost:19110,
102
- simnet: localhost:19557)
103
- --dcrwcert= File containing the dcrwallet certificate file (${HOME}/.dcrwallet/rpc.cert)
104
- --noclienttls Disable TLS for the RPC client -- NOTE: This is only allowed if the RPC client is connecting to localhost
105
- --accountname= Name of the account from (default: default) (default)
106
- --ticketaddress= Address to which you have given voting rights
107
- --pooladdress= Address to which you have given rights to pool fees
124
+ /C, /configfile: Path to configuration file
125
+ (...\dcrspy.conf)
126
+ /V, /version Display version information and exit
127
+ /testnet Use the test network (default mainnet)
128
+ /simnet Use the simulation test network (default mainnet)
129
+ /d, /debuglevel: Logging level {trace, debug, info, warn, error,
130
+ critical} (info)
131
+ /q, /quiet Easy way to set debuglevel to error
132
+ /logdir: Directory to log output (...\logs)
133
+ /e, /nomonitor Do not launch monitors. Display current data and
134
+ (e)xit.
135
+ /noblockdata Do not collect block data (default false)
136
+ /nostakeinfo Do not collect stake info data (default false)
137
+ /f, /outfolder: Folder for file outputs (...\spydata)
138
+ /s, /summary Write plain text summary of key data to stdout
139
+ /o, /save-jsonstdout Save JSON-formatted data to stdout
140
+ /j, /save-jsonfile Save JSON-formatted data to file
141
+ /dcrduser: Daemon RPC user name
142
+ /dcrdpass: Daemon RPC password
143
+ /dcrdserv: Hostname/IP and port of dcrd RPC server to connect to
144
+ (default localhost:9109, testnet: localhost:19109,
145
+ simnet: localhost:19556)
146
+ /dcrdcert: File containing the dcrd certificate file
147
+ (%localappdata%\Dcrd\rpc.cert)
148
+ /dcrwuser: Wallet RPC user name
149
+ /dcrwpass: Wallet RPC password
150
+ /dcrwserv: Hostname/IP and port of dcrwallet RPC server to
151
+ connect to (default localhost:9110, testnet:
152
+ localhost:19110, simnet: localhost:19557)
153
+ /dcrwcert: File containing the dcrwallet certificate file
154
+ (%localappdata%\Dcrwallet\rpc.cert)
155
+ /noclienttls Disable TLS for the RPC client -- NOTE: This is only
156
+ allowed if the RPC client is connecting to localhost
157
+ /accountname: Name of the account from (default: default) (default)
158
+ /ticketaddress: Address to which you have given voting rights
159
+ /pooladdress: Address to which you have given rights to pool fees
108
160
109
161
Help Options:
110
- -h, --help Show this help message
111
- ```
162
+ /? Show this help message
163
+ /h, /help Show this help message
164
+ ~~~
112
165
113
166
### Config file
114
167
115
- ``` ini
168
+ All command line switches may be placed into the config file, which is
169
+ dcrspy.conf by default.
170
+
171
+ ~~~ ini
116
172
[Application Options]
117
173
118
174
debuglevel =debug
119
175
176
+ ; Default outfolder is a folder called "dcrspy" in the working directory.
177
+ ; Change this with the outfolder option:
178
+ ; Windows
179
+ outfolder =%appdata%/dcrspy/spydata
180
+ ; Linux
181
+ ; outfolder=$HOME/dcrspy/spydata
182
+
183
+ ; Uncomment for testnet
184
+ ; testnet=1
185
+
120
186
dcrduser =duser
121
187
dcrdpass =asdfExample
122
188
@@ -128,79 +194,84 @@ dcrwpass=qwertyExample
128
194
129
195
dcrwserv =localhost:9110
130
196
dcrwcert =/home/me/.dcrwallet/rpc.cert
131
-
132
- ; noclienttls=false
133
- ```
197
+ ~~~
134
198
135
199
## Data Details
136
200
137
- Block chain data obtained from dcrd includes:
201
+ Block chain data obtained from dcrd includes several types of data. The JSON
202
+ file written by dcrspy for block data is named ` block-data-[BLOCKNUM].json ` . It
203
+ contains a single JSON object, with each data type as a tagged JSON child
204
+ object.
138
205
139
206
1 . Block header (hash, voters, height, difficulty, nonce, time, etc.)
140
207
141
- ```
142
- {
143
- "hash": "0000000000000c21323dc60866aa5a869b57c001589a026cf0a1a18765971d83 ",
144
- "confirmations": 1,
145
- "version": 1,
146
- "previousblockhash": "000000000000056c3051ae16b4dc098238165e70b11c77b9024c57662dbb479d ",
147
- "merkleroot": "0291270c33212dfeff03da47fa4122ca81825f352bd8cca547c0832e22e67c18 ",
148
- "stakeroot": "3112f31e8a03aa588f4755cdd974eaab938c7f221d29322231992a472188a79a ",
149
- "votebits": 1,
150
- "finalstate": "ca3c601c8042 ",
151
- "voters": 5,
152
- "freshstake": 2 ,
153
- "revocations": 1 ,
154
- "poolsize": 42630 ,
155
- "bits": "1a173a02 ",
156
- "sbits": 22.42495867 ,
157
- "height": 34625 ,
158
- "size": 5945 ,
159
- "time": 1465232577 ,
160
- "nonce": 4055550757 ,
161
- "difficulty": 722316.87132517
208
+ ~~~ json
209
+ "block_header" : {
210
+ "hash" : " 00000000000014c19867d5cd0f60d9409cd9e4ea68f656dac50befa756866cf8 " ,
211
+ "confirmations" : 1 ,
212
+ "version" : 1 ,
213
+ "previousblockhash" : " 00000000000010c295f2e808af78d8240c3365d9d52b28e2061f9a55ce9dcd29 " ,
214
+ "merkleroot" : " 731c342c75237fe72e2d27a6820f6384498add97f96dcef9c6f2fd558a80f4c9 " ,
215
+ "stakeroot" : " c3d75f22a1e9bb4b50155f95d9b7a977f7ed1ecaf05024e157a77d7b5697fe04 " ,
216
+ "votebits" : 1 ,
217
+ "finalstate" : " 6acc9d2694f3 " ,
218
+ "voters" : 5 ,
219
+ "freshstake" : 3 ,
220
+ "revocations" : 0 ,
221
+ "poolsize" : 42084 ,
222
+ "bits" : " 1a166536 " ,
223
+ "sbits" : 22.66271576 ,
224
+ "height" : 35552 ,
225
+ "size" : 3764 ,
226
+ "time" : 1465510687 ,
227
+ "nonce" : 2821830658 ,
228
+ "difficulty" : 749126.76453394
162
229
}
163
- ```
230
+ ~~~
164
231
165
- 2 . Ticket pool info. This is a custom data structure.
232
+ 1 . Ticket pool info. This is a custom data structure.
166
233
167
- ```
168
- {
169
- "poolsize": 42635 ,
170
- "poolvalue": 729895.86066478 ,
171
- "poolvalavg": 17.11964021
234
+ ~~~ json
235
+ "ticket_pool_info" : {
236
+ "poolsize" : 42084 ,
237
+ "poolvalue" : 745705.38747115 ,
238
+ "poolvalavg" : 17.71945127
172
239
}
173
- ```
240
+ ~~~
174
241
175
- 3 . Ticket fee info (block). This is the usual output of ` ticketfeeinfo ` with
242
+ 1 . Ticket fee info (block). This is the usual output of ` ticketfeeinfo ` with
176
243
no extra arguments:
177
244
178
- ```
179
- {
180
- "height": 34624 ,
181
- "number": 3,
182
- "min": 0.01013513 ,
183
- "max": 0.0255102 ,
184
- "mean": 0.01558548 ,
185
- "median": 0.01111111 ,
186
- "stddev": 0.0086089
245
+ ~~~ json
246
+ "ticketfeeinfo_block" : {
247
+ "height" : 35552 ,
248
+ "number" : 3 ,
249
+ "min" : 0.01010101 ,
250
+ "max" : 0.01013513 ,
251
+ "mean" : 0.01011238 ,
252
+ "median" : 0.01010101 ,
253
+ "stddev" : 1.97e-05
187
254
}
188
- ```
255
+ ~~~
189
256
190
- 4 . Current and estimated stake difficulty. These are the usual outputs of
257
+ 1 . Current and estimated stake difficulty. These are the usual outputs of
191
258
` estimatestakediff ` and ` getstakedifficulty ` :
192
259
193
- ```
194
- {
195
- "min": 21.92454703 ,
196
- "max": 50.34015709 ,
197
- "expected": 39.59322765
198
- }
199
- {
200
- "current": 22.42495867 ,
201
- "next": 22.42495867
260
+ ~~~ json
261
+ "estimatestakediff" : {
262
+ "min" : 23.80700879 ,
263
+ "max" : 28.94194858 ,
264
+ "expected" : 25.46730598
265
+ },
266
+ "currentstakediff" : {
267
+ "current" : 22.66271576 ,
268
+ "next" : 22.66271576
202
269
}
203
- ```
270
+ ~~~
271
+
272
+ Wallet data is stored in a similar manner in file ` stake-info-[BLOCKNUM].json ` .
273
+ There are three data types, tagged ` "getstakeinfo ` ", ` "walletinfo" ` , and
274
+ ` "balances" ` . TODO: Update this README with a testnet example output.
204
275
205
276
## Issue Tracker
206
277
@@ -212,4 +283,4 @@ dcrspy is licensed under the [copyfree](http://copyfree.org) ISC License.
212
283
213
284
dcrspy borrows its logging and config file facilities, plus some boilerplate
214
285
code in main.go, from the dcrticketbuyer project by the Decred developers.
215
- The rest is by Jonathan Chappelow ( chappjc) .
286
+ The rest is by chappjc.
0 commit comments