Skip to content

Commit

Permalink
negative balance when sending to self; fixes iquidus#6, iquidus#8
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Williams committed May 4, 2015
1 parent f737658 commit f25f5ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
17 changes: 7 additions & 10 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -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();
}
}
});
}
Expand Down
37 changes: 23 additions & 14 deletions views/includes/address_history.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
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)}

0 comments on commit f25f5ec

Please sign in to comment.