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
|
*chaincfg.Params
|
||||||
DcrdRPCServerPort string
|
DcrdRPCServerPort string
|
||||||
WalletRPCServerPort string
|
WalletRPCServerPort string
|
||||||
|
BlockExplorerURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainNetParams = netParams{
|
var mainNetParams = netParams{
|
||||||
Params: chaincfg.MainNetParams(),
|
Params: chaincfg.MainNetParams(),
|
||||||
DcrdRPCServerPort: "9109",
|
DcrdRPCServerPort: "9109",
|
||||||
WalletRPCServerPort: "9110",
|
WalletRPCServerPort: "9110",
|
||||||
|
BlockExplorerURL: "https://dcrdata.decred.org",
|
||||||
}
|
}
|
||||||
|
|
||||||
var testNet3Params = netParams{
|
var testNet3Params = netParams{
|
||||||
Params: chaincfg.TestNet3Params(),
|
Params: chaincfg.TestNet3Params(),
|
||||||
DcrdRPCServerPort: "19109",
|
DcrdRPCServerPort: "19109",
|
||||||
WalletRPCServerPort: "19110",
|
WalletRPCServerPort: "19110",
|
||||||
|
BlockExplorerURL: "https://testnet.dcrdata.org",
|
||||||
}
|
}
|
||||||
|
|
||||||
var simNetParams = netParams{
|
var simNetParams = netParams{
|
||||||
Params: chaincfg.SimNetParams(),
|
Params: chaincfg.SimNetParams(),
|
||||||
DcrdRPCServerPort: "19556",
|
DcrdRPCServerPort: "19556",
|
||||||
WalletRPCServerPort: "19557",
|
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{
|
apiCfg := webapi.Config{
|
||||||
VSPFee: cfg.VSPFee,
|
VSPFee: cfg.VSPFee,
|
||||||
NetParams: cfg.netParams.Params,
|
NetParams: cfg.netParams.Params,
|
||||||
|
BlockExplorerURL: cfg.netParams.BlockExplorerURL,
|
||||||
SupportEmail: cfg.SupportEmail,
|
SupportEmail: cfg.SupportEmail,
|
||||||
VspClosed: cfg.VspClosed,
|
VspClosed: cfg.VspClosed,
|
||||||
AdminPass: cfg.AdminPass,
|
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">
|
<table class="table ticket-table mt-2 mb-4">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Hash</th>
|
<th>Hash</th>
|
||||||
<td>{{ .Ticket.Hash }}</td>
|
<td>
|
||||||
|
<a href="{{ txURL .Ticket.Hash }}">
|
||||||
|
{{ .Ticket.Hash }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Commitment Address</th>
|
<th>Commitment Address</th>
|
||||||
@ -109,7 +113,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Fee Address</th>
|
<th>Fee Address</th>
|
||||||
<td>{{ .Ticket.FeeAddress }}</td>
|
<td>
|
||||||
|
<a href="{{ addressURL .Ticket.FeeAddress }}">
|
||||||
|
{{ .Ticket.FeeAddress }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Fee Amount</th>
|
<th>Fee Amount</th>
|
||||||
@ -173,12 +181,16 @@
|
|||||||
<td>{{ .Ticket.VotingWIF }}</td>
|
<td>{{ .Ticket.VotingWIF }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Fee Tx</th>
|
<th>Fee Tx Hash</th>
|
||||||
<td>{{ .Ticket.FeeTxHex }}</td>
|
<td>
|
||||||
|
<a href="{{ txURL .Ticket.FeeTxHash }}">
|
||||||
|
{{ .Ticket.FeeTxHash }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Fee Tx Hash</th>
|
<th>Fee Tx</th>
|
||||||
<td>{{ .Ticket.FeeTxHash }}</td>
|
<td>{{ .Ticket.FeeTxHex }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Fee Tx Status</th>
|
<th>Fee Tx Status</th>
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
@ -26,6 +27,7 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
VSPFee float64
|
VSPFee float64
|
||||||
NetParams *chaincfg.Params
|
NetParams *chaincfg.Params
|
||||||
|
BlockExplorerURL string
|
||||||
FeeAccountName string
|
FeeAccountName string
|
||||||
SupportEmail string
|
SupportEmail string
|
||||||
VspClosed bool
|
VspClosed bool
|
||||||
@ -173,6 +175,14 @@ func router(debugMode bool, cookieSecret []byte, dcrd rpc.DcrdConnect, wallets r
|
|||||||
}
|
}
|
||||||
|
|
||||||
router := gin.New()
|
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")
|
router.LoadHTMLGlob("webapi/templates/*.html")
|
||||||
|
|
||||||
// Recovery middleware handles any go panics generated while processing web
|
// Recovery middleware handles any go panics generated while processing web
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user