**Warning: This commit contains a database upgrade.**
In order to add future support for retiring xpub keys, the database is
upgraded such that the keys are now stored in a dedicated bucket which
can hold multiple values rather than storing a single key as individual
values in the root bucket.
A new ID field is added to distinguish between keys. This ID is added to
every ticket record in the database in order to track which pubkey was
used for each ticket.
A new field named "Retired" has also been added to pubkeys. It is a unix
timestamp representing the moment the key was retired, or zero for the
currently active key.
A new tab on the admin page displays a list of all tickets which were
registered with the VSP but missed their votes. Clicking on the ticket
hash redirects to the Ticket Search tab with the details of the missed
ticket displayed.
Any tickets in the database which are currently revoked should be
updated to either expired or missed.
This is achieved with a heuristic based on the expiry height and
revoke height of the tickets. It is not guaranteed to be 100% correct
but should be pretty close.
The web api is not yet updated to reflect this change, missed/expired
tickets will continue to be counted as revoked.
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.
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.
**NOTE: This contains a backwards incompatible database migration, so if you plan to test it, please make a copy of your database first.**
Moves tickets from a single database bucket containing JSON encoded strings, to a bucket for each ticket.
This change is to preemptively deal with scaling issues seen with databases containing tens of thousands of tickets.
This check was added to InsertNewTicket pre-emptivly as a sanity check. It is not strictly required because the fee address itself is also checked, and there is no scenario where we would expect a fee address and its index not to match.
Removing this check eases the route forward to improving database performance.
- 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
- Fee tx status is now tracked using a dedicated field, with values none/received/broadcast/confirmed/error.
- Fee tx hex and hash are now both set in /payfee. The absense of txhash is no longer used to determine if a fee tx has been broadcast or not.
- setvotechoices can no longer be called before a fee is received.
- Remove `binding:required` from response types. It has no effect on responses, it is only needed on request types which are validated by gin.
* Calculate fee from percentage.
- Reverted config to accept a fee percentage, not absolute value.
- The fee amount to be paid is now included in the `getfeeaddress` response. The current best block is used to calculate the fee percentage, and new blocks may be mined before the fee is paid, so the fee expiry period is shortened from 24 hours to 1 hour to mitigate this.
- Rename ticket db field to FeeAmount so it is more representative of the data it holds.
- API fields renamed to "FeePercentage" and "FeeAmount"
- Relay fee is still hard coded.
* Use getbestblockhash
* Delay fee broadcast and adding tickets to wallets.
- Adds a `background` package which implements a dcrd notification handler. On each blockconnected notification, tickets with 6+ confirmations are marked confirmed, relevant fee transactions are broadcast, and any fees with 6+ confirmations have their tickets added to voting wallets.
- VSP fee is now an absolute value measured in DCR rather than a percentage. This simplifies the code and is more appropriate for an MVP. We can re-add percentage based fees later.
- Database code for tickets is now simplified to just "Insert/Update", rather than having functions for updating particular fields.
- Pay fee response no longer includes the fee tx hash, because we dont necessarily broadcast the fee tx straight away.
* Const for required confs
* Remove unnecessary error handling.
* Generate fee addresses in dcrvsp, not dcrwallet
* Break loop if multiple invalid children are generated.
* Use Mutex instead of RWMutex
* Rework client/server authentication.
- Remove Signature from all requests, and instead expect a signature in HTTP header "VSP-Client-Signature".
- Remove CommitmentSignatures from the database.
- Use a bool flag to indicate when a ticket is missing from the database rather than an error.
This commit introduces a lot of duplication into each of the authenticated HTTP handlers. This should be removed in future work which moves the authentication to a dedicated middleware.
* Introduce auth and rpc middleware.
This removed the duplication added in the previous commit, and also removes the duplication of RPC client error handling.