curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE); $result1 = curl_exec($ch); $result = json_decode($result1,true); curl_close($ch); $warm_wallet = $result['address']; } */ if ($total_received > 0) { echo 'Total received: ' . $total_received . PHP_EOL; $update = Status::sumFields(array('hot_wallet_btc' => $total_received, 'total_btc' => $total_received)); //$warm_wallet_a = BitcoinAddresses::getWarmWallet(); $warm_wallet_a['address'] = $warm_wallet; $hot_wallet_a = BitcoinAddresses::getHotWallet(); if ($reserve['hot_wallet_btc'] + $total_received > $CFG->bitcoin_reserve_min && $warm_wallet && $reserve_surplus > 0) { $bitcoin->walletpassphrase($CFG->bitcoin_passphrase, 3); $response = $bitcoin->sendfrom($CFG->bitcoin_accountname, $warm_wallet_a['address'], floatval($reserve_surplus)); $transferred = 0; echo $bitcoin->error; if ($response && !$bitcoin->error) { $transferred = $reserve_surplus; $transfer_fees = 0; $transaction = $bitcoin->gettransaction($response); foreach ($transaction['details'] as $detail) { if ($detail['category'] == 'send') { $detail['fee'] = abs($detail['fee']); if ($detail['fee'] > 0) { $transfer_fees += $detail['fee']; db_insert('fees', array('fee' => $detail['fee'], 'date' => date('Y-m-d H:i:s'))); } } }
$bitcoin->walletpassphrase($CFG->bitcoin_passphrase, 3); $json_arr = array(); $fees_charged = 0; foreach ($transactions as $address => $amount) { $json_arr[$address] = $amount - $CFG->bitcoin_sending_fee; $fees_charged += $CFG->bitcoin_sending_fee; } $response = $bitcoin->sendmany($CFG->bitcoin_accountname, json_decode(json_encode($json_arr))); if (!empty($bitcoin->error)) { echo $bitcoin->error . PHP_EOL; } } elseif (count($transactions) == 1) { $bitcoin->walletpassphrase($CFG->bitcoin_passphrase, 3); $fees_charged = 0; foreach ($transactions as $address => $amount) { $response = $bitcoin->sendfrom($CFG->bitcoin_accountname, $address, (double) bcsub($amount, $CFG->bitcoin_sending_fee, 8)); $fees_charged += $CFG->bitcoin_sending_fee; if (!empty($bitcoin->error)) { echo $bitcoin->error . PHP_EOL; } } } } if (!empty($response) && $users && !$bitcoin->error) { echo 'Transactions sent: ' . $response . PHP_EOL; $total = 0; $transaction = $bitcoin->gettransaction($response); $actual_fee_difference = $fees_charged - abs($transaction['fee']); foreach ($users as $site_user => $amount) { $total += $amount; User::updateBalances($site_user, array('btc' => -1 * $amount), true);