Skip to content

Commit

Permalink
webapi: Distinguish between current/old xpub
Browse files Browse the repository at this point in the history
Showing current and old pubkeys under separate headers makes the
information easier to parse, and also fixes a bug where the current
pubkey was showing a retired timestamp of unix epoch.
  • Loading branch information
jholdstock committed Nov 1, 2024
1 parent ae28df0 commit 8ab6287
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
17 changes: 14 additions & 3 deletions internal/webapi/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,32 @@ func (w *WebAPI) renderAdmin(c *gin.Context, searchResult *searchResult) {

missed.SortByPurchaseHeight()

xpubs, err := w.db.AllXPubs()
currentXPub, err := w.db.FeeXPub()
if err != nil {
w.log.Errorf("db.FeeXPub error: %v", err)
c.String(http.StatusInternalServerError, "Error getting current xpub from db")
return
}

oldXPubs, err := w.db.AllXPubs()
if err != nil {
w.log.Errorf("db.AllXPubs error: %v", err)
c.String(http.StatusInternalServerError, "Error getting xpubs from db")
c.String(http.StatusInternalServerError, "Error getting all xpubs from db")
return
}

// Remove current xpub from the list of old xpubs.
delete(oldXPubs, currentXPub.ID)

c.HTML(http.StatusOK, "admin.html", gin.H{
"SearchResult": searchResult,
"WebApiCache": cacheData,
"WebApiCfg": w.cfg,
"WalletStatus": w.walletStatus(c),
"DcrdStatus": w.dcrdStatus(c),
"MissedTickets": missed,
"XPubs": xpubs,
"CurrentXPub": currentXPub,
"OldXPubs": oldXPubs,
})
}

Expand Down
24 changes: 21 additions & 3 deletions internal/webapi/templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,26 @@ <h1>{{ pluralize (len .MissedTickets) "Missed Ticket" }}</h1>
<div class="collapsible-tab-content">

<div class="p-2">
<h1>All X Pubs</h1>
{{ with .XPubs }}
<h1>Current X Pub</h1>
<table class="mx-auto">
<thead>
<th>ID</th>
<th>Key</th>
<th>Last Address Index</th>
</thead>
<tbody>
<tr>
<td>{{ .CurrentXPub.ID }}</td>
<td>{{ .CurrentXPub.Key }}</td>
<td>{{ .CurrentXPub.LastUsedIdx }}</td>
</tr>
</tbody>
</table>
</div>

{{ with .OldXPubs }}
<div class="p-2">
<h1>Old X Pubs</h1>
<table class="mx-auto">
<thead>
<th>ID</th>
Expand All @@ -271,8 +289,8 @@ <h1>All X Pubs</h1>
{{ end }}
</tbody>
</table>
{{ end}}
</div>
{{ end }}

</div>
</section>
Expand Down

0 comments on commit 8ab6287

Please sign in to comment.