75 Commits

Author SHA1 Message Date
jholdstock
65fab01225 Remove remaining global loggers.
This removes all of the global loggers from the project and replaces them with loggers which are instantiated in vspd.go and passed down as params.

To support this, the background package was removed. It only contained one file so it was a bit pointless anyway. It only existed so background tasks could have their own named logger.
2022-06-29 08:31:44 +01:00
jholdstock
ebcfe0e5e9 Remove global logger from webapi. 2022-06-23 09:11:28 +01:00
jholdstock
01b0df2d7a Remove global loggers from components.
- Web API Cache
- Recovery Middleware
- Database upgrades
- Address Generator
2022-06-13 14:50:16 +01:00
jholdstock
75026f5e91 Clean up use of shutdown context.
- Rename all instances to "shutdownCtx" to be really explicit. This context is special in that it can be closed at any time without warning, so it should be obvious to the reader.
- Don't use shutdownCtx in RPC clients. Clients should not stop working immediately when shutdown is signalled, they need to keep working while the process is shutting down.
2022-05-19 07:59:44 +01:00
Jamie Holdstock
78bb28056c
Remove global cache variable. (#341)
* Remove global cache variable.

Rather than maintaining cached data in a global variable, instantiate a cache struct and keep it in the `Server` struct.

* Store net params in RPC clients.

This means net params only need to be supplied once at startup, and also removes a global instance of net params in `background.go`.
2022-03-30 11:00:42 -05:00
jholdstock
c91ec5c697 Use time.After instead of tickers. 2022-03-28 16:37:25 +01:00
jholdstock
37d51df546 Remove global vars from webapi package. 2022-03-28 08:54:09 +01:00
Ukane philemon
3bb2f65151
add votingwalletsonline and totalvotingwallets to /vspinfo 2022-03-17 10:40:47 +00:00
Ukane philemon
655e5756af
Using error.Is and error.As
* This allow using error.Is and error.As within vsp.
* Add test cases for apiError type.
2022-03-15 10:20:07 +00:00
jholdstock
ab5aa4dd6d Clarify "setaltsig" terminology.
Stardardize "alt sig"/"alt signature"/"alt signing address" terminology to "alternate signing address".
2021-11-16 14:49:13 +00:00
jholdstock
b1a68a94fe Use constants for web context keys. 2021-11-16 14:33:39 +00:00
jholdstock
6acc5be10c Add dcrd to VSP status.
This renames "Voting wallet status" to "VSP status" and it now includes the status of the local dcrd instance. This change impacts both the /admin page of the UI, and the response of the /admin/status API endpoint.
2021-11-16 14:33:39 +00: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
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
Jamie Holdstock
fd4f2b2dad Add commas for large ticket counts. 2021-06-15 10:18:25 +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
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
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
dad662b0f0 Display fee in DCR rather than atoms. 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
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
Jamie Holdstock
ef472ffe5d
Include best block height in /vspinfo response (#254) 2021-05-14 21:09:03 -05:00
jholdstock
3a97c9214b Show formatted date for fee expiry 2021-05-13 12:16:08 +01:00
jholdstock
b5a65a9e78 Add block explorer links to tx hashes and fee addr 2021-05-13 12:16:08 +01:00
Jamie Holdstock
5f8ad656f7
Add framework for database upgrades. (#242)
Plus a few other miscellaneous pieces which will be usedful soon:

- Remove `Get` from func names `GetCookieSecret` and `GetFeeXPub`.
- Add helpers to encode/decode integers/bytes.
2021-05-05 08:54:51 -05:00
David Hill
2a096d81f9
fix errorlint warnings (#193) 2020-11-25 15:14:18 +00:00
jholdstock
825a717ca7 Store records of vote choice changes 2020-09-17 16:05:07 +00:00
jholdstock
c7f8cea4dc webapi: base64 encode server signature 2020-08-31 17:14:33 +00:00
jholdstock
4a207b15f8 Add missing copyright notices 2020-08-19 20:22:12 +00:00
jholdstock
dab1666310 Only load .html files in template dir 2020-08-19 20:20:13 +00:00
jholdstock
e0fc5b8d04 Add basic http auth for /admin/status. Update docs. 2020-08-07 17:03:27 +00:00
jholdstock
8c3cab7942 API versioning 2020-07-17 14:31:42 +00:00
vctt94
6f2a069047 Fix ticket status request erroring on json unmarshal 2020-07-16 18:09:45 +00:00
jholdstock
3bbad27624 Endpoint for JSON wallet status 2020-07-09 21:01:20 +00:00
jholdstock
1c351d02ec Add voting wallet status to admin page 2020-07-09 21:01:20 +00:00
jholdstock
27e49e5e69 Include ticket hex in feeaddress request. 2020-06-30 14:57:38 +00:00
jholdstock
1131e15ff1 Include ticket hex in feeaddress request. 2020-06-29 16:42:10 +00:00
jholdstock
5e8ef4e7f2 Prefix for dcrd/dcrwallet/db errors 2020-06-25 15:45:01 +00:00
jholdstock
600cd7bf9b Use modern logo and colours. 2020-06-18 20:18:17 +00:00
jholdstock
13c4f4faea Protect cached vsp stats with mutex. 2020-06-16 14:23:35 +00:00
Jamie Holdstock
bfeddd25d1 Download db backup from admin page. 2020-06-12 13:35:43 +00:00
jholdstock
d53676a907 Use middleware to check admin status. 2020-06-12 13:35:43 +00:00
jholdstock
2f7c46e5f8 Misc front end improvements.
- Use bootstrap to improve layout.
- Add warning banners for webserver debug mode and vspd closed.

Admin page:
- Replace listing of all tickets with form to search by ticket hash
2020-06-12 13:35:43 +00:00
jholdstock
a304fc9890 Close the database after web server is stopped.
Previously all of the shutdown tasks were running concurrently, which meant the db could be closed before the webserver is finished using it.
2020-06-12 13:23:55 +00:00
jholdstock
6caaac0442 Remove global dcrd/dcrwallet clients 2020-06-09 13:12:43 +00:00
jholdstock
9f48bae78e Return parsable error codes instead of just a string.
Also
- Check if VSP is closed before /payfee
2020-06-08 15:33:06 +00:00