diff --git a/webapi/formatting.go b/webapi/formatting.go index b3489c8..ae51fda 100644 --- a/webapi/formatting.go +++ b/webapi/formatting.go @@ -1,16 +1,25 @@ package webapi -import "time" +import ( + "fmt" + "time" +) func addressURL(blockExplorerURL string) func(string) string { return func(addr string) string { - return blockExplorerURL + "/address/" + addr + return fmt.Sprintf("%s/address/%s", blockExplorerURL, addr) } } func txURL(blockExplorerURL string) func(string) string { return func(txID string) string { - return blockExplorerURL + "/tx/" + txID + return fmt.Sprintf("%s/tx/%s", blockExplorerURL, txID) + } +} + +func blockURL(blockExplorerURL string) func(int64) string { + return func(height int64) string { + return fmt.Sprintf("%s/block/%d", blockExplorerURL, height) } } diff --git a/webapi/getfeeaddress.go b/webapi/getfeeaddress.go index 004ed0c..5e906e6 100644 --- a/webapi/getfeeaddress.go +++ b/webapi/getfeeaddress.go @@ -176,10 +176,18 @@ func feeAddress(c *gin.Context) { now := time.Now() expire := now.Add(feeAddressExpiration).Unix() - confirmed := rawTicket.Confirmations >= requiredConfs + // Only set purchase height if the ticket already has 6 confs, otherwise its + // purchase height may change due to reorgs. + confirmed := false + purchaseHeight := int64(0) + if rawTicket.Confirmations >= requiredConfs { + confirmed = true + purchaseHeight = rawTicket.BlockHeight + } dbTicket := database.Ticket{ Hash: ticketHash, + PurchaseHeight: purchaseHeight, CommitmentAddress: commitmentAddress, FeeAddressIndex: newAddressIdx, FeeAddress: newAddress, diff --git a/webapi/payfee.go b/webapi/payfee.go index f2fe5de..50d857b 100644 --- a/webapi/payfee.go +++ b/webapi/payfee.go @@ -214,7 +214,7 @@ findAddress: // At this point we are satisfied that the request is valid and the fee tx // pays sufficient fees to the expected address. Proceed to update the - // database, and if the ticket is confirmed broadcast the transaction. + // database, and if the ticket is confirmed broadcast the fee transaction. ticket.VotingWIF = votingWIF.String() ticket.FeeTxHex = request.FeeTx diff --git a/webapi/templates/admin.html b/webapi/templates/admin.html index d7f7191..67b681e 100644 --- a/webapi/templates/admin.html +++ b/webapi/templates/admin.html @@ -103,6 +103,17 @@ +