550 Commits

Author SHA1 Message Date
jholdstock
618cfc7cf1 vspd: Remove simnet params.
Simnet params were added in the very first commit of vspd purely because
of copy/pasting from another project.

vspd has never actually been tested on simnet, so its possible
(probable) that it won't even operate correctly without additional dev
work. If we want simnet to be a properly supported network it can be
re-added and tested in the future.
2023-08-26 09:33:30 +01:00
jholdstock
fe8e63a295 build: Use latest golangci-linter. 2023-08-24 07:52:40 +01:00
jholdstock
a4d21d7838 build: Add extra linters.
Some of these cover points which have recently been highlighted in
reviews, such as contexts contained in structs, slices initialized with
zero length, and periods missing from the end of comments.
2023-08-24 07:52:40 +01:00
jholdstock
5f81b0b40e database: Ensure comments end with period. 2023-08-24 07:52:40 +01:00
jholdstock
c052365be8 client: Use %w to wrap error correctly. 2023-08-24 07:52:40 +01:00
jholdstock
e80ebfea13 rpc: Do not store contexts in structs.
Documentation for the context package suggests that Contexts should
never be stored in structs.
2023-08-24 07:52:40 +01:00
jholdstock
49b9db1a64 rpc: Fix block connected handler.
Fix a bug where it appeared as though a notification handler was being
attached to the dcrd RPC client, but actually no notifications were
received until the client was disconnected a new one was created.

Now, rather than delaying attaching the notification handler, it is
attached immediately upon client creation and vspd does not start
handling the received notifications until it is ready.
2023-08-24 07:27:04 +01:00
jholdstock
bac0dcef71 multi: Hoist database integrity checks up to vspd.
Moving the existing integrity checks up into vspd removes the
depdendancy on rpc clients from the database client, and also creates a
natural home for future integrity checks to be added.
2023-08-23 12:48:19 +01:00
jholdstock
b1fbced17c vspd: Move vspd code to its own file.
Moving all vspd code into its own vspd.go file (fka background.go). This
leaves main.go as a minimal entry point for the vspd executable.
2023-08-23 12:32:14 +01:00
jholdstock
4419ae3a6e vspd: Introduce vspd struct.
Storing all of the essential resources such as db, rpcs and logger in a
vspd struct enables vspd functions to be called without passing a bunch
of parameters unnecessarily. This will be increasingly useful later when
further changes are introduced.
2023-08-23 12:32:14 +01:00
jholdstock
c039dc86cb multi: Use const instead of var when possible. 2023-08-22 15:58:48 +01:00
jholdstock
3ddad3eeb5 database: Try get purchase height for all tickets.
Only fatal errors should result in data integrity checks being stopped.
If a single ticket encounters an error, that error should be logged and
other tickets should still be attempted.
2023-08-22 15:58:48 +01:00
jholdstock
010da298c4 rpc: Break out GetBlockHeaderVerbose func.
This makes the RPC reusable by other code in future.
2023-08-22 15:58:48 +01:00
jholdstock
bca2a32a30 database: Add TicketList struct.
This enables a func to find the earliest purchase height to be reused in
multiple packages.
2023-08-22 15:58:48 +01:00
jholdstock
8b50fe619a vspd: Simplify shutdown listener.
The existing signal.go was inherited directly from dcrwallet, and was
slightly more flexible/complicated than required for vspd. This brings
the code more inline with the dcrd implementation which can be
instantiated in one line and with only one parameter.
2023-08-22 15:10:03 +01:00
jholdstock
350a3f5bb2 vspd: Create context and waitgroup near usage.
Creating these closer to where they are needed tidies things up a bit,
and reduces the chance of them being used unnecessarily (as was being
done previously).
2023-08-21 08:33:54 +01:00
jholdstock
bd41dbee63 vspd: Listen for dcrd notifs after startup.
Only attach the dcrd notification listener after all other startup tasks
have been completed.

Attaching the listener before this can result in the notification
handler being invoked whilst startup tasks are still running, which
isn't necessarily a problem, but it is unnecessary and makes a mess of
logging.
2023-08-21 08:33:54 +01:00
jholdstock
2db761e072 client: Remove autoclient & bump to v3
Adding the autoclient to vspd created a circular dependency between vspd
and dcrwallet which is cumbersome and not worth the maintence burden.

At this point there are no known consumers of the vspd version of
autoclient, so removing it is not expected to cause problems for
anybody.

The autoclient will continue to live in the dcrwallet repo.
2023-08-18 14:32:37 +01:00
jholdstock
45addd2a18 build: Use go 1.21 & update GitHub actions. 2023-08-18 14:32:30 +01:00
jholdstock
0a38bd8152 multi: Replace interface{} with 'any' alias 2023-08-18 14:32:17 +01:00
jholdstock
820f130f59 webapi: Add test for securecookie error.
A simple test to ensure an error string returned by the securecookie lib
does not change when we upgrade to newer versions. Important because
vspd checks for this error using string comparison.
2023-08-18 14:31:26 +01:00
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