529 Commits

Author SHA1 Message Date
jholdstock
7a30e22d0a main: Update gitignore to only ignore executables.
A line such as "v3tool" is not specific enough as it does not only
ignore files named "v3tool", but also directories. This is problematic
when adding new files to the directory "/cmd/v3tool/".
2023-08-18 14:31:19 +01:00
jholdstock
de79ce74bb docs: Add 1.2.1 release note. 2023-07-05 09:07:20 +01:00
Jamie Holdstock
0272d713b6
docs: Move 1.2.0 release note to proper dir. (#400)
Not sure how this made it into the root dir, should have been with the rest of the docs.
2023-07-04 09:54:45 -05:00
Jamie Holdstock
d8bcc9292f rpc: Ignore another "duplicate tx" error.
sendrawtransaction is expected to fail if the transaction already exists in the mempool or a mined block. dcrd returns two different errors which can indicate this situation. Handling for one of them already existed, and this commit adds handling for the other.
2023-07-04 11:27:57 +01:00
jholdstock
a88c261cb1 webapi: Display decoded fee tx, not just raw bytes
When searching for a ticket in the admin interface, use GetRawTransaction RPC to get the decoded transaction and display it as formatted JSON.
2023-06-27 14:52:24 +01:00
jholdstock
4dc2cc4d8d webapi: Use raw whitespace to format JSON.
No need to manually construct HTML in this formatting func, it can simply deal with whitespace and then use <pre> tags to display.

Add some tests to validate behaviour.
2023-06-27 14:52:24 +01:00
jholdstock
78cf99bc2c webapi: Use input type "search" for ticket hash.
The "search" input type is functionally the same as "text" but has a nice extra property - most browsers will render it with a "Clear" button to wipe the current input.

Also disable spellchecking on this input.
2023-06-27 14:52:24 +01:00
Jamie Holdstock
ac973bd056
main: Update .gitignore
- Remove redundant duplication
- Add v3tool executable
- Add harness dir
2023-06-27 14:03:18 +01:00
jholdstock
fc0ed6b2c7 version: Bump to 1.3.0-pre 2023-06-15 08:32:58 +01:00
jholdstock
a06a62bfd0 docs: Add 1.2.0 release note. 2023-06-14 10:24:48 +01:00
Jamie Holdstock
f46ffcb60d
docs: Review and polish existing docs. (#390)
Also includes a couple of updates to comments in webapi code.
2023-06-13 13:22:57 -05:00
jholdstock
43a1b9fbdc build: Update transitive deps. 2023-06-13 09:32:14 +01:00
jholdstock
85ebeefafa build: Use tagged dcrwallet v3 2023-06-13 09:32:14 +01:00
jholdstock
9863636978 webapi: Update to gin 1.9.1. 2023-06-13 08:48:56 +01:00
jholdstock
64e044f4ed rpc: Use latest dcrd & dcrwallet 2023-06-13 08:48:46 +01:00
jholdstock
7cb4681639 main: Use latest dcrd deps. 2023-06-11 11:42:53 +01:00
Dave Collins
74579a2931 client: Use latest dcrwallet dep.
This updates the client module to use the latest release version of the
dcrwallet dep.
2023-06-11 10:26:56 +01:00
Dave Collins
6adbfcff20
client: Use latest dcrd deps.
This updates the client module to remove all replace directives and
use the latest release versions of the dcrd deps.
2023-06-09 10:06:51 -05:00
Jamie Holdstock
203bf7d2e6
build: Update linter to 1.53.2 (#384)
* build: Update linter to 1.53.2

* database: Rename helpers.go to encoding.go

* database: Ignore json.Marshal errors.
2023-06-05 09:39:01 -05:00
Jamie Holdstock
a5003c046b
client: Automatic fee payment from dcrwallet (#382) 2023-05-30 11:50:23 +01:00
jholdstock
799041a1e5 docs: Update links to errors and req/resp types. 2023-04-21 08:58:09 +01:00
jholdstock
f8096ef8c4 README: Add link to blog. 2023-04-19 09:54:29 +01:00
Jamie Holdstock
08ea48f7a3
Update decred dependencies. (#378)
* webapi: Use types 2.0.0

* v3tool: Use types 2.0.0

* Update decred dependencies.
2023-04-12 08:16:29 -05:00
Jamie Holdstock
6b99c5d2b5
webapi: Use types 2.0.0 (#376)
* webapi: Use types 2.0.0

* v3tool: Use types 2.0.0
2023-04-12 08:12:53 -05:00
Jamie Holdstock
b5ac64891e
Add v3tool. (#366)
This commit adds a new executable - v3tool - a developer testing tool which hits endpoints of the vspd API.
2023-03-24 13:10:44 -05:00
jholdstock
0c06145d67 client: Use types 2.0.0 2023-03-16 16:14:59 +00:00
jholdstock
6d78e16b23 types: Use ErrorCode in ErrorResponse.
Using ErrorCode instead of int64 in the ErrorResponse type removes the burden of type conversion from calling code.
2023-03-16 16:07:38 +00:00
jholdstock
8303aa8536 client: Add tests for server signature validation.
New tests to ensure that the correct error is returned when the server signature is invalid.
2023-03-15 10:46:13 +00:00
jholdstock
79fd2f7bbe client: Add additional test case for errors.
Tests now check that the correct vspd error code is returned by the
client.
2023-03-15 10:46:13 +00:00
jholdstock
be79a8e279 client: Hard-code validate func.
The client supported overriding the default server signature validation func. This was originally added to facilitate testing, but at the moment only serves to make using the client more clunky and error prone.
2023-03-15 10:46:13 +00:00
jholdstock
2fec8cf5d8 docs: Add sample nginx config. 2023-03-15 10:45:54 +00:00
jholdstock
62803147f0 webapi: Rate limit for admin login requests.
Only allow 3 requests per second. Return "429 Too Many Requests" when this rate is exceeded.
2023-03-15 10:45:54 +00:00
Jamie Holdstock
d00ba70f94
vspd: Fix invalid default config log level. (#371)
* vspd: Fix invalid default config log level.

slog.LevelDebug.String() returns "DBG" which is not valid per the config validation rules specified below. Hard-code "debug" instead.

* Update year.
2023-02-24 09:55:25 -05:00
Jamie Holdstock
2c1bb0027f
docs: Remove dcrstakepool note. (#370)
No need to keep the instructions for deploying vspd along dcrstakepool as it is now defunct.
2023-02-24 09:54:56 -05:00
jholdstock
31a2726578 client: Add tests for error handling.
The tests are to ensure that vspd errors are correctly wrapped as types.ErrorResponse, and non-vspd errors contain adequate information for debugging.

A small change in the client code itself was required to satisfy these conditions.
2023-02-17 20:51:48 +00:00
jholdstock
36505b529c client: Remove constructor.
The constructor contained no important logic and removing it makes the upcoming test code slightly more clean/convenient.
2023-02-17 20:51:48 +00:00
jholdstock
33bb68c3df types: Run tests as sub-tests.
This enables better reporting of test results/metrics, and removes the need to manually include test names in logs.
2023-02-17 20:45:11 +00:00
jholdstock
fb8c58c512 build: Update deps. 2023-02-17 20:45:01 +00:00
jholdstock
67910d0fb3 build: Update to go 1.20. 2023-02-17 20:45:01 +00:00
Jamie Holdstock
7718476caf
webapi: Move VSP closed check to middleware.
Checking this in middleware not only removes duplicated code from each of the handlers, but also makes things more efficient. Previously, dcrd/dcrwallet/database clients were initialized (and could possibly cause errors) **before** checking if the VSP is closed. Now the check happens before those other things.

Also bundled with some improvements to setaltsignaddr_test.go which I implemented along the way.
2023-02-17 20:44:13 +00:00
Jamie Holdstock
824c41c2a5
Remove duplicate fee addr check. (#361)
This check was added preemptively, the error has never actually been observed in dev, testing, or production.

It does not scale well. Its takes almost 500ms to insert into a database containing 100k tickets.
2022-12-01 00:08:18 -05:00
Jamie Holdstock
4acd57efbc
Add client module (#359)
* Add vspd client from dcrwallet.

* client: Extract and export ValidateServerSignature

* client: Add helper funcs.

* client: Add trace logging.

* client: Use existing error types.

* Add comments to explain error handling logic.
2022-11-28 11:16:00 -05:00
Jamie Holdstock
5d7d347114
Use tagged types module. (#358) 2022-11-28 11:14:58 -05:00
Jamie Holdstock
68047dc6ce build: Ensure ci lints all modules.
Use run_tests.sh in CI because the official golangci-lint GitHub action does not handle submodules.
2022-11-26 09:46:36 +08:00
Jamie Holdstock
c9f3573d8b build: Only invoke tests once.
`go test $ROOTPATH/...` runs all tests in the root module, and all tests in
submodules, so there is no need to run `go test` in the loop which
descends into submodule directories. Doing this actually causes each
test file to be run twice because the first iteration of the loop *is* the root
module, and thus all tests.

Only the linter needs to be invoked from each module directory.
2022-11-26 09:46:36 +08:00
Jamie Holdstock
42d91752f5 build: Rename root pkg path vars.
This renames the variables in the script that runs tests against all
modules to better reflect reality as of the latest versions of Go.

In particular, instead of referring to `ROOTPATH`, it now uses `ROOTPKG`
to better indicate that it is the name of root package as opposed to a
file path to it.
2022-11-26 09:46:36 +08:00
Jamie Holdstock
6d872db60e
Rename APIError to ErrorResponse. (#360)
Last commit before tagging v1.0.0 of the types module. The name ErrorResponse is consistent with all other response types.
2022-11-22 17:09:06 +08:00
Jamie Holdstock
ed1fac1a2a
Add types module for API requests/responses/errors. (#356)
* Remove helper func getCommitmentAddress.

This function is only used in one place so removing it does not introduce any duplication. Removing the func also removes the need for errors.Is comparison, which will be very useful in upcoming changes.

* Rename apiError to ErrorCode.

* Don't use inline type for API errors.

* Export webapi errors.

* Export webapi request/responses.

* Add types module for API requests/responses/errors
2022-11-18 15:06:47 -05:00
Jamie Holdstock
a5998264b3
Include commit ID in build info. (#357)
* ci: Update GitHub actions and linter.

* Update go deps.

* Include commit ID in build info.

Introduced in go 1.18, debug.ReadBuildInfo allows a go process to discover the git commit it was built from.
2022-11-18 15:06:00 -05:00
Jamie Holdstock
8bb868a5a5
Add vote-validator tool. (#335)
vote-validator is a tool for VSP admins to verify that their vspd deployment
is voting correctly according to user preferences.
2022-11-18 15:05:38 -05:00