Skip to content
This repository was archived by the owner on Mar 15, 2019. It is now read-only.

Commit f5cbefd

Browse files
committed
Acquire and store "wallet info" and balances from wallet.
Update README.md. Bump version label for new tag.
1 parent a3a39f1 commit f5cbefd

File tree

5 files changed

+273
-126
lines changed

5 files changed

+273
-126
lines changed

README.md

+181-110
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,91 @@
1-
dcrspy
2-
====
3-
4-
**WORK IN PROGRESS**
1+
# dcrspy
52

63
[![Gitter](https://badges.gitter.im/chappjc/dcrspy.svg)](https://gitter.im/chappjc/dcrspy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
74

85
dcrspy is a program to continuously monitor and log changes in various data
96
on the Decred network. It works by connecting to both dcrd and dcrwallet
107
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.
129

1310
## Types of Data
1411

1512
Two types of information are monitored:
1613

1714
* 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).
1916

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.
2119

22-
See [Data Details](#data-details) below for details.
20+
See [Data Details](#data-details) below for more information.
2321

2422

2523
## Output
2624

2725
Multiple destinations for the data are planned:
2826

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+
~~~
3559

3660
## TO-DO
3761

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+
3865
There is a [very long to-do list](https://drive.google.com/open?id=1Z057i7tGfnATWu0w7loetIkGElteNnlx2bJSxPvVOqE).
3966

4067
## Requirements
4168

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`.
4572

4673
## Installation
4774

48-
#### Build from Source
75+
### Build from Source
4976

50-
- Install Go:
77+
* Install Go:
5178
http://golang.org/doc/install
5279

53-
- Verify Go installation:
80+
* Verify Go installation:
5481

55-
`go env GOROOT GOPATH`
82+
`go env GOROOT GOPATH`
5683

57-
- Build executable
84+
* Build executable
5885

59-
`go get -u -v github.com/chappjc/dcrspy`
86+
`go get -u -v github.com/chappjc/dcrspy`
6087

61-
- Find dcrspy executable in `$GOPATH/bin`, and copy elsewhere (recommended).
88+
* Find dcrspy executable in `$GOPATH/bin`, and copy elsewhere (recommended).
6289

6390
## Updating
6491

@@ -68,55 +95,94 @@ Run the same command used to build:
6895

6996
## Getting Started
7097

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.
73100

74101
There are several program options, which may be utilized via:
75102

76103
1. Command line arguments
77-
2. Config file (e.g. dcrspy.conf)
104+
1. Config file (e.g. dcrspy.conf)
78105

79106
### Command line
80107

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
82120
Usage:
83-
dcrspy [OPTIONS]
121+
dcrspy.exe [OPTIONS]
84122
85123
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
108160
109161
Help Options:
110-
-h, --help Show this help message
111-
```
162+
/? Show this help message
163+
/h, /help Show this help message
164+
~~~
112165

113166
### Config file
114167

115-
```ini
168+
All command line switches may be placed into the config file, which is
169+
dcrspy.conf by default.
170+
171+
~~~ini
116172
[Application Options]
117173

118174
debuglevel=debug
119175

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+
120186
dcrduser=duser
121187
dcrdpass=asdfExample
122188

@@ -128,79 +194,84 @@ dcrwpass=qwertyExample
128194

129195
dcrwserv=localhost:9110
130196
dcrwcert=/home/me/.dcrwallet/rpc.cert
131-
132-
;noclienttls=false
133-
```
197+
~~~
134198

135199
## Data Details
136200

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.
138205

139206
1. Block header (hash, voters, height, difficulty, nonce, time, etc.)
140207

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
162229
}
163-
```
230+
~~~
164231

165-
2. Ticket pool info. This is a custom data structure.
232+
1. Ticket pool info. This is a custom data structure.
166233

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
172239
}
173-
```
240+
~~~
174241

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
176243
no extra arguments:
177244

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
187254
}
188-
```
255+
~~~
189256

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
191258
`estimatestakediff` and `getstakedifficulty`:
192259

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
202269
}
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.
204275

205276
## Issue Tracker
206277

@@ -212,4 +283,4 @@ dcrspy is licensed under the [copyfree](http://copyfree.org) ISC License.
212283

213284
dcrspy borrows its logging and config file facilities, plus some boilerplate
214285
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

Comments
 (0)