function tx_scan($tx) { global $address; if (isset($tx['limit'])) { $tx['type'] = 2; $tx['in'] = 0; $tx['amount'] = remove_ep($tx['vin'][0]['value']); return $tx; } else { foreach ($tx['vin'] as $k => $input) { if ($input['address'] === $address) { $tx['type'] = 0; $tx['in'] = remove_ep($input['value']); $tx['amount'] = $tx['in']; return $tx; } } foreach ($tx['vout'] as $k => $output) { if ($output['address'] === $address) { $tx['type'] = 1; $tx['out'] = remove_ep($output['value']); $tx['amount'] = $tx['out']; return $tx; } } } $tx['type'] = -1; return $tx; }
function scan_tx($tx) { global $totals; global $add_txs; $txid = $tx['txid']; if (isset($tx['limit'])) { if (isset($add_txs[$tx['vin'][0]['address']])) { $add_txs[$tx['vin'][0]['address']] .= "{$txid}:2\n"; } else { $add_txs[$tx['vin'][0]['address']] = "{$txid}:2\n"; } } else { foreach ($tx['vin'] as $k => $input) { $clean_val = remove_ep($input['value']); if (isset($add_txs[$input['address']])) { $add_txs[$input['address']] .= "{$txid}:0\n"; $inp_sum = $totals[$input['address']]['inp']; $totals[$input['address']]['inp'] = bcadd($inp_sum, $clean_val); $totals[$input['address']]['ict'] += 1; } else { $add_txs[$input['address']] = "{$txid}:0\n"; $totals[$input['address']] = array('inp' => $clean_val, 'ict' => 1, 'out' => 0, 'oct' => 0); } } foreach ($tx['vout'] as $k => $output) { $clean_val = remove_ep($output['value']); if (isset($add_txs[$output['address']])) { $add_txs[$output['address']] .= "{$txid}:1\n"; $out_sum = $totals[$output['address']]['out']; $totals[$output['address']]['out'] = bcadd($out_sum, $clean_val); $totals[$output['address']]['oct'] += 1; } else { $add_txs[$output['address']] = "{$txid}:1\n"; $totals[$output['address']] = array('out' => $clean_val, 'oct' => 1, 'inp' => 0, 'ict' => 0); } } } }
<th>Transaction ID</th> <th>Age</th> <th>Amount Sent</th> </tr>'; foreach ($txs as $key => $value) { if ($count > 9) { break; } $tx[$key] = $_SESSION[$rpc_client]->getrawtransaction($value, 1); if (!$show_cbtxs && $tx[$key]['vin'][0]['coinbase'] === true) { continue; } $total = ''; foreach ($tx[$key]['vout'] as $k => $value) { if (!isset($tx[$k]['limit'])) { $total = bcadd($total, remove_ep($value['value'])); } } $tx_time = date("Y-m-d h:i:s A e", $tx[$key]['time']); $tx_age = get_time_difference($tx_time, date("Y-m-d h:i:s A e")); $count++; if ($tx_age['seconds'] < 1) { $tx_age = '< 1 second'; } elseif ($tx_age['minutes'] < 1) { $tx_age = $tx_age['seconds'] . ' seconds'; } else { $tx_age = $tx_age['minutes'] . ' minutes'; } echo "<tr><td><a href='./?tx=" . $tx[$key]['txid'] . "'>" . $tx[$key]['txid'] . "</a></td><td>" . $tx_age . "</td><td>" . $total . ' ' . $curr_code . "</td></tr>"; } echo '</table>';
<?php $balance = $_SESSION[$rpc_client]->listbalances(1, array($cb_address)); $mining_info = $_SESSION[$rpc_client]->getmininginfo(); $tx_stats = $_SESSION[$rpc_client]->gettxoutsetinfo(); $now_time = date("Y-m-d H:i:s e"); $start_time = date("Y-m-d H:i:s e", $launch_time); $time_diff = get_time_difference($start_time, $now_time); $coin_supply = remove_ep($tx_stats['total_amount']); $cb_balance = remove_ep($balance[0]['balance']); $frac_reman = bcdiv($cb_balance, $total_coin); $block_rwrd = bcmul($first_reward, $frac_reman); $l_dat = explode(':', file_get_contents("./db/last_dat")); $s_dat = explode(':', file_get_contents("./db/stat_dat")); ?> <h1>Statistics</h1><br /> <table class="table table-striped"> <tr><td> <b>Coin supply:</b></td><td> <?php echo float_format($coin_supply, 6) . " {$curr_code}"; ?> </td></tr><tr><td> <b>Unmined coins:</b></td><td> <?php echo float_format($cb_balance, 4) . ' ' . $curr_code; ?> </td></tr><tr><td> <b>Block Reward:</b></td><td>
} else { $address = preg_replace("/[^a-z0-9]/i", '', $_GET['arg1']); $confs = empty($_GET['arg2']) ? 1 : (int) $_GET['arg2']; $ainfo = $_SESSION[$rpc_client]->listbalances($confs, array($address)); $result = remove_ep($ainfo[0]['limit']); break; } case 'addresslastseen': //////////////////////////////////////////// if (empty($_GET['arg1'])) { die('address was not specified'); } else { $address = preg_replace("/[^a-z0-9]/i", '', $_GET['arg1']); $confs = empty($_GET['arg2']) ? 1 : (int) $_GET['arg2']; $ainfo = $_SESSION[$rpc_client]->listbalances($confs, array($address)); $balance = remove_ep($ainfo[0]['balance']); if (clean_number($balance) === '0') { $last_used = 'unknown'; } else { $last_used = $ainfo[0]['age']; } $result = $last_used; break; } case 'addresscount': //////////////////////////////////////////// $tx_stats = $_SESSION[$rpc_client]->gettxoutsetinfo(); $result = $tx_stats['accounts']; break; case 'getinfo': ////////////////////////////////////////////
function coins_to_int($num, $coin = 10000000000.0) { return bcmul(remove_ep($num), $coin); }
$total_in = bcadd($total_in, $clean_val); if ($value['coinbase'] == true) { $input_str .= "<a href='./?address=" . $value['address'] . "'>TheCoinbaseAccount" . "</a> → <span class='sad_txt'>{$clean_val}</span> {$curr_code} (block reward)<br />"; } else { $input_str .= "<a href='./?address=" . $value['address'] . "'>" . $value['address'] . "</a> → <span class='sad_txt'>{$clean_val}</span> {$curr_code}<br />"; } } } else { $total_in = 0; $input_str = 'No Inputs (coinbase genesis transaction)<br />'; } foreach ($tx['vout'] as $key => $value) { $clean_val = remove_ep($value['value']); $total_out = bcadd($total_out, $clean_val); if (isset($tx['limit'])) { $output_str .= "Withdrawal limit of input address updated to: <span class='happy_txt'>" . remove_ep($tx['limit']) . "</span> {$curr_code}<br />"; } else { $output_str .= "<a href='./?address=" . $value['address'] . "'>" . $value['address'] . "</a> ← <span class='happy_txt'>{$clean_val}</span> {$curr_code}<br />"; } } echo "<h1>Transaction Details</h1><br />"; echo "<table class='table table-striped table-condensed' style='width:auto;'>"; echo "<tr><td><b>TxID:</b></td><td><a href='./?rawtx=" . $tx['txid'] . "'>" . $tx['txid'] . "</a></td></tr>"; if (isset($tx['blockhash'])) { echo "<tr><td><b>Block:</b></td><td><a href='./?block=" . $tx['blockhash'] . "'>" . $tx['blockhash'] . "</a></td></tr>"; } else { echo "<tr><td><b>Block:</b></td><td>not in a block yet</td></tr>"; } $tx_time = isset($tx['time']) ? date("Y-m-d h:i A e", $tx['time']) : 'unknown'; $confirmations = isset($tx['confirmations']) ? $tx['confirmations'] : '0'; $tx_message = empty($tx['msg']) ? 'none' : safe_str($tx['msg']);