goback(); $PoS = ($coin->algo == 'PoS'); // or if 'stake' key is present in 'getinfo' method $DCR = ($coin->rpcencoding == 'DCR'); $ETH = ($coin->rpcencoding == 'GETH'); $remote = new WalletRPC($coin); $reserved1 = dboscalar("SELECT SUM(balance) FROM accounts WHERE coinid={$coin->id}"); $reserved1 = altcoinvaluetoa($reserved1); $balance = altcoinvaluetoa($coin->balance); $owed = dboscalar("SELECT SUM(E.amount) AS owed FROM earnings E ". "LEFT JOIN blocks B ON E.blockid = B.id ". "WHERE E.status!=2 AND E.coinid={$coin->id} "//."AND B.category NOT IN ('stake','generated')" ); $owed_btc = bitcoinvaluetoa($owed*$coin->price); $owed = altcoinvaluetoa($owed); $symbol = $coin->symbol; if (!empty($coin->symbol2)) $symbol = $coin->symbol2; echo "
"; if (YAAMP_ALLOW_EXCHANGE) { $reserved2 = bitcoinvaluetoa(dboscalar("SELECT SUM(amount*price) FROM earnings WHERE status!=2 AND userid IN (SELECT id FROM accounts WHERE coinid={$coin->id})")); echo "Earnings $reserved2 BTC, "; } echo "Balance (db) $balance $symbol"; echo ", Owned ".bitcoinvaluetoa($coin->available)." $symbol"; echo ", Owed ".CHtml::link($owed, "/site/earning?id=".$coin->id)." $symbol ($owed_btc BTC)"; echo ", ".CHtml::link($reserved1, "/site/payments?id=".$coin->id)." $symbol cleared

"; ////////////////////////////////////////////////////////////////////////////////////// $bookmarkAdd = CHtml::link('+', "/site/bookmarkAdd?id=".$coin->id, array('title'=>'Add a bookmark')); echo << end; $list = getdbolist('db_markets', "coinid={$coin->id} AND NOT deleted ORDER BY disabled, priority DESC, price DESC"); $bestmarket = getBestMarket($coin); foreach($list as $market) { $marketurl = '#'; $price = bitcoinvaluetoa($market->price); $price2 = bitcoinvaluetoa($market->price2); $marketurl = getMarketUrl($coin, $market->name); $rowclass = 'ssrow'; if($bestmarket && $market->id == $bestmarket->id) $rowclass .= ' bestmarket'; if($market->disabled) $rowclass .= ' disabled'; echo ''; echo ''; $updated = "last updated: ".strip_tags(datetoa2($market->pricetime)); echo ''; echo ''; echo ''; $updated = "last updated: ".strip_tags(datetoa2($market->balancetime)); $balance = $market->balance > 0 ? bitcoinvaluetoa($market->balance) : ''; echo ''; $ontrade = $market->ontrade > 0 ? bitcoinvaluetoa($market->ontrade) : ''; echo ''; $sent = datetoa2($market->lastsent); $traded = datetoa2($market->lasttraded); $late = $market->lastsent > $market->lasttraded && $market->lasttraded ? 'late': ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; } // in the list after the markets, made for quick send between wallets $list = getdbolist('db_bookmarks', "idcoin={$coin->id} ORDER BY lastused DESC"); foreach($list as $bookmark) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $sent = datetoa2($bookmark->lastused); echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; } echo "
Market Bid Ask Deposit Balance Locked Sent Traded Late Message {$bookmarkAdd} Actions
'; echo $market->name; echo ''.$price.''.$price2.''; if (!empty($market->deposit_address)) { $name = CJavaScript::encode($market->name); $addr = CJavaScript::encode($market->deposit_address); echo CHtml::link( YAAMP_ALLOW_EXCHANGE ? "sell" : "send", "javascript:;", array( 'onclick'=>"return showSellAmountDialog($name, $addr, {$market->id});" ) ); echo ' '.$market->deposit_address; } echo ' edit'; echo ''.$balance.''.$ontrade.''.(empty($sent) ? "" : "$sent ago").''.(empty($traded) ? "" : "$traded ago").''.$late.''.$market->message.''; if ($market->disabled) echo 'enable'; else echo 'disable'; echo ' delete'; echo '
'.$bookmark->label.''; if (!empty($bookmark->address)) { $name = CJavaScript::encode($bookmark->label); $addr = CJavaScript::encode($bookmark->address); echo CHtml::link( "send", "javascript:;", array( 'onclick'=>"return showSellAmountDialog($name, $addr, 0, {$bookmark->id});" ) ); echo ' '.$bookmark->address; } echo ' edit'; echo ''.(empty($sent) ? "" : "$sent ago").''; echo 'delete'; echo '
"; ////////////////////////////////////////////////////////////////////////////////////// $info = $remote->getinfo(); if (!empty($info)) { $stake = arraySafeVal($info, 'stake', ''); if ($stake !== '') $PoS = true; } if ($DCR) { // Decred Tickets $stake = 0; $balances = $remote->getbalance('*',0); if (isset($balances["balances"])) { foreach ($balances["balances"] as $accb) { $stake += arraySafeVal($accb, 'lockedbytickets', 0); } } $stakeinfo = $remote->getstakeinfo(); $ticketprice = arraySafeVal($stakeinfo,'difficulty'); $tickets = arraySafeVal($stakeinfo, 'live', 0); $tickets += arraySafeVal($stakeinfo, 'immature', 0); } echo ''; echo ''; echo ''; echo ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if ($PoS || $DCR) echo ""; if ($DCR) echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; if($coin->enable) echo ""; else echo ""; echo ''; echo ''; echo ''; if(!$info) { echo ''; echo ''; echo '
NameSymbolAlgoDifficultyBlocksBalanceBTCStakeTicket priceConnsPriceRewardIndex *
[ + ][    ]'.$coin->name.''.$coin->symbol.''.$coin->algo.'ERROR '.$remote->error.''.bitcoinvaluetoa($coin->price).''; echo "

