diff --git a/lib/database.js b/lib/database.js index 1e8a3c939..c23e3c7ac 100644 --- a/lib/database.js +++ b/lib/database.js @@ -40,7 +40,7 @@ function update_address(hash, txid, amount, type, cb) { if ( hash == 'coinbase' ) { Address.update({a_id:hash}, { sent: address.sent + amount, - balance: 0, + balance: 0, }, function() { return cb(); }); @@ -64,26 +64,23 @@ function update_address(hash, txid, amount, type, cb) { txs: tx_array, received: received, sent: sent, - balance: received - sent, + balance: received - sent }, function() { return cb(); }); } else { - /* if (tx_array[index].type == type || tx_array[index].type == 'pos') { - return cb(); - } else { - //pos - tx_array[index].type = 'pos'; + if (type == tx_array[index].type) { + return cb(); //duplicate + } else { Address.update({a_id:hash}, { txs: tx_array, received: received, sent: sent, - balance: received - sent, + balance: received - sent }, function() { return cb(); }); - }*/ - return cb(); + } } }); } diff --git a/views/includes/address_history.jade b/views/includes/address_history.jade index 5c087e3ac..b0d5b90f8 100644 --- a/views/includes/address_history.jade +++ b/views/includes/address_history.jade @@ -3,7 +3,6 @@ thead th.hidden-xs #{settings.locale.timestamp} th.hidden-xs #{settings.locale.tx_hash} th #{settings.locale.mkt_amount} (#{settings.symbol}) - th tbody each tx in txs - var time = format_unixtime(tx.timestamp) @@ -12,19 +11,29 @@ tbody td.hidden-xs a(href='/tx/#{tx.txid}') #{tx.txid} - var done = false + - var out = 0 + - var vin = 0 each r in tx.vout if r.addresses == address.a_id - td.success - - var amount = r.amount / 100000000 + - out = r.amount + each s in tx.vin + if s.addresses == address.a_id + - vin = s.amount + if out > 0 && vin > 0 + td.info + - var amount = (out - vin) / 100000000 + if amount < 0 + - amount = amount * -1 + | - #{amount.toFixed(8)} + else if amount > 0 | + #{amount.toFixed(8)} - else - each s in tx.vin - if done == false - if s.addresses == address.a_id - - done = true - td.danger - -var amount = s.amount / 100000000 - | - #{amount.toFixed(8)} - td(style='text-align:center') - a(href='/tx/#{tx.txid}') - span.glyphicon.glyphicon-eye-open \ No newline at end of file + else + | #{amount.toFixed(8)} + else if out > 0 + td.success + - var amount = out / 100000000 + | + #{amount.toFixed(8)} + else + td.danger + - var amount = vin / 100000000 + | - #{amount.toFixed(8)} \ No newline at end of file