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)
|
setLogLevels(cfg.LogLevel)
|
||||||
|
|
||||||
// Set the database path
|
// Set the database path
|
||||||
cfg.dbPath = filepath.Join(dataDir, "vsp.db")
|
cfg.dbPath = filepath.Join(dataDir, "vspd.db")
|
||||||
|
|
||||||
// Validate the cold wallet xpub.
|
// Validate the cold wallet xpub.
|
||||||
if cfg.FeeXPub == "" {
|
if cfg.FeeXPub == "" {
|
||||||
|
|||||||
19
docs/api.md
19
docs/api.md
@ -109,7 +109,18 @@ has 6 confirmations.
|
|||||||
### Ticket Status
|
### Ticket Status
|
||||||
|
|
||||||
Clients can check the status of a ticket at any time after calling
|
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`
|
- `GET /ticketstatus`
|
||||||
|
|
||||||
@ -127,7 +138,11 @@ Clients can check the status of a ticket at any time after calling
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"timestamp":1590509066,
|
"timestamp":1590509066,
|
||||||
"status":"active",
|
"ticketconfirmed":true,
|
||||||
|
"feetxreceived":true,
|
||||||
|
"feetxbroadcast":true,
|
||||||
|
"feeconfirmed":false,
|
||||||
|
"feetxhash": "e1c02b04b5bbdae66cf8e3c88366c4918d458a2d27a26144df37f54a2bc956ac",
|
||||||
"votechoices":{"headercommitments":"no"},
|
"votechoices":{"headercommitments":"no"},
|
||||||
"request": {"<Copy of request body>"}
|
"request": {"<Copy of request body>"}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,7 +174,7 @@ findAddress:
|
|||||||
return
|
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{
|
sendJSONResponse(payFeeResponse{
|
||||||
|
|||||||
@ -33,7 +33,11 @@ func ticketStatus(c *gin.Context) {
|
|||||||
sendJSONResponse(ticketStatusResponse{
|
sendJSONResponse(ticketStatusResponse{
|
||||||
Timestamp: time.Now().Unix(),
|
Timestamp: time.Now().Unix(),
|
||||||
Request: ticketStatusRequest,
|
Request: ticketStatusRequest,
|
||||||
Status: "active",
|
TicketConfirmed: ticket.Confirmed,
|
||||||
|
FeeTxReceived: ticket.FeeTxHex != "",
|
||||||
|
FeeTxBroadcast: ticket.FeeTxHash != "",
|
||||||
|
FeeConfirmed: ticket.FeeConfirmed,
|
||||||
|
FeeTxHash: ticket.FeeTxHash,
|
||||||
VoteChoices: ticket.VoteChoices,
|
VoteChoices: ticket.VoteChoices,
|
||||||
}, c)
|
}, c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,11 @@ type TicketStatusRequest struct {
|
|||||||
|
|
||||||
type ticketStatusResponse struct {
|
type ticketStatusResponse struct {
|
||||||
Timestamp int64 `json:"timestamp" binding:"required"`
|
Timestamp int64 `json:"timestamp" binding:"required"`
|
||||||
Request TicketStatusRequest `json:"request" binding:"required"`
|
TicketConfirmed bool `json:"ticketconfirmed" binding:"required"`
|
||||||
Status string `json:"status" 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"`
|
VoteChoices map[string]string `json:"votechoices" binding:"required"`
|
||||||
|
Request TicketStatusRequest `json:"request" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user