73 Commits

Author SHA1 Message Date
jholdstock
7d1b7deb01 multi: Remove GetBlockHeaderVerbose.
A slight performance improvement becase vspd can do everything it needs
without the verbose block header.
2023-09-04 16:51:27 +01:00
jholdstock
9be203c923 multi: Find voted/revoked tickets with GCS filters
Use dcrd and GCS filters to find voted/revoked tickets rather than using
the dcrwallet TicketInfo RPC.

Using TicketInfo was a bit flakey because wallets do not always
correctly detect votes/revokes, and as a result VSP admins may notice
that with this change vspd detects some historic voted/revoked tickets
which TicketInfo never detected.
2023-08-26 09:33:30 +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
c039dc86cb multi: Use const instead of var when possible. 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
0a38bd8152 multi: Replace interface{} with 'any' alias 2023-08-18 14:32:17 +01: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
64e044f4ed rpc: Use latest dcrd & dcrwallet 2023-06-13 08:48:46 +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
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
7f72caafe7 Remove global vars from background.go
While removing the globals from background.go it also made sense to clean up the use of dcrd RPC clients. Previously two seperate clients were maintained, one for making RPC calls and one for receiving notifications. These clients have been unified.
2022-06-13 14:50:27 +01:00
jholdstock
4beb036663 rpc: Use context.TODO instead of .Background 2022-05-19 07:59:44 +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
d8dd02433c Move CanTicketVote out of dcrd RPC client.
`CanTicketVote` doesn't really fit into the RPC client code as it is more of a business logic function. Moving it into the webapi package is more appropriate.
2022-05-06 11:14:22 +01:00
jholdstock
b32bb56032 Remove hash param from CanTicketVote.
CanTicketVote already has the full rawTx, so it doesn't need the hash passed in separately.
2022-05-06 11:14:22 +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
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
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
David Hill
0fd96388ce
build: bump dcr deps (#310) 2021-12-29 11:23:45 +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
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
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
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
ef472ffe5d
Include best block height in /vspinfo response (#254) 2021-05-14 21:09:03 -05:00
Jamie Holdstock
4858af2682
Upgrade deps (#239)
* Update to latest deps.

Includes using the dcrd stdaddr package instead of dcrutil.

* Use stdaddr.Hash160
2021-04-26 09:12:23 -05:00
Jamie Holdstock
79cdeaaf8b
Add parser for blockconnected notification (#238) 2021-04-25 08:22:13 -05:00
Jamie Holdstock
057b89e2f2
Only marshal DB record when needed (#214)
* Only marshal DB record when needed

* Lock mutex before deferring Unlock.
2020-12-27 15:20:46 +00:00
David Hill
2a096d81f9
fix errorlint warnings (#193) 2020-11-25 15:14:18 +00:00
Jamie Holdstock
4f8b3c79eb
Add debug logging to TicketInfo RPC. (#208) 2020-11-21 22:12:29 +00:00
David Hill
a67de8a024
rpc: optimize TicketInfo (#189) 2020-10-05 10:30:42 +01:00
David Hill
c83a2a0085
rpc: verify dcrwallet's have --manualtickets set. (#187) 2020-09-25 09:55:53 +01:00
jholdstock
4a207b15f8 Add missing copyright notices 2020-08-19 20:22:12 +00:00
jholdstock
ba77d39f35 Comment exported methods 2020-08-07 17:03:03 +00:00
David Hill
b8c6ffe1e0
rpc: set tls options (#168)
* rpc: set tls options

* build: golangci-lint v1.30.0
2020-08-06 09:00:35 +01:00
jholdstock
c308b8a9a6 Close RPC connection if server doesnt meet reqs 2020-08-03 13:26:47 +00:00
jholdstock
4139f25670 semver matching for dcrd/dcrwallet RPC versions 2020-08-03 13:26:47 +00:00
jholdstock
6cc246ceea Configure RPC auth per wallet host. 2020-07-30 18:26:01 +00:00
jholdstock
9d503e67ae Wallet consistency checks & setting ticket outcome 2020-07-28 20:09:23 +00:00
jholdstock
1c351d02ec Add voting wallet status to admin page 2020-07-09 21:01:20 +00:00
jholdstock
da410b5060 Update log format 2020-07-09 21:01:20 +00:00
jholdstock
c05cdc0069 Construct full RPC addr just once 2020-07-09 21:01:20 +00:00
jholdstock
c5485a28ec Return string for failed rpc connections 2020-07-09 21:01:20 +00:00
jholdstock
7f969c6db5 Dont fail wallet connection if wallet is locked 2020-07-09 21:01:20 +00:00
jholdstock
aed1e5f5d4 Extract walletinfo for re-use 2020-07-09 21:01:20 +00:00
jholdstock
b029d88fdb Check dcrwallet network before calling walletinfo RPC 2020-07-09 21:01:20 +00:00
jholdstock
70ba1adc93 Combine ImportPrivKey and AddTransaction 2020-07-09 21:01:20 +00:00
jholdstock
80f5e6f55c Extract code to decode tx and validate tickets 2020-06-22 16:23:31 +00:00
jholdstock
5d8215e6b7 Move rpc errors to rpc package. 2020-06-22 16:23:31 +00:00