diff --git a/config.go b/config.go index 3aef8a1..625cacf 100644 --- a/config.go +++ b/config.go @@ -329,7 +329,7 @@ func loadConfig() (*config, error) { setLogLevels(cfg.LogLevel) // Set the database path - cfg.dbPath = filepath.Join(dataDir, "vsp.db") + cfg.dbPath = filepath.Join(dataDir, "vspd.db") // Validate the cold wallet xpub. if cfg.FeeXPub == "" { diff --git a/docs/api.md b/docs/api.md index 9c5059a..1337f9d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -109,7 +109,18 @@ has 6 confirmations. ### Ticket Status Clients can check the status of a ticket at any time after calling -`/feeaddress`. +`/feeaddress`. The lifecycle of the ticket is represented with a set of boolean +fields: + +- `ticketconfirmed` is true when the ticket transaction has 6 confirmations. +- `feetxreceived` is true when the VSP has received a valid fee transaction. +- `feetxbroadcast` is true when the VSP has broadcast the fee transaction. +- `feeconfirmed` is true when the fee transaction has 6 confirmations. + +`feetxhash` will only be populated if `feetxbroadcast` is true. + +The VSP will only add tickets to the voting wallets when all four of these +conditions are met. - `GET /ticketstatus` @@ -126,10 +137,14 @@ Clients can check the status of a ticket at any time after calling ```json { - "timestamp":1590509066, - "status":"active", - "votechoices":{"headercommitments":"no"}, - "request": {""} + "timestamp":1590509066, + "ticketconfirmed":true, + "feetxreceived":true, + "feetxbroadcast":true, + "feeconfirmed":false, + "feetxhash": "e1c02b04b5bbdae66cf8e3c88366c4918d458a2d27a26144df37f54a2bc956ac", + "votechoices":{"headercommitments":"no"}, + "request": {""} } ``` diff --git a/webapi/payfee.go b/webapi/payfee.go index d5b7cf3..6435858 100644 --- a/webapi/payfee.go +++ b/webapi/payfee.go @@ -174,7 +174,7 @@ findAddress: return } - log.Debugf("Fee tx broadcast for ticket: ticketHash=%s", ticket.Hash) + log.Debugf("Fee tx broadcast for ticket: ticketHash=%s, feeHash=%s", ticket.Hash, feeTxHash) } sendJSONResponse(payFeeResponse{ diff --git a/webapi/ticketstatus.go b/webapi/ticketstatus.go index 803d0cb..66d5277 100644 --- a/webapi/ticketstatus.go +++ b/webapi/ticketstatus.go @@ -31,9 +31,13 @@ func ticketStatus(c *gin.Context) { } sendJSONResponse(ticketStatusResponse{ - Timestamp: time.Now().Unix(), - Request: ticketStatusRequest, - Status: "active", - VoteChoices: ticket.VoteChoices, + Timestamp: time.Now().Unix(), + Request: ticketStatusRequest, + TicketConfirmed: ticket.Confirmed, + FeeTxReceived: ticket.FeeTxHex != "", + FeeTxBroadcast: ticket.FeeTxHash != "", + FeeConfirmed: ticket.FeeConfirmed, + FeeTxHash: ticket.FeeTxHash, + VoteChoices: ticket.VoteChoices, }, c) } diff --git a/webapi/types.go b/webapi/types.go index 1fec776..650437f 100644 --- a/webapi/types.go +++ b/webapi/types.go @@ -51,8 +51,12 @@ type TicketStatusRequest struct { } type ticketStatusResponse struct { - Timestamp int64 `json:"timestamp" binding:"required"` - Request TicketStatusRequest `json:"request" binding:"required"` - Status string `json:"status" binding:"required"` - VoteChoices map[string]string `json:"votechoices" binding:"required"` + Timestamp int64 `json:"timestamp" binding:"required"` + TicketConfirmed bool `json:"ticketconfirmed" binding:"required"` + FeeTxReceived bool `json:"feetxreceived" binding:"required"` + FeeTxBroadcast bool `json:"feetxbroadcast" binding:"required"` + FeeConfirmed bool `json:"feeconfirmed" binding:"required"` + FeeTxHash string `json:"feetxhash" binding:"required"` + VoteChoices map[string]string `json:"votechoices" binding:"required"` + Request TicketStatusRequest `json:"request" binding:"required"` }