"; return; } $errors = isset($info['errors'])? $info['errors']: ''; $balance = isset($info['balance'])? $info['balance']: ''; $txfee = isset($info['paytxfee'])? $info['paytxfee']: ''; $connections = isset($info['connections'])? CHtml::link($info['connections'],'/site/peers?id='.$coin->id): ''; $blocks = isset($info['blocks'])? $info['blocks']: ''; echo ''.round_difficulty($coin->difficulty).''; if(!empty($errors)) echo ''.$blocks.''; else echo "$blocks"; echo ''.altcoinvaluetoa($balance).''; $btc = bitcoinvaluetoa($balance*$coin->price); echo "$btc"; if ($PoS) echo ''.$stake.''; else if ($DCR) { echo ''.CHtml::link("$stake ($tickets)", '/site/tickets?id='.$coin->id).''; echo ''.CHtml::link($ticketprice, "https://dcrstats.com/", array('target'=>'_blank')).''; } echo "$connections"; echo ''.bitcoinvaluetoa($coin->price).''; echo ''.$coin->reward.''; $index = ''; if($coin->difficulty) $index = round($coin->reward * $coin->price / $coin->difficulty * 10000, 3); echo ''.$index.''; echo ''; echo ''; ////////////////////////////////////////////////////////////////////////////////////// // last week $list_since = arraySafeVal($_GET,'since',time()-(7*24*3600)); $maxrows = (int) arraySafeVal($_GET,'rows', 500); $maxrows = max($maxrows, 250); $maxrows = min($maxrows, 2500); echo << end; $account = ''; if ($DCR) $account = '*'; if ($ETH) $account = $coin->master_wallet; $txs = $remote->listtransactions($account, $maxrows); if (empty($txs)) { if (!empty($remote->error)) { echo "RPC Error: {$remote->error}

