Skip to content

Commit

Permalink
Provide a more useful message when txindex is off
Browse files Browse the repository at this point in the history
Also changed session.userMessage to render as markdown,
hopefully that's okay?
  • Loading branch information
shesek committed Feb 14, 2021
1 parent f02f98e commit 0cef27a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion routes/baseRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const v8 = require('v8');

const forceCsrf = csurf({ ignoreMethods: [] });

var noTxIndexMsg = "\n\nYour node does not have `txindex` enabled. Without it, you can only lookup wallet, mempool and recently confirmed transactions by their `txid`. Searching for non-wallet transactions that were confirmed more than "+config.noTxIndexSearchDepth+" blocks ago is only possible if you provide the confirmed block height in addition to the txid, using `<txid>@<height>` in the search box.";

router.get("/", function(req, res, next) {
if (req.session.host == null || req.session.host.trim() == "") {
if (req.cookies['rpc-host']) {
Expand Down Expand Up @@ -543,7 +545,8 @@ router.post("/search", function(req, res, next) {
res.redirect("./block/" + query);
}).catch(function(err) {
req.session.userMessage = "No results found for query: " + query;

if (global.getindexinfo && !global.getindexinfo.txindex)
req.session.userMessage += noTxIndexMsg;
res.redirect("./");
});
});
Expand Down Expand Up @@ -854,6 +857,9 @@ router.get("/tx/:transactionId", function(req, res, next) {
}).catch(function(err) {
res.locals.userMessageMarkdown = `Failed to load transaction: txid=**${txid}**`;

if (global.getindexinfo && !global.getindexinfo.txindex)
res.locals.userMessageMarkdown += noTxIndexMsg;

res.locals.pageErrors.push(utils.logError("1237y4ewssgt", err));

res.render("transaction");
Expand Down
2 changes: 1 addition & 1 deletion views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ html(lang="en")

if (userMessage)
div.alert(class=(userMessageType ? `alert-${userMessageType}` : "alert-warning"), role="alert")
span #{userMessage}
| !{markdown(userMessage)}


div(style="min-height: 500px;")
Expand Down

0 comments on commit 0cef27a

Please sign in to comment.