58 Commits

Author SHA1 Message Date
Jamie Holdstock
e65a7fdbf3
Set values early to prevent races (#77) 2020-05-28 06:58:44 +01:00
Jamie Holdstock
6b6bc20522
Periodically write a database backup. (#76) 2020-05-28 06:58:34 +01:00
Jamie Holdstock
d275fddf1b
Remove votechoices from setVoteChoices response. (#81) 2020-05-28 06:58:26 +01:00
Jamie Holdstock
67dece7041
Rename to vspd. (#75) 2020-05-27 15:59:30 +01:00
Jamie Holdstock
d5c949b9ad
Split docs into seperate files (#72) 2020-05-27 15:36:21 +01:00
Jamie Holdstock
d5eb18f557
Add support email and pubkey to GUI (#74)
* Add support email to gui.

* Use Decred fonts

* Use Decred favicon

* Add pubkey to homepage. Use properly typed struct for template data.

* go mod tidy
2020-05-27 15:36:11 +01:00
Jamie Holdstock
d0dedd3af0
Resolving some TODOs (#71)
* Dont allow duplicate fee addresses

* Load webapi keypair in webapi package.

* Split database test file

* Add extra DB testing.
2020-05-27 14:55:59 +01:00
Jamie Holdstock
e1a18804ac
Check dcrwallet and dcrd config (#70)
* Verify dcrd network and txindex

* Verify dcrwallet network
2020-05-27 14:45:06 +01:00
Jamie Holdstock
ccafd8dec4
Calculate fee from percentage. (#69)
* 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
2020-05-27 14:44:40 +01:00
Jamie Holdstock
87500c3fef
Delay fee broadcast and adding tickets to wallets. (#62)
* 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
2020-05-27 06:39:38 +01:00
Jamie Holdstock
86c4195931
Replace local fee wallet with dcrd. (#61) 2020-05-26 17:30:51 +01:00
Jamie Holdstock
9151f4f221
Generate fee addresses in dcrvsp, not dcrwallet (#59)
* Remove unnecessary error handling.

* Generate fee addresses in dcrvsp, not dcrwallet

* Break loop if multiple invalid children are generated.

* Use Mutex instead of RWMutex
2020-05-26 14:51:05 +01:00
Jamie Holdstock
ac488464c0
Rework client/server authentication. (#58)
* 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.
2020-05-26 14:14:38 +01:00
Jamie Holdstock
1ff55f4b30
Add some stats to homepage (#51) 2020-05-22 18:43:41 +01:00
Jamie Holdstock
96608718a0
Cleaning up some TODOs (#50) 2020-05-22 18:42:51 +01:00
Jamie Holdstock
740b9c8e0f
Get relay fee from wallet (#47) 2020-05-22 15:09:51 +01:00
Jamie Holdstock
68e3fca59c
Add context to RPC wrapper (#53) 2020-05-22 14:58:28 +01:00
Jamie Holdstock
869b68fad5
Split voting wallet and fee wallet clients (#45) 2020-05-22 07:54:09 +01:00
David Hill
033ac95c33
rpc: verify wallet version (#42) 2020-05-21 08:21:50 +01:00
Jamie Holdstock
bb416e8bc9
Set vote choices on voting wallets (#43) 2020-05-21 07:59:51 +01:00
Jamie Holdstock
bd518d7e24
Split methods.go (#39) 2020-05-20 15:37:01 +01:00
Jamie Holdstock
72fc9afa40
Config for web server release/debug mode (#40) 2020-05-20 15:31:10 +01:00
Jamie Holdstock
36c748ba12
Import xpub tweaks (#41) 2020-05-20 15:18:24 +01:00
David Hill
67c8e8f27c
Importxpub (#27) 2020-05-20 11:02:40 +01:00
Jamie Holdstock
00525f4d53
Validate votebits in payfee (#37) 2020-05-20 08:09:18 +01:00
Jamie Holdstock
cf55092c21
Add ticket hash to payfee request. (#38) 2020-05-20 08:09:07 +01:00
Jamie Holdstock
d31c24b531
Add missing tests and log errors. (#36) 2020-05-19 17:21:40 +01:00
David Hill
f50b0aba56
cleanup payfee (#35) 2020-05-19 16:53:11 +01:00
David Hill
80e7983d4e
add in expiration logic (#31) 2020-05-19 16:13:48 +01:00
Jamie Holdstock
702aef3ce6
Log when a new config file is created (#33) 2020-05-19 14:24:59 +01:00
David Hill
fff8132b13
Store signing key in db. (#34) 2020-05-19 14:24:02 +01:00
Jamie Holdstock
5c1c19844c
Error logging for API methods (#28) 2020-05-19 10:55:25 +01:00
David Hill
302abce2fc
database: rename GetFeesByFeeAddress to GetTicketByFeeAddress (#30) 2020-05-19 10:54:06 +01:00
David Hill
c9fca9bb0e
Get votebits from DB (#29) 2020-05-19 10:51:18 +01:00
Jamie Holdstock
e70bb206c3
Generalize database accessor. (#24) 2020-05-18 15:20:29 +01:00
Jamie Holdstock
04311000e8
Move web assets under webapi package. (#26) 2020-05-18 15:20:13 +01:00
Jamie Holdstock
7dbee5b6c2
Add dcrwallet RPC client (#25) 2020-05-18 15:19:35 +01:00
Jamie Holdstock
6ca2f620b7
Use a waitgroup to wait for shutdown tasks (#21) 2020-05-18 09:05:10 +01:00
David Hill
1092df5224
use dcrutil.VerifyMessage versus RPC (#22) 2020-05-18 08:42:35 +01:00
Jamie Holdstock
8768014348
Add shutdown context. (#20) 2020-05-17 07:49:53 +01:00
David Hill
70ed281215
start hooking up database (#17) 2020-05-15 16:33:55 +01:00
David Hill
72ba2ce3b1
add setvotebits api (#18) 2020-05-15 16:33:20 +01:00
Jamie Holdstock
7c5ab7ebae
Add basic HTML page and project license (#15) 2020-05-15 16:07:26 +01:00
David Hill
d8b6517dbd
ticketstatus api (#13) 2020-05-15 15:45:24 +01:00
David Hill
6b6655cfed
Additional sanity (#10)
* Add expiration field

VSPs may wish to change their poolFees.  We must honor the poolfee
given in the feeaddress request, but only for a certain amount of time.

* VSP must also sign voteBits as a guarantee

* add timestamps and full requests to the responses
2020-05-15 08:49:34 +01:00
David Hill
c371f1983b
add helper functions (#9) 2020-05-15 08:48:22 +01:00
Jamie Holdstock
57dfc1ed6d
Add decred logging and config (#8) 2020-05-14 19:02:45 +01:00
David Hill
48f7a584ac
Expect JSON for requests (#7) 2020-05-14 18:52:21 +01:00
Jamie Holdstock
d0236e5c04
Implement ticket storage and retrieval (#5) 2020-05-14 14:04:14 +01:00
jholdstock
5da8d9238b Temporarily disable linter 2020-05-14 14:00:18 +01:00