Example #1
0
                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')));
                    }
                }
            }
            Status::sumFields(array('hot_wallet_btc' => 0 - $transferred - $transfer_fees, 'warm_wallet_btc' => $transferred, 'total_btc' => 0 - $transfer_fees));
            echo 'Transferred ' . $reserve_surplus . ' to warm wallet. TX: ' . $response . PHP_EOL;
        }
    }
} elseif ($reserve['hot_wallet_btc'] > $CFG->bitcoin_reserve_min && $warm_wallet && $reserve_surplus > 0) {
    //$warm_wallet_a = BitcoinAddresses::getWarmWallet();
    $warm_wallet_a['address'] = $warm_wallet;
    $hot_wallet_a = BitcoinAddresses::getHotWallet();
    $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')));
                }