Populate ticket status response. (#82)
This commit is contained in:
parent
1a507badc2
commit
4b2a68ea48
@ -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 == "" {
|
||||
|
||||
25
docs/api.md
25
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": {"<Copy of request body>"}
|
||||
"timestamp":1590509066,
|
||||
"ticketconfirmed":true,
|
||||
"feetxreceived":true,
|
||||
"feetxbroadcast":true,
|
||||
"feeconfirmed":false,
|
||||
"feetxhash": "e1c02b04b5bbdae66cf8e3c88366c4918d458a2d27a26144df37f54a2bc956ac",
|
||||
"votechoices":{"headercommitments":"no"},
|
||||
"request": {"<Copy of request body>"}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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"`
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user