Post
Topic
Board Trading Discussion
Re: PHP martingale bot for satoshiDICE
by
tribalmind
on 02/02/2013, 02:13:16 UTC
require_once('jsonRPCClient.php');
/** BITCOIN **/
$btcu = array("user" => "xxx",             // RPC Username
            "pass" =>   "xxx",               // RPC Password
            "host" =>   "localhost",      // RPC Hostname/IP
            "port" =>   8332);            // RPC Port
$b = new jsonRPCClient("http://{$btcu['user']}:{$btcu['pass']}@{$btcu['host']}:{$btcu['port']}");

define('MIN_BET', 0.0633399);
define('MAX_BET', 2);
define('ADDRESS', '1dicec9k7KpmQaA8Uc8aCCxfWnwEWzpXE');

$bet = MIN_BET;
$total_fees = 0;
$count = 0;
$count_won = 0;
while (($bet <= MAX_BET) && ($count_won < 300))
{
        $balance_a = $b->getbalance('*', 0);
        if (!isset($starting_balance)) $starting_balance = $balance_a;
        if($b->getbalance('*', 1) < $bet) { // If we don't have enough confirmed bitcoins to send to satoshi dice...
            echo "Waiting for confirmed balance";
            while($b->getbalance('*', 1) < $bet)
            {
                echo ".";
                sleep(60); // Wait a full minute before checking the balance again.
            }
            echo "\n";
        }
       try // Wrapped in a try catch block just incase we run out of cash.
        {
            $b->sendtoaddress(ADDRESS, (float) $bet);
       }
        catch(Exception $e)
        {
            echo "Have: " . $b->getbalance('*', 1) . " Needed: " . $bet . "\n";
          die("Ran out of money?\n");
       }
        $balance_b = $b->getbalance('*', 0);
        $count++;
        $fee = $balance_a - $balance_b - $bet;
        $total_fees += $fee;
        $total_fees = number_format($total_fees,8,'.','')+0


the errors came with 3 different attempts at modifieng the bet amount for it to be a fraction of the balance,