From 90727ba40abfa0f4a2877e1448f0c5b828d69533 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Sun, 23 Sep 2018 13:12:27 -0400 Subject: [PATCH] include "first seen" on address pages --- routes/baseActionsRouter.js | 19 +++++++++++++++++++ views/address.pug | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/routes/baseActionsRouter.js b/routes/baseActionsRouter.js index 07951f3..e46ca30 100644 --- a/routes/baseActionsRouter.js +++ b/routes/baseActionsRouter.js @@ -610,8 +610,16 @@ router.get("/address/:address", function(req, res) { pagedTxids.push(txids[i]); } } + + // always request the first txid; we'll use it to show "first seen" info for the address + pagedTxids.unshift(txidResult.result[0].tx_hash); coreApi.getRawTransactionsWithInputs(pagedTxids).then(function(rawTxResult) { + // first result is always the earliest tx, but doesn't fit into the current paging; + // store it as firstSeenTransaction then remove from list + res.locals.firstSeenTransaction = rawTxResult.transactions[0]; + rawTxResult.transactions.shift(); + res.locals.transactions = rawTxResult.transactions; res.locals.txInputsByTransaction = rawTxResult.txInputsByTransaction; res.locals.blockHeightsByTxid = blockHeightsByTxid; @@ -666,6 +674,17 @@ router.get("/address/:address", function(req, res) { reject(err); }); })); + + promises.push(new Promise(function(resolve, reject) { + coreApi.getBlockchainInfo().then(function(getblockchaininfo) { + res.locals.getblockchaininfo = getblockchaininfo; + + resolve(); + + }).catch(function(err) { + reject(err); + }); + })); } Promise.all(promises).catch(function(err) { diff --git a/views/address.pug b/views/address.pug index b89e06e..44fffc2 100644 --- a/views/address.pug +++ b/views/address.pug @@ -100,6 +100,25 @@ block content div(class="summary-split-table-label") Witness Program div(class="summary-split-table-content monospace") #{result.validateaddress.witness_program} + if (firstSeenTransaction) + div(class="row") + div(class="summary-split-table-label") First Seen + div(class="summary-split-table-content monospace") + if (getblockchaininfo) + span Block ##{(getblockchaininfo.blocks - firstSeenTransaction.confirmations).toLocaleString()} + else + a(href=("/block/" + firstSeenTransaction.blockhash)) #{firstSeenTransaction.blockhash} + + br + + span #{moment.utc(new Date(firstSeenTransaction.time * 1000)).format("Y-MM-DD HH:mm:ss")} utc + - var timeAgoTime = firstSeenTransaction.time; + include includes/time-ago.pug + + if (false) + pre + code #{JSON.stringify(firstSeenTransaction)} + if (balance) if (balance.conflictedResults) div(class="row")