20 Commits

Author SHA1 Message Date
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
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
9d503e67ae Wallet consistency checks & setting ticket outcome 2020-07-28 20:09:23 +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
jholdstock
a9d70abb93 Handle fee tx already exists in mempool. 2020-06-15 13:43:07 +00:00
jholdstock
3a76d44113 Extra ticket hash validation before using db/rpc.
Provides extra protection against DoS.
2020-06-15 13:32:51 +00:00
jholdstock
72c16ad2c7 Close RPC connections after the web server is stopped.
Previously all of the shutdown tasks were running concurrently, which meant the RPC connections be closed before the webserver is finished using them.
2020-06-12 13:23:55 +00:00
jholdstock
4f2766352b Improve handling of fee status.
- 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.
2020-06-09 14:17:43 +00:00
jholdstock
4d47bc6df8 Handle "transaction already exists" error 2020-06-05 16:19:46 +00:00
jholdstock
1c92856303 Ensure provided private key matches ticket 2020-06-05 15:33:56 +00:00
jholdstock
7da79c7561 Simplify dcrd and dcrwallet client creation. 2020-06-03 15:46:24 +00:00
jholdstock
4feed5e884 Fix off-by-one 2020-06-03 12:49:14 +00:00
jholdstock
81a6bf1ea8 Reject unvotable tickets.
/payfee and /getaddress will now only accept tickets which are immature or live.
2020-06-03 12:49:14 +00: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