307 Commits

Author SHA1 Message Date
jholdstock
78abc59e97 Update for go 1.18 2022-03-28 16:37:39 +01:00
jholdstock
a412e3e8b9 Tidy hard-coded strings. 2022-03-28 16:37:25 +01:00
jholdstock
c91ec5c697 Use time.After instead of tickers. 2022-03-28 16:37:25 +01:00
jholdstock
9fe6eb8e52 Critical log startup and shutdown.
These messages should always be logged, even if log level is set to WARN or ERROR.
2022-03-28 16:37:25 +01:00
jholdstock
fba9fe5b0a Move database encoding helpers. 2022-03-28 16:37:25 +01:00
jholdstock
3b1812e98f Minor cleanups for new helpers.
- Ensure errors are properly wrapped with `%w`
- Error strings should not starts with caps.
- Add missing params to "Bad signature" error log
2022-03-28 16:37:25 +01:00
Jamie Holdstock
f1cc73e218
Add mainnet pre-release warning.
Make the existing startup warning more obvious, and add a new one for when a pre-release version of vspd is used on mainnet.
2022-03-28 16:37:12 +01:00
jholdstock
37d51df546 Remove global vars from webapi package. 2022-03-28 08:54:09 +01:00
Ukane philemon
4d4f9c8ca0
add new helper functions 2022-03-28 08:26:08 +01:00
Jamie Holdstock
860e50130e
Add 1.1.1 release note 2022-03-23 12:27:26 +00:00
Jamie Holdstock
aac96f8c9d
Fix assignment to nil map.
Ensure that Tickets loaded from the database are returned with empty maps instead of nil maps.

To be back-ported to 1.1.0 release.
2022-03-22 13:46:43 +00:00
jholdstock
9fa1012f3d Add some new linters. 2022-03-21 14:49:40 +00:00
jholdstock
2d67a35ba5 Use golangci-lint GitHub action.
- Rather than manually downloading and invoking golangci-lint, use the GitHub
action provided by the developers.
- Configure golangci with a config file rather than passing command line args.
This enables the same config to be used locally and on CI without introducing
duplication. It also allows much more flexibililty in configuration than using
CLI args alone.
2022-03-21 14:49:40 +00:00
Ukane philemon
00b26f8b0a
gitignore .exe files 2022-03-21 14:48:00 +00:00
Ukane philemon
3bb2f65151
add votingwalletsonline and totalvotingwallets to /vspinfo 2022-03-17 10:40:47 +00:00
Jamie Holdstock
9a4646f002
Use GitHub mermaid.js rendering.
GitHub is now capable of rendering mermaid.js diagrams, so we don't need to maintain a separate source and rendered .png file. The mermaid source can be embedded directly into the documentation itself.
2022-03-17 09:52:44 +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
Jamie Holdstock
4dd4954517
Bump version to 1.2.0-pre 2022-03-14 12:40:58 +00:00
Jamie Holdstock
f0430f1f6c
Add 1.1.0 release note 2022-02-18 06:35:47 +00:00
Jamie Holdstock
da1cb8f916
Enable treasury vote choices. (#319)
This allows both tspend and treasury policies to be set by clients on a per-ticket basis. Preferences can be set when initially registering a ticket with `/payfee`, and can be later updated using `/setvotechoices`.

Any requests which alter treasury/tspend policy will be stored in the database using the existing accountability system.

**Note:** This does not include consistency checking, it will need to be added later when dcrwallet has an RPC to retrieve policies in batches.
2022-02-04 14:14:49 -05:00
Jamie Holdstock
dcbf8a2c18
Ensure previous vote choices are remembered. (#323) 2022-02-02 10:04:53 -05:00
Jamie Holdstock
040ed56f11
Use DCP-0010 status to calculate fees.
vspd will now call dcrd RPC `getblockchaininfo` to determine if DCP-0010 is active, and take that information into consideration when calculating ticket registration fee.
2022-01-20 08:54:52 +00:00
Ukane philemon
74aa7bcd13
Added alternate signing address to /ticketstatus response (#314) 2022-01-17 10:50:46 +00:00
ukane-philemon
0b78c9c2da Show altsignaddress req/res in admin UI 2022-01-13 12:40:16 +00:00
David Hill
0fd96388ce
build: bump dcr deps (#310) 2021-12-29 11:23:45 +00:00
Jamie Holdstock
913b38bf14
Configurable harness directory. (#309)
Add a -r flag to the harness script which enables the default root directory to be changed.
2021-11-29 14:34:47 -05:00
Jamie Holdstock
0919c6db29
Update gin to 1.7.7. (#308)
This pulls a fix which enables vspd to determine remote client IP using header `X-Forwarded-For` or `X-Real-Ip`.

This depends on the reverse proxy setting those headers appropriately, which can be achieved in nginx 1.20 using the following:

```
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
```
2021-11-29 14:34:18 -05:00
jholdstock
43873ec320 Record expired/missed tickets as revoked.
This is an unfortunate workaround which is necessary because an instance of dcrwallet will only recognise a ticket as revoked if it has done the revoke itself. If another wallet broadcasts the revoke then the ticket will forever be reported as missed/expired. This causes problems for vspd when a wallet outside of the vspd deployment revokes a ticket (eg. a users ticketbuyer wallet).

I'm happy to include this slightly dirty workaround because this should no longer be an issue when the auto-revoke work in DCP-0009 lands.
2021-11-16 14:57:43 +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
jholdstock
d337e0a321 Delay dcrd client error handling.
Errors generated during dcrd client creation were previously handled in middleware, and request handling was terminated immediately.

Now the error handling is delayed by adding the error details to the request context. This enables downstream handlers to decide what to do with the error.
2021-11-16 14:33:39 +00:00
jholdstock
ce5227356d Update build tags to pref. go1.17 syntax. 2021-11-16 14:33:39 +00:00
jholdstock
6260e4ee5b Add alternate sign address to ticket search result 2021-11-14 11:00:39 +00:00
jholdstock
efa5a09820 Don't export types unnecessarily. 2021-11-14 11:00:39 +00:00
jholdstock
4ea25ec327 Extract search results to own template.
Reducing the size and nesting of admin.html.
2021-11-14 11:00:39 +00:00
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