Browse Source

05/24/2021 03:31:47 PM MST

master
coldstar 3 years ago
parent
commit
b3512a3154
4 changed files with 79 additions and 79 deletions
  1. +1
    -1
      README.md
  2. +64
    -64
      app.js
  3. +13
    -13
      app/env.js
  4. +1
    -1
      views/connect.pug

+ 1
- 1
README.md View File

@@ -1,7 +1,7 @@

Simple, stateless Vivocoin blockchain explorer, via RPC. Built with Node.js, express, bootstrap-v4.

This tool is intended to be a simple, stateless, self-hosted explorer for the Vivocoin blockchain, driven by RPC calls to your own smartcashd node. This tool is easy to run but lacks features compared to full-fledged (stateful) explorers.
This tool is intended to be a simple, stateless, self-hosted explorer for the Vivocoin blockchain, driven by RPC calls to your own vivod node. This tool is easy to run but lacks features compared to full-fledged (stateful) explorers.

I built this tool because I wanted to use it myself. Whatever reasons one might have for running a full node (trustlessness, technical curiosity, etc) it's helpful to appreciate the "fullness" of a node.



+ 64
- 64
app.js View File

@@ -33,69 +33,69 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(session({
secret: env.cookiePassword,
resave: false,
saveUninitialized: false
secret: env.cookiePassword,
resave: false,
saveUninitialized: false
}));
app.use(express.static(path.join(__dirname, 'public')));


// Make our db accessible to our router
app.use(function(req, res, next) {
// make session available in templates
res.locals.session = req.session;
res.locals.debug = env.debug;
if (env.smartcashd && env.smartcashd.rpc) {
req.session.host = env.smartcashd.host;
req.session.port = env.smartcashd.port;
req.session.username = env.smartcashd.rpc.username;
global.client = new bitcoin.Client({
host: env.smartcashd.host,
port: env.smartcashd.port,
user: env.smartcashd.rpc.username,
pass: env.smartcashd.rpc.password,
timeout: 5000
});
}
res.locals.host = req.session.host;
res.locals.port = req.session.port;
/* if (!["/", "/connect"].includes(req.originalUrl)) {
if (utils.redirectToConnectPageIfNeeded(req, res)) {
return;
}
}
*/
if (req.session.userMessage) {
res.locals.userMessage = req.session.userMessage;
if (req.session.userMessageType) {
res.locals.userMessageType = req.session.userMessageType;
} else {
res.locals.userMessageType = "info";
}
}
req.session.userMessage = null;
req.session.userMessageType = null;
// make some var available to all request
// ex: req.cheeseStr = "cheese";
next();
// make session available in templates
res.locals.session = req.session;
res.locals.debug = env.debug;
if (env.vivod && env.vivod.rpc) {
req.session.host = env.vivod.host;
req.session.port = env.vivod.port;
req.session.username = env.vivod.rpc.username;
global.client = new bitcoin.Client({
host: env.vivod.host,
port: env.vivod.port,
user: env.vivod.rpc.username,
pass: env.vivod.rpc.password,
timeout: 5000
});
}
res.locals.host = req.session.host;
res.locals.port = req.session.port;
/* if (!["/", "/connect"].includes(req.originalUrl)) {
if (utils.redirectToConnectPageIfNeeded(req, res)) {
return;
}
}
*/
if (req.session.userMessage) {
res.locals.userMessage = req.session.userMessage;
if (req.session.userMessageType) {
res.locals.userMessageType = req.session.userMessageType;
} else {
res.locals.userMessageType = "info";
}
}
req.session.userMessage = null;
req.session.userMessageType = null;
// make some var available to all request
// ex: req.cheeseStr = "cheese";
next();
});

app.use('/', baseActionsRouter);

/// catch 404 and forwarding to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
var err = new Error('Not Found');
err.status = 404;
next(err);
});

/// error handlers
@@ -103,23 +103,23 @@ app.use(function(req, res, next) {
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});

app.locals.moment = moment;
@@ -128,4 +128,4 @@ app.locals.utils = utils;



module.exports = app;
module.exports = app;

+ 13
- 13
app/env.js View File

@@ -1,16 +1,16 @@
module.exports = {
cookiePassword: "0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
debug: false,
cookiePassword: "0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
debug: false,

// Uncomment "smartcashd" below to automatically connect via RPC.
// Otherwise, you can manually connect via the UI.
// Uncomment "vivod" below to automatically connect via RPC.
// Otherwise, you can manually connect via the UI.

smartcashd:{
host:"127.0.0.1",
port:5567,
rpc: {
username:"vivorpc",
password:"c46d58eb99da24bb0392875f"
}
}
};
vivod: {
host: "127.0.0.1",
port: 5567,
rpc: {
username: "vivorpc",
password: "c46d58eb99da24bb0392875f"
}
}
};

+ 1
- 1
views/connect.pug View File

@@ -7,7 +7,7 @@ block content
:markdown-it
This tool is intended to be a simple, stateless, self-hosted explorer for the Vivocoin blockchain, driven by RPC calls to your own vivod node. Because it is stateless, it is easy to run but lacks some (many?) of the features of other explorers.

Start by connecting to your full, archiving smartcashd node. Make sure that the node you'll be connecting to has `txindex=1` set.
Start by connecting to your full, archiving vivod node. Make sure that the node you'll be connecting to has `txindex=1` set.

form(method="post", action="/connect")
div(class="card")


Loading…
Cancel
Save