"; } // retry... $txs = $remote->listtransactions($account, 200); } $txs_array = array(); $lastday = ''; if (!empty($txs)) { // to hide truncated days sums $tx = reset($txs); if (count($txs) == $maxrows && isset($tx['time'])) $lastday = strftime('%F', $tx['time']); if (!empty($txs)) foreach($txs as $tx) { if (arraySafeVal($tx, 'time', $list_since+1) > $list_since) $txs_array[] = $tx; } krsort($txs_array); } // 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) { // required after a wallet resynch/import $txs_array[$key]['time'] = min($tx['timereceived'], arraySafeVal($tx,'blocktime', $tx['time'])); $prev_txid = arraySafeVal($prev_tx,"txid"); $category = $tx['category']; if (arraySafeVal($tx, 'txtype') == 'ticket') { $txs_array[$key]['category'] = 'ticket'; if ($category != 'receive' || $prev_txid === arraySafeVal($tx,"txid")) unset($txs_array[$key]); else $txs_array[$key]['amount'] = 0 - $tx['amount']; continue; } if ($category == 'send' && arraySafeVal($tx,'generated')) { $txs_array[$key]['category'] = 'spent'; } else if ($category == 'send' && $tx['amount'] == -0) { // vote accepted (listed twice ? in listtransactions) if ($tx['vout'] > 0) $category = 'spent'; else if (arraySafeVal($tx,"confirmations") >= 256) $category = 'receive'; else $category = 'immature'; if ($category=='spent' && arraySafeVal($tx, 'txtype') == 'vote') { // todo: ticket unlocked amount $category='unlock'; } $txs_array[$key]['category'] = $category; if ($tx['vout'] == 0) { // won ticket value $t = $remote->getrawtransaction($tx['txid'], 1); if ($t && isset($t['vin'][0])) { $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'] * $amountin_mul; } } } else if ($category == 'send' && $prev_txid === arraySafeVal($tx,"txid")) { // if txid is the same as the last income... it's not a real "send" if ($prev_tx['amount'] == 0 - $tx['amount']) $txs_array[$key]['category'] = 'spent'; } else if ($category == 'receive') { $prev_tx = $tx; } // for truncated day sums if ($lastday == '' && count($txs) == $maxrows) $lastday = strftime('%F', $tx['time']); } ksort($txs_array); // reversed order } $rows = 0; foreach($txs_array as $tx) { $category = arraySafeVal($tx,'category'); if ($category == 'spent') continue; $block = null; if(isset($tx['blockhash'])) $block = $remote->getblock($tx['blockhash']); echo '

'; if (!isset($tx['time'])) { // martian wallets echo ''; continue; } $d = datetoa2($tx['time']); echo ''; $eta = ''; if ($category == 'immature') { if ($coin->block_time && $coin->mature_blocks) { $t = (int) ($coin->mature_blocks - arraySafeVal($tx,'confirmations',0)) * $coin->block_time; $eta = "ETA: ".sprintf('%dh %02dmn', ($t/3600), ($t/60)%60); } } echo ''; echo ''; if($block) { echo ''; } else echo ''; echo ''; echo ''; echo ''; echo ''; $rows++; if ($rows >= $maxrows) break; } echo '
Time Category Amount Height Difficulty Confirm Address Tx
'.json_encode($tx).''.$d.''.$category.''.$tx['amount'].''.$block['height'].''.round_difficulty($block['difficulty']).''.arraySafeVal($tx,'confirmations').''; if(isset($tx['address'])) { $address = $tx['address']; $exists = dboscalar("SELECT count(*) AS nb FROM accounts WHERE username=:address", array(':address'=>$address)); if ($exists) echo CHtml::link($address, '/?address='.$address); else echo $address.'
'; } echo '
'; if(!empty($block)) { $txid = arraySafeVal($tx, 'txid'); $label = substr($txid, 0, 7); echo $coin->createExplorerLink($label, array('txid'=>$txid), array('target'=>'_blank')); } echo '
'; $url = '/site/coin?id='.$coin->id.'&since='.(time()-31*24*3600).'&rows='.($maxrows*2); $moreurl = CHtml::link('Click here to show more transactions...', $url); echo '
'.$moreurl.'
'; echo ''; ////////////////////////////////////////////////////////////////////////////////////// echo << end; $sums = array(); foreach($txs_array as $tx) { if (!isset($tx['time'])) continue; $day = strftime('%F', $tx['time']); // YYYY-MM-DD if ($day == $lastday) break; // do not show truncated days $category = $tx['category']; if ($category == 'spent') continue; $key = $day.' '.$category; $sums[$key] = arraySafeVal($sums, $key) + $tx['amount']; } foreach($sums as $key => $amount) { $keys = explode(' ', $key); $day = substr($keys[0], 5); // remove year $category = $keys[1]; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } if (empty($sums)) { echo ''; echo ''; echo ''; } echo '
Day Category Sum BTC
'.$day.''.$category.''.$amount.''.bitcoinvaluetoa($coin->price * $amount).'
No activity during the last 7 days
';