Browse Source

Tx IO displays - For fun, add the following:

- highlight coinbase spends
- highlight very old (5+ year) UTXO spends

To do this, when summarizing tx details store whether it's a coinbase spend and the time of input txs
master
Dan Janosik 5 years ago
parent
commit
e410a1fc36
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 7
      app/api/coreApi.js
  2. 14
      views/includes/transaction-io-details.pug

7
app/api/coreApi.js

@ -19,7 +19,7 @@ var rpcApi = require("./rpcApi.js");
// this value should be incremented whenever data format changes, to avoid
// pulling old-format data from a persistent cache
var cacheKeyVersion = "v0";
var cacheKeyVersion = "v1";
const ONE_SEC = 1000;
@ -581,6 +581,11 @@ function getSummarizedTransactionOutput(txid, voutIndex) {
}
vout.txid = txid;
vout.utxoTime = rawTx.time;
if (rawTx.vin.length == 1 && rawTx.vin[0].coinbase) {
vout.coinbaseSpend = true;
}
resolve(vout);

14
views/includes/transaction-io-details.pug

@ -63,6 +63,20 @@ div.row.text-monospace
div.word-wrap
small.data-tag.bg-dark.mr-2
span(title=`Input Type: ${utils.outputTypeName(vout.scriptPubKey.type)}`, data-toggle="tooltip") #{utils.outputTypeAbbreviation(vout.scriptPubKey.type)}
if (vout.coinbaseSpend)
small.data-tag.bg-success.mr-2
span(title=`This input spends a coinbase output (mining reward).`, data-toggle="tooltip") coinbase-spend
if (vout.utxoTime)
- var deltaT = tx.time - vout.utxoTime
- var deltaTYears = deltaT / 60 / 60 / 24 / 365
if (deltaTYears > 5)
span.mr-2(title=`This UTXO was very old! It existed for ${parseInt(deltaTYears)}+ years - from ${moment.utc(new Date(vout.utxoTime * 1000)).format('MMM D, Y')} until ${moment.utc(new Date(tx.time * 1000)).format('MMM D, Y')} - before being spent (destroyed) in this transaction!`, data-toggle="tooltip")
i.fas.fa-certificate.text-primary
a(href=("/tx/" + txInput.txid + "#output-" + txVin.vout)) #{utils.ellipsize(txInput.txid, 26)}
span ##{txVin.vout}

Loading…
Cancel
Save