First off, thank you to all our botters.
Your relentless thrashing of our games have helped us tune the engine and front end for much faster responses.
This latest update first checks your local bitcoin wallet's latest transaction, if it is a recieve it assumes it is a result and proceeds with the next bet.
This can have unforeseen results, ie if you have another transaction come in while the bot is running.
To avoid any user heads this "turbo mode" is disabled by default, but can be turned on by setting
$turbo = 1; in the user defined settings.
<?php
# *****************************************************************************
# Satoshi Roulette Bot
# *****************************************************************************
#
# references:
# https://bitcointalk.org/index.php?topic=137519.msg1512149#msg1512149
# http://blockchain.info/api/blockchain_wallet_api
include './jsonRPCClient.php';
global $address;
global $address_old;
global $bet;
global $min;
global $max;
global $max_old;
global $jackpot;
global $sleep;
global $user;
global $password;
global $coind;
global $blockchain;
global $turbo;
# -----------------------------------------------------------------------------
# Begin user defined settings
# -----------------------------------------------------------------------------
$turbo = 0; # enable turbo mode, for fast result checking using the latest recieved bitcoind txid.
# list of games to bet against.
$games = array("roulette-red", "roulette-black", "roulette-odd", "roulette-even", "jdice-052", "coinflip-heads", "coinflip-tails", "roulette-1to18", "roulette-19to36");
# exit settings
$percent_win = 100; # what % wallet increase to stop at
$percent_lose = 50; # what % wallet decrease to stop at
# bot settings
$mode = 'TRC'; # mode: BTC/ LTC/ PPC
$blockchain = 0; # 1 for using blockchain.info wallets, set mode to BTC
$min = 0.025; # if lower than the games min, the games min is used
$max = 100; # if higher than the games max, the games max is used
$goto_max = 1; # if the next bet greater than the games max bet, bet max. Used for collecting jackpots.
# bitcoind/ litecoind/ trcoind rpc connection settings
$ip = '127.0.0.1'; # coind ip
$user = 'user'; # coind rpc user
$password = 'password'; # coind rpc password
$port = 8866; # coind rpc port
# misc settings
$x = 2; # when a bet loses, the next bet = $bet * $x;
$sleep = 10; # sleep time: 10 seconds is optimal, 5 or lower for turbo.
# -----------------------------------------------------------------------------
# End user defined settings
# -----------------------------------------------------------------------------
$bet = 0;
$json_coind_url = "http://$user:$password@$ip:$port/";
$game_name = $games[0]; # start with first game in array
$balance = 0;
$jackpot = 0;
$address_old = '';
$gweedo = 1;
$json_coind_url = "http://$user:$password@$ip:$port/";
$address = '';
# *****************************************************************************
# Start
# *****************************************************************************
if(!$blockchain) # connect to coind via rpc if not using blockchain.info api
{
$coind = new jsonRPCClient($json_coind_url);
}
$start_balance = $balance = sprintf("%.4f", check_balance());
$win_balance = sprintf("%.4f", $start_balance * ((100+$percent_win) / 100));
$lose_balance = sprintf("%.4f", $start_balance * ((100-$percent_lose) / 100));
check_last();
echo
"===============================================================================
Satoshi Roulette - Martingale Bot - Mode $mode
===============================================================================
Target Balance: $win_balance $mode
Start Balance : $start_balance $mode
Stop Balance : $lose_balance $mode
";
if($turbo == 1)
{
echo "\nTURBO MODE\n";
}
echo "
-----------------------------------------------------------------------------
";
# load game info
$rand_keys = array_rand($games, 2); $game_name = $games[$rand_keys[0]];
$s = load_game($mode, $game_name);
if(!$bet) { $bet = $min; }
while(1)
{
# send bet
$bet_txid = send_bet($bet, $address);
echo date("H:i:s: ", time()) . "Balance: " . sprintf("%.4f", $balance) . " $mode, txid: $bet_txid, bet: " . sprintf("%.4f", $bet) . " $mode on $game_name ";
# wait for result
$result = get_result($mode, $bet_txid, $game_name);
# pre select next game
$rand_keys = array_rand($games, 2); $game_name = $games[$rand_keys[0]]; $s = load_game($mode, $game_name);
# check win / lose
if($result) # WIN
{
#echo $win_string;
echo " WIN\n";
$bet = $min;
}
else # LOSE
{
echo " LOSE\n";
$bet = 0 + sprintf("%.8f", $bet * $x);
if($bet > $max)
{
echo "[Hit Wall - Reseting]\n";
$bet = $min;
}
else if($goto_max && $bet * $x > $max)
{
$bet = $max;
}
}
# -----------------------------------------------------------------------------
# check exit :3
# -----------------------------------------------------------------------------
$balance = check_balance();
if($balance < $start_balance * (100-$percent_lose) / 100) # loss exit
{
echo "Exiting, Balance $balance is $percent_lose % lower than start balance $start_balance\n";
exit;
}
if($balance > $start_balance * (100+$percent_win) / 100 ) # profit exit
{
echo "Exiting, Balance $balance is $percent_win % higher than start balance $start_balance\n";
exit;
}
}
exit;
# *****************************************************************************
# done
# *****************************************************************************
# -----------------------------------------------------------------------------
# Load Game
function load_game($mode, $game_name)
{
$GLOBALS['jackpot'] = 0;
while(1)
{
$tmp = file_get_contents("http://satoshiroulette.com/api.php?game=$game_name&mode=$mode");
$game = json_decode($tmp);
if( isset($game->{'address'}) )
{
break;
}
else
{
print "JSON Reply:\n$tmp\n";
sleep(10);
}
}
$GLOBALS['address'] = $game->{'address'} ;
if(isset($game->{'jackpot'}))
{
$GLOBALS['jackpot'] = sprintf("%.8f", $game->{'jackpot'});
}
if($GLOBALS['min'] < $game->{'min_bet'} || !$GLOBALS['min'])
{
$GLOBALS['min'] = $game->{'min_bet'} ;
}
if($GLOBALS['min'] > $game->{'max_bet'})
{
$GLOBALS['min'] = $game->{'min_bet'} ;
}
if($GLOBALS['max'] > $game->{'max_bet'} || !$GLOBALS['max'])
{
$GLOBALS['max'] = $game->{'max_bet'};
}
}
# -----------------------------------------------------------------------------
# Get Balance
function check_balance()
{
if($GLOBALS['blockchain'])
{
$jsonurl = "https://blockchain.info/merchant/".$GLOBALS['user']."/balance?password=".$GLOBALS['password'];
$json = file_get_contents($jsonurl,0,null,null);
$json = json_decode($json);
return $json->{'balance'} / 100000000;
}
return $GLOBALS['coind']->getbalance('*', 0);
}
# -----------------------------------------------------------------------------
# wait for bet result
function get_result($mode, $bet_txid, $game_name)
{
$jsonurl = "http://satoshiroulette.com/log.api.php?txid=$bet_txid&mode=$mode";
$c = 0;
while(! isset($r->{$game_name}))
{
$c++;
# sleep straight away as its unlikely we bitcoin travels the speed of light
sleep($GLOBALS['sleep']);
# check local wallet for latest tx
$w = check_last();
if($w == 'WIN')
{
return 1;
}
else if ($w == 'LOSE')
{
return 0;
}
# check satoshiroulette.com API for win / lose
$r = json_decode(file_get_contents($jsonurl));
if(isset($r->{$game_name}))
{
return $r->{$game_name};
}
if($c == 6)
{
$c = 0;
print "|";
}
else
{
print "-";
}
}
}
# -----------------------------------------------------------------------------
# Bet
function send_bet($bet, $address)
{
if($GLOBALS['blockchain'])
{
$b = $bet * 100000000;
$jsonurl = "https://blockchain.info/merchant/".$GLOBALS['user']."/payment?password=".$GLOBALS['password']."&to=$address&amount=$b";
$bet_tx = json_decode(file_get_contents($jsonurl,0,null,null));
return $bet_tx->{'tx_hash'};
}
return $GLOBALS['coind']->sendtoaddress($address, (float) $bet );
}
function check_last()
{
if($GLOBALS['blockchain'] || !$GLOBALS['turbo'])
{
return 'NULL';
}
$r = $GLOBALS['coind']->listtransactions();
$l = count($r) - 1;
$cat = $r[$l]['category'];
$txid = $r[$l]['txid'];
$amount = $r[$l]['amount'];
if($cat == 'receive')
{
if($amount < $GLOBALS['bet'])
{
return 'LOSE';
}
else
{
return 'WIN';
}
}
return 'NULL';
}
?>
Sample Output:
C:\sr-bot>php bot.php
===============================================================================
Satoshi Roulette - Martingale Bot - Mode TRC
===============================================================================
Target Balance: 725.4350 TRC
Start Balance : 362.7175 TRC
Stop Balance : 181.3587 TRC
-----------------------------------------------------------------------------
21:03:46: Balance: 362.7175 TRC, txid: 5c3dc408e2bd309de48dcbab3e0868fb5011fc8963a6fec8f5283e6e572cd692, bet: 0.5000 TRC on roulette-red WIN
21:03:57: Balance: 363.2115 TRC, txid: 437978c14bbdecdc83907327b5274727d17b5e7fe18b4eacec7fa8291daae9a3, bet: 0.5000 TRC on roulette-red LOSE
21:04:08: Balance: 362.7105 TRC, txid: a9e024ffd569236055715b6e908c196a349b95e7c69c244348014795707e2990, bet: 1.0000 TRC on coinflip-heads - LOSE
21:04:32: Balance: 361.7095 TRC, txid: 21a068d5eafaae38cee29c894322562b64b4a8b05141d7b8dcdb2cfb5af6537e, bet: 2.0000 TRC on jdice-052 - LOSE
21:04:55: Balance: 359.7085 TRC, txid: 6313a2eb1a41f5e565e198f68716643085b6360e2007d4fe8ad9c3a34329d713, bet: 4.0000 TRC on jdice-052 - LOSE
21:05:18: Balance: 355.7075 TRC, txid: c010cfb3b22011be3972e52f522f932f2963b26bb1450a330721cd77719a16da, bet: 8.0000 TRC on roulette-black LOSE
21:05:29: Balance: 347.7065 TRC, txid: 3fe612101867a9d30624c17234fafb92d67ec1cafea14bee52e6f52a6f431441, bet: 16.0000 TRC on roulette-1to18 LOSE
21:05:40: Balance: 331.7055 TRC, txid: c774a19b0a2943d95b0cb95d0a1dbf8070c3901ffc537fd868e670850bcde047, bet: 37.0000 TRC on jdice-052 - LOSE
[Hit Wall - Reseting]
21:06:03: Balance: 294.7045 TRC, txid: f187198677a7f338f61caa4080d8835b3d3bd8219d077233e9f60424e1ffff10, bet: 0.5000 TRC on jdice-052 WIN
21:06:14: Balance: 295.1995 TRC, txid: 7648ea3d1bad8ddfb0b7173a43e5ce79191c136d1ace2dc795d2f57f556060ca, bet: 0.5000 TRC on roulette-even - LOSE
21:06:36: Balance: 294.6985 TRC, txid: 992e3af38bcf6bee00eabec0a2906308d0b3cd5c411fdb55282e2f44a5532167, bet: 1.0000 TRC on roulette-red WIN
21:06:47: Balance: 295.6925 TRC, txid: 8a7d83076e86f0dcf3f2205ffbd2dede222186525ee74089d44b86e2f46455c5, bet: 0.5000 TRC on roulette-even LOSE
21:06:58: Balance: 295.1915 TRC, txid: ff565210a53d0c0d2df062c438260d08b1ee6a9ced77b4a18f104faa4ff19c74, bet: 1.0000 TRC on roulette-odd - LOSE
21:07:20: Balance: 294.1905 TRC, txid: e7fac25eaf862a8a89444211a7ece0146c00c941e0d409073693271ec4330325, bet: 2.0000 TRC on roulette-black LOSE
21:07:31: Balance: 292.1895 TRC, txid: ceaf730d498907d1014f9ef90acfa0c58f83ff413501126c5f088944073acce9, bet: 4.0000 TRC on roulette-odd LOSE
21:07:42: Balance: 288.1885 TRC, txid: 4eed48cbfddd87ff37c34c9a7e160f2644037be603dc5d8436352003a2d79a00, bet: 8.0000 TRC on roulette-black WIN
21:07:53: Balance: 296.1825 TRC, txid: 6bd913d91d37ddec7dcc61e44d0cfbbc20b0dd32964152aabc842906f9beeb4d, bet: 0.5000 TRC on roulette-black - LOSE
21:08:15: Balance: 295.6815 TRC, txid: 53bc4d3afb6379eb60dd998985390ad748bc4248db0900c3e29b4955360d97c5, bet: 1.0000 TRC on roulette-black WIN
21:08:26: Balance: 296.6755 TRC, txid: ed48318fd28c56ff096c09a8820490c591f9303828ac1fbc86d7fed021621dc6, bet: 0.5000 TRC on roulette-black