From 3a931939fec1fde78ec793ffb67f19ba363ca007 Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Mon, 6 Aug 2018 12:29:11 -0400 Subject: [PATCH] fixes/improvements for new tx io details template --- views/includes/block-content.pug | 1 + views/includes/transaction-io-details.pug | 30 ++++++++++++++--------- views/transaction.pug | 1 + 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/views/includes/block-content.pug b/views/includes/block-content.pug index 0734d63..5b8aba6 100644 --- a/views/includes/block-content.pug +++ b/views/includes/block-content.pug @@ -216,6 +216,7 @@ div(class="tab-content") // code #{JSON.stringify(result.txInputsByTransaction[tx.txid], null, 4)} if (true) - var txInputs = result.txInputsByTransaction[tx.txid]; + - var blockHeight = result.getblock.height; include ./transaction-io-details.pug diff --git a/views/includes/transaction-io-details.pug b/views/includes/transaction-io-details.pug index c8ed5c8..dbcc4b4 100644 --- a/views/includes/transaction-io-details.pug +++ b/views/includes/transaction-io-details.pug @@ -2,6 +2,16 @@ - var fontawesomeOutputName = "sign-out-alt"; +- var totalInputValue = new Decimal(0); +if (tx.vin[0].coinbase) + - totalInputValue = totalInputValue.plus(new Decimal(coinConfig.blockRewardFunction(blockHeight))); +each txInput, txInputIndex in txInputs + if (txInput) + - var vout = txInput.vout[tx.vin[txInputIndex].vout]; + if (vout.value) + - totalInputValue = totalInputValue.plus(new Decimal(vout.value)); + + div(class="row") div(class="col-md-6") if (txInputs) @@ -17,7 +27,7 @@ div(class="row") span(class="tag monospace") coinbase span(class="monospace") Newly minted coins - td(class="border-top-0") + td(class="border-top-0 text-right") - var currencyValue = coinConfig.blockRewardFunction(result.getblock.height); include ./value-display.pug @@ -41,7 +51,7 @@ div(class="row") span(class="small monospace") via a(href=("/tx/" + txInput.txid + "#output-" + tx.vin[txInputIndex].vout), class="monospace") #{txInput.txid.substring(0, 20)}...[#{tx.vin[txInputIndex].vout}] - td(class=(txInputIndex == 0 ? "border-top-0" : false), class="pl-0") + td(class=(txInputIndex == 0 ? "border-top-0" : false), class="pl-0 text-right") if (vout.value) - var currencyValue = vout.value; include ./value-display.pug @@ -49,10 +59,9 @@ div(class="row") tr th td - td - strong - - var currencyValue = totalInputValue; - include ./value-display.pug + td(class="text-right font-weight-bold") + - var currencyValue = totalInputValue; + include ./value-display.pug div(class="col-md-6") @@ -82,16 +91,15 @@ div(class="row") span(class="monospace text-danger") Unable to decode output: br span(class="monospace") type=#{vout.scriptPubKey.type}, asm=#{vout.scriptPubKey.asm} - td(class=(voutIndex == 0 ? "border-top-0" : false), class="pl-0") + td(class=(voutIndex == 0 ? "border-top-0" : false), class="pl-0 text-right") - var currencyValue = vout.value; include ./value-display.pug tr th td - td - strong - - var currencyValue = totalOutputValue; - include ./value-display.pug + td(class="text-right font-weight-bold") + - var currencyValue = totalOutputValue; + include ./value-display.pug diff --git a/views/transaction.pug b/views/transaction.pug index e048248..8737f7a 100644 --- a/views/transaction.pug +++ b/views/transaction.pug @@ -216,6 +216,7 @@ block content div(class="card-body") - var tx = result.getrawtransaction; - var txInputs = result.txInputs; + - var blockHeight = result.getblock.height; include includes/transaction-io-details.pug - var fontawesomeInputName = "sign-in-alt";