Add block explorer links to tx hashes and fee addr
This commit is contained in:
parent
7cb0ded1fe
commit
b5a65a9e78
@ -12,22 +12,26 @@ type netParams struct {
|
||||
*chaincfg.Params
|
||||
DcrdRPCServerPort string
|
||||
WalletRPCServerPort string
|
||||
BlockExplorerURL string
|
||||
}
|
||||
|
||||
var mainNetParams = netParams{
|
||||
Params: chaincfg.MainNetParams(),
|
||||
DcrdRPCServerPort: "9109",
|
||||
WalletRPCServerPort: "9110",
|
||||
BlockExplorerURL: "https://dcrdata.decred.org",
|
||||
}
|
||||
|
||||
var testNet3Params = netParams{
|
||||
Params: chaincfg.TestNet3Params(),
|
||||
DcrdRPCServerPort: "19109",
|
||||
WalletRPCServerPort: "19110",
|
||||
BlockExplorerURL: "https://testnet.dcrdata.org",
|
||||
}
|
||||
|
||||
var simNetParams = netParams{
|
||||
Params: chaincfg.SimNetParams(),
|
||||
DcrdRPCServerPort: "19556",
|
||||
WalletRPCServerPort: "19557",
|
||||
BlockExplorerURL: "https://dcrdata.decred.org",
|
||||
}
|
||||
|
||||
1
vspd.go
1
vspd.go
@ -87,6 +87,7 @@ func run(ctx context.Context) error {
|
||||
apiCfg := webapi.Config{
|
||||
VSPFee: cfg.VSPFee,
|
||||
NetParams: cfg.netParams.Params,
|
||||
BlockExplorerURL: cfg.netParams.BlockExplorerURL,
|
||||
SupportEmail: cfg.SupportEmail,
|
||||
VspClosed: cfg.VspClosed,
|
||||
AdminPass: cfg.AdminPass,
|
||||
|
||||
13
webapi/formatting.go
Normal file
13
webapi/formatting.go
Normal file
@ -0,0 +1,13 @@
|
||||
package webapi
|
||||
|
||||
func addressURL(blockExplorerURL string) func(string) string {
|
||||
return func(addr string) string {
|
||||
return blockExplorerURL + "/address/" + addr
|
||||
}
|
||||
}
|
||||
|
||||
func txURL(blockExplorerURL string) func(string) string {
|
||||
return func(txID string) string {
|
||||
return blockExplorerURL + "/tx/" + txID
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,11 @@
|
||||
<table class="table ticket-table mt-2 mb-4">
|
||||
<tr>
|
||||
<th>Hash</th>
|
||||
<td>{{ .Ticket.Hash }}</td>
|
||||
<td>
|
||||
<a href="{{ txURL .Ticket.Hash }}">
|
||||
{{ .Ticket.Hash }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Commitment Address</th>
|
||||
@ -109,7 +113,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fee Address</th>
|
||||
<td>{{ .Ticket.FeeAddress }}</td>
|
||||
<td>
|
||||
<a href="{{ addressURL .Ticket.FeeAddress }}">
|
||||
{{ .Ticket.FeeAddress }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fee Amount</th>
|
||||
@ -173,12 +181,16 @@
|
||||
<td>{{ .Ticket.VotingWIF }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fee Tx</th>
|
||||
<td>{{ .Ticket.FeeTxHex }}</td>
|
||||
<th>Fee Tx Hash</th>
|
||||
<td>
|
||||
<a href="{{ txURL .Ticket.FeeTxHash }}">
|
||||
{{ .Ticket.FeeTxHash }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fee Tx Hash</th>
|
||||
<td>{{ .Ticket.FeeTxHash }}</td>
|
||||
<th>Fee Tx</th>
|
||||
<td>{{ .Ticket.FeeTxHex }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Fee Tx Status</th>
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
@ -26,6 +27,7 @@ import (
|
||||
type Config struct {
|
||||
VSPFee float64
|
||||
NetParams *chaincfg.Params
|
||||
BlockExplorerURL string
|
||||
FeeAccountName string
|
||||
SupportEmail string
|
||||
VspClosed bool
|
||||
@ -173,6 +175,14 @@ func router(debugMode bool, cookieSecret []byte, dcrd rpc.DcrdConnect, wallets r
|
||||
}
|
||||
|
||||
router := gin.New()
|
||||
|
||||
// Add custom functions for use in templates.
|
||||
router.SetFuncMap(template.FuncMap{
|
||||
"txURL": txURL(cfg.BlockExplorerURL),
|
||||
"blockURL": blockURL(cfg.BlockExplorerURL),
|
||||
"addressURL": addressURL(cfg.BlockExplorerURL),
|
||||
})
|
||||
|
||||
router.LoadHTMLGlob("webapi/templates/*.html")
|
||||
|
||||
// Recovery middleware handles any go panics generated while processing web
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user