Show altsignaddress req/res in admin UI
This commit is contained in:
parent
0fd96388ce
commit
0b78c9c2da
@ -26,13 +26,13 @@ type AltSignAddrData struct {
|
|||||||
// AltSignAddr is the new alternate signing address. It is base 58 encoded.
|
// AltSignAddr is the new alternate signing address. It is base 58 encoded.
|
||||||
AltSignAddr string
|
AltSignAddr string
|
||||||
// Req is the original request to set an alternate signing address.
|
// Req is the original request to set an alternate signing address.
|
||||||
Req []byte
|
Req string
|
||||||
// ReqSig is the request's signature signed by the commitment address of the
|
// ReqSig is the request's signature signed by the commitment address of the
|
||||||
// corresponding ticket. It is base 64 encoded.
|
// corresponding ticket. It is base 64 encoded.
|
||||||
ReqSig string
|
ReqSig string
|
||||||
// Resp is the original response from the server to the alternate signing
|
// Resp is the original response from the server to the alternate signing
|
||||||
// address.
|
// address.
|
||||||
Resp []byte
|
Resp string
|
||||||
// RespSig is the response's signature signed by the server. It is base 64
|
// RespSig is the response's signature signed by the server. It is base 64
|
||||||
// encoded.
|
// encoded.
|
||||||
RespSig string
|
RespSig string
|
||||||
@ -66,7 +66,7 @@ func (vdb *VspDatabase) InsertAltSignAddr(ticketHash string, data *AltSignAddrDa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bkt.Put(reqK, data.Req); err != nil {
|
if err := bkt.Put(reqK, []byte(data.Req)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ func (vdb *VspDatabase) InsertAltSignAddr(ticketHash string, data *AltSignAddrDa
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bkt.Put(respK, data.Resp); err != nil {
|
if err := bkt.Put(respK, []byte(data.Resp)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return bkt.Put(respSigK, []byte(data.RespSig))
|
return bkt.Put(respSigK, []byte(data.RespSig))
|
||||||
@ -113,9 +113,9 @@ func (vdb *VspDatabase) AltSignAddrData(ticketHash string) (*AltSignAddrData, er
|
|||||||
}
|
}
|
||||||
h = &AltSignAddrData{
|
h = &AltSignAddrData{
|
||||||
AltSignAddr: string(bkt.Get(altSignAddrK)),
|
AltSignAddr: string(bkt.Get(altSignAddrK)),
|
||||||
Req: bkt.Get(reqK),
|
Req: string(bkt.Get(reqK)),
|
||||||
ReqSig: string(bkt.Get(reqSigK)),
|
ReqSig: string(bkt.Get(reqSigK)),
|
||||||
Resp: bkt.Get(respK),
|
Resp: string(bkt.Get(respK)),
|
||||||
RespSig: string(bkt.Get(respSigK)),
|
RespSig: string(bkt.Get(respSigK)),
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -12,9 +12,9 @@ import (
|
|||||||
func exampleAltSignAddrData() *AltSignAddrData {
|
func exampleAltSignAddrData() *AltSignAddrData {
|
||||||
return &AltSignAddrData{
|
return &AltSignAddrData{
|
||||||
AltSignAddr: randString(35, addrCharset),
|
AltSignAddr: randString(35, addrCharset),
|
||||||
Req: randBytes(1000),
|
Req: string(randBytes(1000)),
|
||||||
ReqSig: randString(96, sigCharset),
|
ReqSig: randString(96, sigCharset),
|
||||||
Resp: randBytes(1000),
|
Resp: string(randBytes(1000)),
|
||||||
RespSig: randString(96, sigCharset),
|
RespSig: randString(96, sigCharset),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,12 +38,12 @@ type DcrdStatus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type searchResult struct {
|
type searchResult struct {
|
||||||
Hash string
|
Hash string
|
||||||
Found bool
|
Found bool
|
||||||
Ticket database.Ticket
|
Ticket database.Ticket
|
||||||
AltSignAddr string
|
AltSignAddrData *database.AltSignAddrData
|
||||||
VoteChanges map[uint32]database.VoteChangeRecord
|
VoteChanges map[uint32]database.VoteChangeRecord
|
||||||
MaxVoteChanges int
|
MaxVoteChanges int
|
||||||
}
|
}
|
||||||
|
|
||||||
func dcrdStatus(c *gin.Context) DcrdStatus {
|
func dcrdStatus(c *gin.Context) DcrdStatus {
|
||||||
@ -176,19 +176,14 @@ func ticketSearch(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
altSignAddr := ""
|
|
||||||
if altSignAddrData != nil {
|
|
||||||
altSignAddr = altSignAddrData.AltSignAddr
|
|
||||||
}
|
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "admin.html", gin.H{
|
c.HTML(http.StatusOK, "admin.html", gin.H{
|
||||||
"SearchResult": searchResult{
|
"SearchResult": searchResult{
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Found: found,
|
Found: found,
|
||||||
Ticket: ticket,
|
Ticket: ticket,
|
||||||
AltSignAddr: altSignAddr,
|
AltSignAddrData: altSignAddrData,
|
||||||
VoteChanges: voteChanges,
|
VoteChanges: voteChanges,
|
||||||
MaxVoteChanges: cfg.MaxVoteChangeRecords,
|
MaxVoteChanges: cfg.MaxVoteChangeRecords,
|
||||||
},
|
},
|
||||||
"WebApiCache": getCache(),
|
"WebApiCache": getCache(),
|
||||||
"WebApiCfg": cfg,
|
"WebApiCfg": cfg,
|
||||||
|
|||||||
@ -111,9 +111,9 @@ func setAltSignAddr(c *gin.Context) {
|
|||||||
|
|
||||||
data := &database.AltSignAddrData{
|
data := &database.AltSignAddrData{
|
||||||
AltSignAddr: altSignAddr,
|
AltSignAddr: altSignAddr,
|
||||||
Req: reqBytes,
|
Req: string(reqBytes),
|
||||||
ReqSig: c.GetHeader("VSP-Client-Signature"),
|
ReqSig: c.GetHeader("VSP-Client-Signature"),
|
||||||
Resp: []byte(resp),
|
Resp: resp,
|
||||||
RespSig: respSig,
|
RespSig: respSig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ var (
|
|||||||
maxVoteChangeRecords = 3
|
maxVoteChangeRecords = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// randBytes returns a byte slice of size n filled with random bytes.
|
||||||
func randBytes(n int) []byte {
|
func randBytes(n int) []byte {
|
||||||
slice := make([]byte, n)
|
slice := make([]byte, n)
|
||||||
if _, err := seededRand.Read(slice); err != nil {
|
if _, err := seededRand.Read(slice); err != nil {
|
||||||
@ -196,9 +197,9 @@ func TestSetAltSignAddress(t *testing.T) {
|
|||||||
if test.isExistingAltSignAddr {
|
if test.isExistingAltSignAddr {
|
||||||
data := &database.AltSignAddrData{
|
data := &database.AltSignAddrData{
|
||||||
AltSignAddr: test.addr,
|
AltSignAddr: test.addr,
|
||||||
Req: b,
|
Req: string(b),
|
||||||
ReqSig: reqSig,
|
ReqSig: reqSig,
|
||||||
Resp: randBytes(1000),
|
Resp: string(randBytes(1000)),
|
||||||
RespSig: randString(96, sigCharset),
|
RespSig: randString(96, sigCharset),
|
||||||
}
|
}
|
||||||
if err := db.InsertAltSignAddr(ticketHash, data); err != nil {
|
if err := db.InsertAltSignAddr(ticketHash, data); err != nil {
|
||||||
@ -256,7 +257,7 @@ func TestSetAltSignAddress(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(b, altsig.Req) || altsig.ReqSig != reqSig {
|
if !bytes.Equal(b, []byte(altsig.Req)) || altsig.ReqSig != reqSig {
|
||||||
t.Fatalf("%q: expected alt sign addr data different than actual", test.name)
|
t.Fatalf("%q: expected alt sign addr data different than actual", test.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,14 +40,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<th>Alternate Signing Address</th>
|
|
||||||
<td>
|
|
||||||
<a href="{{ addressURL .AltSignAddr }}">
|
|
||||||
{{ .AltSignAddr }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h1>Fee</h1>
|
<h1>Fee</h1>
|
||||||
@ -141,6 +133,50 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h1>Alternate Signing Address</h1>
|
||||||
|
|
||||||
|
<table id="ticket-table" class="mt-2 mb-4 w-100">
|
||||||
|
<tr>
|
||||||
|
<th>Alternate Signing Address</th>
|
||||||
|
<td>
|
||||||
|
{{if .AltSignAddrData}}
|
||||||
|
<a href="{{ addressURL .AltSignAddrData.AltSignAddr }}">
|
||||||
|
{{ .AltSignAddrData.AltSignAddr }}
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
AltSignAddress Change
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
{{if .AltSignAddrData}}
|
||||||
|
<details>
|
||||||
|
<table class="my-2">
|
||||||
|
<tr>
|
||||||
|
<th>Request</th>
|
||||||
|
<td>{{ indentJSON .AltSignAddrData.Req }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Request<br />Signature</th>
|
||||||
|
<td>{{ .AltSignAddrData.ReqSig }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Response</th>
|
||||||
|
<td>{{ indentJSON .AltSignAddrData.Resp }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Response<br />Signature</th>
|
||||||
|
<td>{{ .AltSignAddrData.RespSig }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<p>No ticket found with hash <span class="code">{{ .Hash }}</span></p>
|
<p>No ticket found with hash <span class="code">{{ .Hash }}</span></p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user