From 84c4bc18110cf7ab0e584b6c8be64926c95cfc7e Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Wed, 9 May 2018 13:31:46 +0200 Subject: [PATCH] Add rounding to socketio satoshi values --- server/socketio.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/socketio.go b/server/socketio.go index 80897a5b..6da0d070 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -334,7 +334,7 @@ type resTx struct { type addressHistoryItem struct { Addresses map[string]addressHistoryIndexes `json:"addresses"` - Satoshis int `json:"satoshis"` + Satoshis int64 `json:"satoshis"` Confirmations int `json:"confirmations"` Tx resTx `json:"tx"` } @@ -396,7 +396,7 @@ func (s *SocketIoServer) getAddressHistory(addr []string, opts *addrOpts) (res r for _, vout := range tx.Vout { aoh := vout.ScriptPubKey.Hex ao := txOutputs{ - Satoshis: int64(vout.Value * 1E8), + Satoshis: int64(vout.Value*1E8 + 0.5), Script: &aoh, } if vout.Address != nil { @@ -664,7 +664,7 @@ func (s *SocketIoServer) getDetailedTransaction(txid string, opts txOpts) (res r } ai.Address = &a } - ai.Satoshis = int64(vout.Value * 1E8) + ai.Satoshis = int64(vout.Value*1E8 + 0.5) } } hi = append(hi, ai) @@ -672,7 +672,7 @@ func (s *SocketIoServer) getDetailedTransaction(txid string, opts txOpts) (res r for _, vout := range tx.Vout { aos := vout.ScriptPubKey.Hex ao := txOutputs{ - Satoshis: int64(vout.Value * 1E8), + Satoshis: int64(vout.Value*1E8 + 0.5), Script: &aos, } if vout.Address != nil {