44 Commits

Author SHA1 Message Date
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
jholdstock
43873ec320 Record expired/missed tickets as revoked.
This is an unfortunate workaround which is necessary because an instance of dcrwallet will only recognise a ticket as revoked if it has done the revoke itself. If another wallet broadcasts the revoke then the ticket will forever be reported as missed/expired. This causes problems for vspd when a wallet outside of the vspd deployment revokes a ticket (eg. a users ticketbuyer wallet).

I'm happy to include this slightly dirty workaround because this should no longer be an issue when the auto-revoke work in DCP-0009 lands.
2021-11-16 14:57:43 +00:00
jholdstock
ab5aa4dd6d Clarify "setaltsig" terminology.
Stardardize "alt sig"/"alt signature"/"alt signing address" terminology to "alternate signing address".
2021-11-16 14:49:13 +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
JoeGruff
b868b828f1 middleware: Allow alternate vsp auth address.
If an alternate address exists for this ticket, check it first and fall
back to the commitment address if validation fails. Alternate address
failure is allowed so that other endpoints do not need to add a field to
all requests specifying whether this is the alternate address's
signature or the commitment address's signature.
2021-10-23 11:14:11 +01:00
Jamie Holdstock
c1ba46347e
Be more specific about consensus vote choices. (#278)
* Be more specific about consensus vote choices.

Rather than referring to just "Vote choices", refer specifically to "consensus vote choices".

This will be useful when treasury and tspend vote choices are added, and the distinction becomes more important.

* dnldd suggestion.
2021-07-05 09:16:08 -05:00
Jamie Holdstock
b56dc26558 Add shutdownWg to dcrd notif handler.
This prevents db/dcrd/dcrwallet connections from being closed while the dcrd notification handler is running.
2021-06-15 10:13:31 +08:00
Jamie Holdstock
e05ced391a Various minor cleanups.
- Updating and adding some copyrights which were missed recently.
- Slight improvements to some commenting and naming.
2021-06-01 07:17:11 +08:00
Jamie Holdstock
2d0db6f6b3 Remove confirmed fee tx hex.
This PR introduces a database migration which deletes any raw fee transactions which remain in the database after already having been confirmed on-chain. There is no need to keep these, and they take up a lot of space.

There is also a change in the background handler to ensure that in future, tx hex is always removed from the database when the tx is confirmed.
2021-05-20 13:33:41 +08:00
Jamie Holdstock
79cdeaaf8b
Add parser for blockconnected notification (#238) 2021-04-25 08:22:13 -05:00
Jamie Holdstock
33703d972a
Properly call String function. (#209) 2020-11-25 14:37:25 +00:00
jholdstock
56a5aa5b1d background: Exit early if no votable tickets 2020-10-09 12:41:11 +00:00
David Hill
a67de8a024
rpc: optimize TicketInfo (#189) 2020-10-05 10:30:42 +01:00
jholdstock
288aa09c6d Stop blockConnected handler if no wallet connected 2020-10-01 12:45:15 +00:00
jholdstock
c82b08b760 Use shutdownCtx for dcrdWithNotifs 2020-09-25 15:59:12 +00:00
jholdstock
f06d4cd8ba Use background context for background processes 2020-09-25 15:59:12 +00:00
jholdstock
5c41761f1e Dont handle notifs during shutdown 2020-09-25 15:59:12 +00:00
jholdstock
d0c3abf258 Make funcNames constant.
Aside from just being a sensible thing to do, this also prevents a local stack allocation.
2020-09-17 14:21:17 +00:00
jholdstock
4a207b15f8 Add missing copyright notices 2020-08-19 20:22:12 +00:00
David Hill
de9c6b428e
background: handle fee transaction doublespends (#164) 2020-07-31 08:55:28 +01:00
jholdstock
9d503e67ae Wallet consistency checks & setting ticket outcome 2020-07-28 20:09:23 +00:00
jholdstock
c5485a28ec Return string for failed rpc connections 2020-07-09 21:01:20 +00:00
jholdstock
70ba1adc93 Combine ImportPrivKey and AddTransaction 2020-07-09 21:01:20 +00:00
jholdstock
5e8ef4e7f2 Prefix for dcrd/dcrwallet/db errors 2020-06-25 15:45:01 +00:00
jholdstock
0e953dc225 Add extra debug info to log messages 2020-06-25 15:45:01 +00:00
jholdstock
43f9f09734 Add funcName to background 2020-06-25 15:45:01 +00:00
jholdstock
5d8215e6b7 Move rpc errors to rpc package. 2020-06-22 16:23:31 +00:00
jholdstock
29268467f9 Delete tickets with no information. 2020-06-15 13:31:35 +00:00
jholdstock
78692fea88 Let background processing finish before shutting down 2020-06-12 13:23:55 +00:00
jholdstock
82dc5f5ba1 Don't log an error if context is cancelled. 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
David Hill
873d89e412
remove fee transactions if dcrd rejects it. (#114) 2020-06-08 17:31:22 +01:00
jholdstock
4d47bc6df8 Handle "transaction already exists" error 2020-06-05 16:19:46 +00:00
jholdstock
e3d7ab6e75 Run background tasks immediately on startup. 2020-06-05 16:17:43 +00:00
jholdstock
a6d9b79619 Tolerate dcrwallet connection failures.
If at least 1 wallet connection succeeds, vspd should proceed to use the connected wallet(s). Only error out if all wallet connections fail.
2020-06-04 15:56:43 +00:00
jholdstock
fc5749545d Reverse order of addtx and importprivkey 2020-06-04 15:04:39 +00:00
jholdstock
7da79c7561 Simplify dcrd and dcrwallet client creation. 2020-06-03 15:46:24 +00:00
jholdstock
86fdf888da Move to decred github org 2020-05-28 12:29:42 -05:00
Jamie Holdstock
1a507badc2
Multi wallet fix (#83)
* Fix min required check

* Remove duplicated host logging on conn errors.

* Show confirmed tickets on homepage.
2020-05-28 15:01:44 +01:00
jholdstock
225dcaf29e multi wallet support (#32)
* multiwallet

* print host

Co-authored-by: Jamie Holdstock <jholdstock@decred.org>
2020-05-28 12:52:06 +01:00
Jamie Holdstock
67dece7041
Rename to vspd. (#75) 2020-05-27 15:59:30 +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