From 20643756e5c3bc447d5ec96ff58b1177aacc2a71 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Thu, 28 Jun 2018 22:41:46 +0200 Subject: [PATCH] Fix formatting of amounts in explorer --- api/worker.go | 2 +- server/public.go | 2 +- static/templates/txdetail.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/worker.go b/api/worker.go index 14ef57cb..0dc9c983 100644 --- a/api/worker.go +++ b/api/worker.go @@ -97,7 +97,7 @@ func (w *Worker) GetTransaction(txid string, bestheight uint32, spendingTx bool) Locktime: bchainTx.LockTime, WithSpends: spendingTx, Time: bchainTx.Time, - Txid: txid, + Txid: bchainTx.Txid, ValueIn: valIn, ValueOut: valOut, Version: bchainTx.Version, diff --git a/server/public.go b/server/public.go index b517e5fc..5476e8f2 100644 --- a/server/public.go +++ b/server/public.go @@ -108,7 +108,7 @@ func formatUnixTime(ut int64) string { } func formatAmount(a float64) string { - return fmt.Sprintf("%0.8f", a) + return strings.TrimRight(strings.TrimRight(fmt.Sprintf("%0.8f", a), "0"), ".") } // Run starts the server diff --git a/static/templates/txdetail.html b/static/templates/txdetail.html index 3439f919..ee663332 100644 --- a/static/templates/txdetail.html +++ b/static/templates/txdetail.html @@ -22,7 +22,7 @@ {{$vin.Addr}} {{else}}Unparsed address{{end}} - {{$vin.Value}} {{$cs}} + {{formatAmount $vin.Value}} {{$cs}} {{else}}No Inputs (Newly Generated Coins){{end}} @@ -50,7 +50,7 @@ {{else}} Unparsed address {{end}} - {{$vout.Value}} {{$cs}} + {{formatAmount $vout.Value}} {{$cs}} {{end}}