371 Commits

Author SHA1 Message Date
JoeGruff
fc1357aa38 docs/api: Add setaltsig details. 2021-10-23 11:14:11 +01:00
JoeGruff
b868b828f1 middleware: Allow alternate vsp auth address.
If an alternate address exists for this ticket, check it first and fall
back to the commitment address if validation fails. Alternate address
failure is allowed so that other endpoints do not need to add a field to
all requests specifying whether this is the alternate address's
signature or the commitment address's signature.
2021-10-23 11:14:11 +01:00
JoeGruff
6191ddb7c0 webapi: Add setaltsig endpoint.
Allow setting the alternate public key that signs json requests from
the client. Save a copy of the request and signature in the db.
2021-10-23 11:14:11 +01:00
JoeGruff
6e13d23214 db/ticket: Add AltSigAddress.
To allow signing with addresses other than the commitment address, add
an alternate signature address. In order to continue to prove that the
address was chosen by the user, add an alternate signature history. Only
allow one record per ticket to be saved to cap needed db space.
2021-10-23 11:14:11 +01:00
Jamie Holdstock
623bb192d1
Use latest dcrd RPC version.
This commit marks the point at which vspd will stop working against dcrd 1.6 and start to target master.

The dcrwallet RPC version has not changed, so vspd continues to work with dcrwallet 1.6 or master.
2021-10-23 11:13:51 +01:00
Jamie Holdstock
67b4c6c019
Use reflect.DeepEqual where possible. (#294)
Comparing each field manually is unnecessary and error-prone.
2021-09-15 14:24:51 -05:00
Jamie Holdstock
7f25f6614c
Remove string compare in dcrd error handling. (#295)
dcrd now returns the same error for duplicate transactions regardless of whether they are mined or only exist in the mempool.
2021-09-15 14:24:25 -05:00
Jamie Holdstock
522a363bda
Add architecture diagram to deployment.md. (#296)
Also add a note that voting wallets should not be run on the
web server.
2021-09-15 13:47:48 -05:00
Jamie Holdstock
83253f3c19
Use go 1.16 features (#292)
* Use features from Go 1.16 tooling.

- GO111MODULE environment variable now defaults to "on"
- "go build" and "go test" now exit with an error rather than silently modifying go.mod or go.sum files
- Update README.md

* Don't use deprecated ioutil package.
2021-08-26 09:29:43 -05:00
Jamie Holdstock
b97609cd2c
Update shutdown signalling. (#293)
Bring in some updates from the signal handling code in other projects:

- Rename `signals` to more descriptive `interruptSignals`.
- Add SIGHUP to unix shutdown signals. Rename `signalsigterm.go` to `signal_unix.go` accordingly.
- Include extra detail in "Already shutting down..." messages log lines.
- Pass a shutdown func into `webapi.go` rather than a channel. It's more obvious how to invoke a func, whereas a channel can be used in multiple ways.
2021-08-26 09:28:51 -05:00
David Hill
9ef8834187
build: test against Go 1.17 (#291) 2021-08-22 12:34:30 -05:00
Jamie Holdstock
ce0e28b8de
Use latest gin-gonic patch (#289) 2021-08-15 12:41:29 -05:00
JoeGruffins
f9c4e03eaa
cache: Avoid unlikely zero division. (#282) 2021-08-03 10:39:02 +01:00
Jamie Holdstock
c1ba46347e
Be more specific about consensus vote choices. (#278)
* Be more specific about consensus vote choices.

Rather than referring to just "Vote choices", refer specifically to "consensus vote choices".

This will be useful when treasury and tspend vote choices are added, and the distinction becomes more important.

* dnldd suggestion.
2021-07-05 09:16:08 -05:00
Jamie Holdstock
844d1a0736 Add comment to explain hard-coded relay fee. 2021-06-25 20:39:22 +08:00
Jamie Holdstock
74d32c5f09 Ensure PurchaseHeight is set for all tickets.
This is necessary because of an old bug which, in some circumstances, would prevent purchase height from being stored.
2021-06-25 15:56:35 +08:00
Jamie Holdstock
e42b1cad33 Update dcrd and dcrwallet deps. 2021-06-15 21:54:22 +08:00
Jamie Holdstock
2b2f6177bb Update third party deps. 2021-06-15 21:54:22 +08:00
Jamie Holdstock
36acb8c04a Vertical ticket search form. 2021-06-15 10:18:25 +08:00
Jamie Holdstock
ab5ee2857f Vertical login form and improve error appearance. 2021-06-15 10:18:25 +08:00
Jamie Holdstock
2b7903f7d5 Add database and logout tabs to admin page.
Buttons to logout and download DB backup are now moved into new tabs. Also the database size is displayed in the database tab.
2021-06-15 10:18:25 +08:00
Jamie Holdstock
fd4f2b2dad Add commas for large ticket counts. 2021-06-15 10:18:25 +08:00
Jamie Holdstock
5deb1abcfc Prevent dividing by zero when pool has no voted tickets. 2021-06-15 10:18:25 +08:00
Jamie Holdstock
b56dc26558 Add shutdownWg to dcrd notif handler.
This prevents db/dcrd/dcrwallet connections from being closed while the dcrd notification handler is running.
2021-06-15 10:13:31 +08:00
Jamie Holdstock
36c9f5a562 Fix typo in config comment. 2021-06-15 10:13:19 +08:00
Jamie Holdstock
fc131e926d
Refactor gui cache
* Remove static cfg values from GUI cache.

Theres no need for these values to be copied into the cache when templates could simply access the config struct directly.

This also changes the cache accessor so it returns a copy of the cache rather than a pointer, which removes a potential race.

* Rename and move cache.

Cache code was previous in `homepage.go`, but its used in multiple places and not just on the homepage. Its enough code to go into its own dedicated `cache.go`.
2021-06-12 09:54:53 +08:00
Jamie Holdstock
d1a838bf7f Add vspclosedmsg config.
If vspclosed is set to true, the provided message will be displayed on the webpage and returned by the status API endpoint.
2021-06-10 09:45:22 +08:00
Jamie Holdstock
4db50a4439 Helpers for bool<>[]byte conversion. 2021-06-09 21:25:21 +08:00
Jamie Holdstock
49af391b0c Only deserialize full ticket when filter matches. 2021-06-09 21:25:21 +08:00
Jamie Holdstock
f4adcfeaf0 Add version to bootstrap.css filename. 2021-06-09 21:25:05 +08:00
Jamie Holdstock
b9d4db40e9 Use vspd version as cache buster for .css files.
This will ensure when VSP admins update to a new version of vspd, web visitors will not use cached old .css files.
2021-06-09 21:25:05 +08:00
Jamie Holdstock
25ae1b89d6 Use a single cache buster string for favicon.
Previously two different strings were used as cache busters in favicon files. Only one is required. Using multiple increases the chance of making mistakes when updating the cachebuster in future.
2021-06-09 21:25:05 +08:00
Jamie Holdstock
9867f78385
Add network proportion to homepage and /vspinfo (and revoked proportion) (#264)
* Add network proportion to homepage and /vspinfo.

Proportion is calculated using the number of tickets  currently registered with the VSP, divided by the total size of the network ticket pool as reported by `getblockheader`.

The value will only ever be an estimate because:

- it's possible for a single ticket to be added to multiple VSPs.
- vspd does not distinguish between immature and live tickets, whereas `getblockheader` only reports live tickets.
- `getblockheader` is reporting the size of the ticket pool as of the previous block, not the current block.

* xaur suggestions

* Show missed ticket %, not just the raw number.
2021-06-08 08:47:07 -05:00
Jamie Holdstock
978b78e745
Compare scripts rather than addresses. (#267)
* Decode fee address with stdaddr.

Compare script and script versions rather than just comparing address strings.

Also move the fee amount check higher, so it is with the rest of the fee validating code.

* Compare voting addr scripts rather than addrs.

Rather than comparing the address strings, ensure both voting script and script version match.
2021-06-08 08:46:16 -05:00
Jamie Holdstock
dad662b0f0 Display fee in DCR rather than atoms. 2021-06-01 07:17:54 +08:00
Jamie Holdstock
c3eeb1eb5c Block explorer link for commitment address 2021-06-01 07:17:54 +08:00
Jamie Holdstock
a1091015ff Split ticket info into ticket, fee and voting info 2021-06-01 07:17:54 +08:00
Jamie Holdstock
2cdc5a74b5 Split admin page into tabs.
Previously the voting wallet status and the ticket search were stacked on top of eachother, making the page very long and awkward to navigate. This introduces tabbed navigation which allows just one to be displayed at a time.
2021-06-01 07:17:54 +08:00
Jamie Holdstock
7edbd02d4e Use proper background color. 2021-06-01 07:17:54 +08:00
Jamie Holdstock
32c5c7a524 Indent JSON on admin screen. 2021-06-01 07:17:54 +08:00
Jamie Holdstock
851d3137e5 Improve voting wallet status aesthetics. 2021-06-01 07:17:54 +08:00
Jamie Holdstock
e05ced391a Various minor cleanups.
- Updating and adding some copyrights which were missed recently.
- Slight improvements to some commenting and naming.
2021-06-01 07:17:11 +08:00
Jamie Holdstock
20cb546e74
Store each ticket in its own DB bucket.
**NOTE: This contains a backwards incompatible database migration, so if you plan to test it, please make a copy of your database first.**

Moves tickets from a single database bucket containing JSON encoded strings, to a bucket for each ticket.

This change is to preemptively deal with scaling issues seen with databases containing tens of thousands of tickets.
2021-05-24 17:45:47 +08:00
Jamie Holdstock
136e389f95 Update to golangci-lint 1.40.1.
Linter `golint` has been deprecated and replaced with `revive`.
2021-05-23 11:37:54 +08:00
Jamie Holdstock
2d0db6f6b3 Remove confirmed fee tx hex.
This PR introduces a database migration which deletes any raw fee transactions which remain in the database after already having been confirmed on-chain. There is no need to keep these, and they take up a lot of space.

There is also a change in the background handler to ensure that in future, tx hex is always removed from the database when the tx is confirmed.
2021-05-20 13:33:41 +08:00
Jamie Holdstock
1988322cac Add timezone to GUI timestamps 2021-05-20 13:04:33 +08:00
Jamie Holdstock
8b5cd2a014 Properly close db after running tests 2021-05-18 23:25:42 +01:00
Jamie Holdstock
a8c0ae95ac
Use a custom Recovery middleware. (#255) 2021-05-18 07:27:12 +01:00
Jamie Holdstock
b050fc3100
Set and display ticket purchase height (#250)
* Ensure purchase height set for confirmed tickets.

* Show purchase height in admin screen.

Only show purchase height when the ticket is confirmed, because if a ticket is not confirmed, its purchase height is not yet known.
2021-05-14 21:19:01 -05:00
Jamie Holdstock
08fafdaf31
Remove relayFee todo. (#256)
Accepting this as a hard-coded value. It will not be retrieved from RPC or config.
2021-05-14 21:09:24 -05:00