Reinstate check for confirmed tickets.
This commit is contained in:
parent
fc5749545d
commit
8a4053f29f
@ -155,11 +155,21 @@ func feeAddress(c *gin.Context) {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
expire := now.Add(cfg.FeeAddressExpiration).Unix()
|
expire := now.Add(cfg.FeeAddressExpiration).Unix()
|
||||||
|
|
||||||
|
rawTx, err := dcrdClient.GetRawTransaction(ticketHash)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Could not retrieve tx %s for %s: %v", ticketHash, c.ClientIP(), err)
|
||||||
|
sendErrorResponse(err.Error(), http.StatusInternalServerError, c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmed := rawTx.Confirmations >= requiredConfs
|
||||||
|
|
||||||
dbTicket := database.Ticket{
|
dbTicket := database.Ticket{
|
||||||
Hash: ticketHash,
|
Hash: ticketHash,
|
||||||
CommitmentAddress: commitmentAddress,
|
CommitmentAddress: commitmentAddress,
|
||||||
FeeAddressIndex: newAddressIdx,
|
FeeAddressIndex: newAddressIdx,
|
||||||
FeeAddress: newAddress,
|
FeeAddress: newAddress,
|
||||||
|
Confirmed: confirmed,
|
||||||
FeeAmount: fee,
|
FeeAmount: fee,
|
||||||
FeeExpiration: expire,
|
FeeExpiration: expire,
|
||||||
// VotingKey and VoteChoices: set during payfee
|
// VotingKey and VoteChoices: set during payfee
|
||||||
@ -172,8 +182,8 @@ func feeAddress(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Fee address created for new ticket: feeAddrIdx=%d, feeAddr=%s, "+
|
log.Debugf("Fee address created for new ticket: tktConfirmed=%t, feeAddrIdx=%d, "+
|
||||||
"feeAmt=%f, ticketHash=%s", newAddressIdx, newAddress, fee, ticketHash)
|
"feeAddr=%s, feeAmt=%f, ticketHash=%s", confirmed, newAddressIdx, newAddress, fee, ticketHash)
|
||||||
|
|
||||||
sendJSONResponse(feeAddressResponse{
|
sendJSONResponse(feeAddressResponse{
|
||||||
Timestamp: now.Unix(),
|
Timestamp: now.Unix(),
|
||||||
|
|||||||
@ -30,6 +30,9 @@ type Config struct {
|
|||||||
const (
|
const (
|
||||||
// TODO: Make this configurable or get it from RPC.
|
// TODO: Make this configurable or get it from RPC.
|
||||||
relayFee = 0.0001
|
relayFee = 0.0001
|
||||||
|
// requiredConfs is the number of confirmations required to consider a
|
||||||
|
// ticket purchase or a fee transaction to be final.
|
||||||
|
requiredConfs = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfg Config
|
var cfg Config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user