function BackendUpdateDeposit() { // debuglog(__FUNCTION__); $btc = getdbosql('db_coins', "symbol='BTC'"); if (!$btc) { return; } $remote = new Bitcoin($btc->rpcuser, $btc->rpcpasswd, $btc->rpchost, $btc->rpcport); $info = $remote->getinfo(); if (!$info) { return; } if (!isset($info['blocks'])) { return; } $hash = $remote->getblockhash(intval($info['blocks'])); if (!$hash) { return; } $block = $remote->getblock($hash); if (!$block) { return; } if (!isset($block['time'])) { return; } if ($block['time'] + 30 * 60 < time()) { return; } $list = $remote->listaccounts(1); foreach ($list as $r => $a) { if ($a == 0) { continue; } $b = preg_match('/renter-prod-([0-9]+)/', $r, $m); if (!$b) { continue; } $renter = getdbo('db_renters', $m[1]); if (!$renter) { continue; } $ts = $remote->listtransactions(yaamp_renter_account($renter), 1); if (!$ts || !isset($ts[0])) { continue; } $moved = $remote->move(yaamp_renter_account($renter), '', $a); if (!$moved) { continue; } debuglog("deposit {$renter->id} {$renter->address}, {$a}"); $rentertx = new db_rentertxs(); $rentertx->renterid = $renter->id; $rentertx->time = time(); $rentertx->amount = $a; $rentertx->type = 'deposit'; $rentertx->tx = isset($ts[0]['txid']) ? $ts[0]['txid'] : ''; $rentertx->save(); $renter->unconfirmed = 0; $renter->balance += $a; $renter->updated = time(); $renter->save(); } $list = $remote->listaccounts(0); foreach ($list as $r => $a) { if ($a == 0) { continue; } $b = preg_match('/renter-prod-([0-9]+)/', $r, $m); if (!$b) { continue; } $renter = getdbo('db_renters', $m[1]); if (!$renter) { continue; } debuglog("unconfirmed {$renter->id} {$renter->address}, {$a}"); $renter->unconfirmed = $a; $renter->updated = time(); $renter->save(); } ///////////////////////////////////////////////////////////////////////////////////////////////////// $received1 = $remote->getbalance('bittrex', 1); //nicehash payments if ($received1 > 0) { $moved = $remote->move('bittrex', '', $received1); debuglog("moved from bittrex {$received1}"); dborun("update renters set balance=balance+{$received1} where id=7"); dborun("update renters set custom_start=custom_start+{$received1} where id=7"); } ///////////////////////////////////////////////////////////////////////////////////////////////////// $fees = 0.0001; $list = getdbolist('db_rentertxs', "type='withdraw' and tx='scheduled'"); foreach ($list as $tx) { $renter = getdbo('db_renters', $tx->renterid); if (!$renter) { continue; } // debuglog("$renter->balance < $tx->amount + $fees"); $tx->amount = bitcoinvaluetoa(min($tx->amount, $renter->balance - $fees)); if ($tx->amount < $fees * 2) { $tx->tx = 'failed'; $tx->save(); continue; } debuglog("withdraw send {$renter->id} {$renter->address} sendtoaddress({$tx->address}, {$tx->amount})"); $tx->tx = $remote->sendtoaddress($tx->address, round($tx->amount, 8)); if (!$tx->tx) { $tx->tx = 'failed'; $tx->save(); continue; } $renter->balance -= $tx->amount + $fees; $renter->balance = max($renter->balance, 0); dborun("update renters set balance={$renter->balance} where id={$renter->id}"); $tx->save(); if ($renter->balance <= 0.0001) { dborun("update jobs set active=false, ready=false where id={$renter->id}"); } } }
echo "<div class='main-left-inner'>"; echo "<table class='dataGrid2'>"; echo "<thead class=''>"; echo "<tr>"; echo "<th>Time</th>"; echo "<th>Amount</th>"; echo "<th>Confirmations</th>"; echo "<th>Tx</th>"; echo "</tr>"; echo "</thead><tbody>"; $btc = getdbosql('db_coins', "symbol='BTC'"); if (!$btc) { return; } $remote = new Bitcoin($btc->rpcuser, $btc->rpcpasswd, $btc->rpchost, $btc->rpcport); $ts = $remote->listtransactions(yaamp_renter_account($renter), 10); $res_array = array(); foreach ($ts as $val) { $t = $val['time']; if ($t < $renter->created) { continue; } $res_array[$t] = $val; } krsort($res_array); $total = 0; foreach ($res_array as $transaction) { if ($transaction['category'] != 'receive') { continue; } $d = datetoa2($transaction['time']);
echo "<br><br>"; ////////////////////////////////////////////////////////////////////////////////////// echo "<table class='dataGrid'>"; //showTableSorter('maintable'); echo "<thead class=''>"; echo "<tr>"; echo "<th>Time</th>"; echo "<th>Height</th>"; echo "<th>Category</th>"; echo "<th>Amount</th>"; echo "<th>Confirmations</th>"; echo "<th></th>"; echo "</tr>"; echo "</thead><tbody>"; //$transactions = $remote->listsinceblock(''); $ts = $remote->listtransactions('', 10); $res_array = array(); foreach ($ts as $val) { $t = $val['time']; $res_array[$t] = $val; } krsort($res_array); foreach ($res_array as $transaction) { $block = null; if (isset($transaction['blockhash'])) { $block = $remote->getblock($transaction['blockhash']); } $d = datetoa2($transaction['time']); echo "<tr class='ssrow'>"; echo "<td><b>{$d}</b></td>"; if ($block) {