tickets: amountin tx value is now normal since 0.1.5

This commit is contained in:
Tanguy Pruvot 2016-06-13 15:46:08 +02:00
parent b2aa3d9ffd
commit 5c83e36a5b
2 changed files with 11 additions and 5 deletions

View file

@ -321,6 +321,9 @@ if (!empty($txs)) {
// filter useless decred spent transactions
if ($DCR) {
// normal value since 0.1.5
$amountin_mul = $info['version'] >= 10500 ? 1.0 : 0.00000001;
$prev_tx = array(); $lastday = '';
foreach($txs_array as $key => $tx)
{
@ -360,14 +363,14 @@ if ($DCR) {
// won ticket value
$t = $remote->getrawtransaction($tx['txid'], 1);
if ($t && isset($t['vin'][0])) {
$txs_array[$key]['amount'] = $t['vin'][0]['amountin'] * 0.00000001;
$txs_array[$key]['amount'] = $t['vin'][0]['amountin'] * $amountin_mul;
}
}
if ($category == 'unlock') {
// unlocked amount
$t = $remote->getrawtransaction($tx['txid'], 1);
if ($t && isset($t['vin'][1])) {
$txs_array[$key]['amount'] = $t['vin'][1]['amountin'] * 0.00000001;
$txs_array[$key]['amount'] = $t['vin'][1]['amountin'] * $amountin_mul;
}
}
}

View file

@ -107,6 +107,9 @@ $voted_txs = array();
$list_txs = array();
$tickets = $remote->gettickets(true);
// normal value since 0.1.5
$amountin_mul = $info['version'] >= 10500 ? 1.0 : 0.00000001;
// extract stxs from decred transactions
if (!empty($txs_array)) {
@ -136,7 +139,7 @@ if (!empty($txs_array)) {
// ticket price
$input = 0.;
if ($stx && !empty($stx['vin'])) foreach ($stx['vin'] as $vin) {
$input += $vin['amountin'] * 0.00000001;
$input += $vin['amountin'] * $amountin_mul;
}
$txs_array[$key]['input'] = $input;
$list_txs[] = $tx['txid'];
@ -144,7 +147,7 @@ if (!empty($txs_array)) {
$category = 'stake';
if ($stx && isset($stx['vin'][0])) {
// won ticket value
$txs_array[$key]['amount'] = $stx['vin'][0]['amountin'] * 0.00000001;
$txs_array[$key]['amount'] = $stx['vin'][0]['amountin'] * $amountin_mul;
}
if ($stx && isset($stx['vin'][1])) {
$voted_txs[] = arraySafeVal($stx['vin'][1],'txid');
@ -177,7 +180,7 @@ if (!empty($tickets)) foreach ($tickets['hashes'] as $n => $txid) {
$k = time() - arraySafeVal($stx,'time', time()) + $n; // sort key
$stx['category'] = 'ticket';
if (isset($stx['vin'][0]))
$stx['input'] = $stx['vin'][0]['amountin'] * 0.00000001;
$stx['input'] = $stx['vin'][0]['amountin'] * $amountin_mul;
$commitamt = 0.;
foreach ($stx['vout'] as $v) {
if (arraySafeVal($v['scriptPubKey'],'type') == 'sstxcommitment')