Skip to content

Commit 8ab6287

Browse files
committed
webapi: Distinguish between current/old xpub
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.
1 parent ae28df0 commit 8ab6287

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

internal/webapi/admin.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,32 @@ func (w *WebAPI) renderAdmin(c *gin.Context, searchResult *searchResult) {
160160

161161
missed.SortByPurchaseHeight()
162162

163-
xpubs, err := w.db.AllXPubs()
163+
currentXPub, err := w.db.FeeXPub()
164+
if err != nil {
165+
w.log.Errorf("db.FeeXPub error: %v", err)
166+
c.String(http.StatusInternalServerError, "Error getting current xpub from db")
167+
return
168+
}
169+
170+
oldXPubs, err := w.db.AllXPubs()
164171
if err != nil {
165172
w.log.Errorf("db.AllXPubs error: %v", err)
166-
c.String(http.StatusInternalServerError, "Error getting xpubs from db")
173+
c.String(http.StatusInternalServerError, "Error getting all xpubs from db")
167174
return
168175
}
169176

177+
// Remove current xpub from the list of old xpubs.
178+
delete(oldXPubs, currentXPub.ID)
179+
170180
c.HTML(http.StatusOK, "admin.html", gin.H{
171181
"SearchResult": searchResult,
172182
"WebApiCache": cacheData,
173183
"WebApiCfg": w.cfg,
174184
"WalletStatus": w.walletStatus(c),
175185
"DcrdStatus": w.dcrdStatus(c),
176186
"MissedTickets": missed,
177-
"XPubs": xpubs,
187+
"CurrentXPub": currentXPub,
188+
"OldXPubs": oldXPubs,
178189
})
179190
}
180191

internal/webapi/templates/admin.html

+21-3
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,26 @@ <h1>{{ pluralize (len .MissedTickets) "Missed Ticket" }}</h1>
251251
<div class="collapsible-tab-content">
252252

253253
<div class="p-2">
254-
<h1>All X Pubs</h1>
255-
{{ with .XPubs }}
254+
<h1>Current X Pub</h1>
255+
<table class="mx-auto">
256+
<thead>
257+
<th>ID</th>
258+
<th>Key</th>
259+
<th>Last Address Index</th>
260+
</thead>
261+
<tbody>
262+
<tr>
263+
<td>{{ .CurrentXPub.ID }}</td>
264+
<td>{{ .CurrentXPub.Key }}</td>
265+
<td>{{ .CurrentXPub.LastUsedIdx }}</td>
266+
</tr>
267+
</tbody>
268+
</table>
269+
</div>
270+
271+
{{ with .OldXPubs }}
272+
<div class="p-2">
273+
<h1>Old X Pubs</h1>
256274
<table class="mx-auto">
257275
<thead>
258276
<th>ID</th>
@@ -271,8 +289,8 @@ <h1>All X Pubs</h1>
271289
{{ end }}
272290
</tbody>
273291
</table>
274-
{{ end}}
275292
</div>
293+
{{ end }}
276294

277295
</div>
278296
</section>

0 commit comments

Comments
 (0)