Pages:
Author

Topic: PHP martingale bot for satoshiDICE - page 3. (Read 32838 times)

newbie
Activity: 24
Merit: 0
February 06, 2013, 01:14:45 AM
I'm gonna try your script as it looks 1000x better.

Here is an error I get:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\bot2.php on line 132



BTC2 received, thanks.  Good luck! (you'll need it if you plan to use martingale betting for very long...)
legendary
Activity: 2072
Merit: 1001
February 05, 2013, 10:08:12 PM
maybe * does not work as you expect. put 127.0.0.1

maybe server=1 does not work.
start bitcoin from dos prompt. change directory to where bitcoin executable is and start like this "bitcoin -server" or
whatever the exe is called. bitcoind or bitcoin...
newbie
Activity: 24
Merit: 0
February 05, 2013, 09:58:27 PM
Okay so I'm still confused.

This is what I currently have in my bitcoin.conf:
rpcuser=KJTetc
rpcpassword=(my pass lol)
rpcallowip=*
server=1

And this is my bot which is in htdocs which also has JSONrpcClient in it.

 
Code:
require_once('jsonRPCClient.php');
$b = new jsonRPCClient('http://KJTetc:MyRpcpass@localhost:8332/');

define('MIN_BET'0.01);
define('MAX_BET'6);
define('ADDRESS''1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp');

$bet MIN_BET;
$total_fees 0;
$count 0;
$count_won 0;

while ((
$bet <= MAX_BET) && ($count_won 100))
{
        
$count++;

        
$balance_a $b->getbalance('*'0);
        if (!isset(
$starting_balance)) $starting_balance $balance_a;
        
$b->sendtoaddress(ADDRESS, (float) $bet);
        
$balance_b $b->getbalance('*'0);

        
$fee $balance_a $balance_b $bet;
        
$total_fees += $fee;
        
$total_fees number_format($total_fees,8,'.','')+0;

        echo 
'Game #'.$count."\n";
        echo 
'Balance: ' $balance_a."       ";
        echo 
'Bet: '$bet."       ";
        echo 
'Fee: '. (number_format($fee8'.''') +0) . "       ";
        echo 
'Total Fees: '$total_fees"\n";
        echo 
'Balance: ' $balance_b "       ".'Waiting';

        
$balance_c 0;

        while (
$balance_b >= $balance_c)
        {
        sleep(4);
$balance_c $b -> getbalance('*'0);
echo '.';
        }

        echo 
"\nBalance: $balance_c       ";

        
$diff $balance_c $balance_b;

        if (
$diff $bet)
        {
                
$bet MIN_BET;
                
$count_won++;
                echo 
"Win! ($count_won out of $count)\n";
        }
        else
        {
                
$bet *= 2;
                echo 
'Lose!'."\n";
        }

        echo 
"\n";
}

echo 
'Starting Balance: '.$starting_balance."\n";
echo 
'Ending Balance  : '$balance_c."\n";
echo 
'Total Fees: '$total_fees."\n";
$amt_won $balance_c $starting_balance;
echo 
'Net Profit: '. (number_format($amt_won,8,'.','') + 0). "\n\n";

I get this error:


Code:
Warning: fopen(http://...@localhost:8332/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\xampp\htdocs\jsonRPCClient.php on line 132

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://KJTetc:*****@localhost:8332/' in C:\xampp\htdocs\jsonRPCClient.php:140 Stack trace: #0 C:\xampp\htdocs\bot2.php(20): jsonRPCClient->__call('sendtoaddress', Array) #1 C:\xampp\htdocs\bot2.php(20): jsonRPCClient->sendtoaddress('1dice8EMZmqKvrG...', 0.01) #2 {main} thrown in C:\xampp\htdocs\jsonRPCClient.php on line 140





BTC2 received, thanks.  Good luck! (you'll need it if you plan to use martingale betting for very long...)
legendary
Activity: 2856
Merit: 1518
Bitcoin Legal Tender Countries: 2 of 206
February 05, 2013, 10:31:42 AM
you cannot successfully play SD with logic or a script. forget to play with this!

to beat SD you have to play with illogicalness. this is where the fear of SD comes from!

http://blockchain.info/tx/9784cb364ffbaa000bbb5574ec6a50c9f500c9df830cf89d3cd90318bd7225dc --> WIN

EDIT: http://blockchain.info/tx/9b446789a58501a84767f0ad87013982aec870048b40cc895fc3fde0c56af37a --> WIN

EDIT2: http://blockchain.info/tx/812bdb3cc7e620e38e1fdee74361d58c1c860e3d2b2b7a7ee3c37047e2157a8c --> LOSE

So, what next? Buy bitcoins to feed the SD monster with 20.48 --> 40.96 --> 81.92?? NO WAY!! DON'T FEED THE SD MONSTER. IT IS WASTE OF TIME.
legendary
Activity: 2940
Merit: 1330
February 04, 2013, 09:27:03 PM

BTC2 received, thanks.  Good luck! (you'll need it if you plan to use martingale betting for very long...)
legendary
Activity: 2940
Merit: 1330
February 04, 2013, 06:41:16 PM
Here you go:

https://github.com/dooglus/sdbot

I lost about BTC1 testing it, but it seems to work pretty well.

Don't forget to edit this line:

Code:
define('STASH_ADDRESS', '1Doog7asLrYah3yeUppBVj8nUYnFkmXm2N');                             

or your winnings will be sent somewhere *really* safe...  Wink
legendary
Activity: 1792
Merit: 1008
/dev/null
February 04, 2013, 05:51:54 PM
What do I have near the top as the ip address? I get this error right now :

Warning: fopen(http://[email protected]:8332/): failed to open stream: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\jsonRPCClient.php on line 86


Your bitcoin client prob need to be in server mode and listening on 127.0.0.1 which is local loopback ip addy.

How do I start it in server mode? I think I saw a script a while ago on it but I can't remember...
i saw something named README / wiki
legendary
Activity: 2940
Merit: 1330
February 04, 2013, 05:45:38 PM
It seems to work pretty well now.  The min_bet goes up each time I win, and 90% of the net winnings get stashed away in a safe place:

Quote
$ php sdbot.php

starting new round; balance   1.231179 BTC; min:   0.011081 BTC; max:   1.231179 BTC
      [ wait for confirms; bet =   0.011081 BTC; confirmed =   0.002181 BTC; unconfirmed =   1.228998 BTC .................................................................... ]
  1 : Won  0; Lost  0; W:L ratio  (inf)    bet   0.011081 BTC . payout   0.021704 BTC : WIN
      [ net win:   0.010123 BTC; stashing 90% =   0.009111 BTC; total stashed =   0.009111 BTC ]

starting new round; balance   1.232192 BTC; min:   0.011090 BTC; max:   1.232192 BTC
  2 : Won  1; Lost  0; W:L ratio  (inf)    bet   0.011090 BTC . payout   0.021722 BTC : WIN
      [ net win:   0.010132 BTC; stashing 90% =   0.009119 BTC; total stashed =   0.018230 BTC ]

starting new round; balance   1.233205 BTC; min:   0.011099 BTC; max:   1.233205 BTC
  3 : Won  2; Lost  0; W:L ratio  (inf)    bet   0.011099 BTC . payout   0.000000 BTC : LOSE
  4 : Won  2; Lost  1; W:L ratio 2.00000   bet   0.022198 BTC .... payout   0.043981 BTC : WIN
      [ net win:   0.009684 BTC; stashing 90% =   0.008716 BTC; total stashed =   0.026946 BTC ]

starting new round; balance   1.233673 BTC; min:   0.011103 BTC; max:   1.233673 BTC
  5 : Won  3; Lost  1; W:L ratio 3.00000   bet   0.011103 BTC . payout   0.000000 BTC : LOSE
  6 : Won  3; Lost  2; W:L ratio 1.50000   bet   0.022206 BTC . payout   0.000000 BTC : LOSE
      [ wait for confirms; bet =   0.044412 BTC; confirmed =   0.002181 BTC; unconfirmed =   1.197183 BTC ...... ]
  7 : Won  3; Lost  3; W:L ratio 1.00000   bet   0.044412 BTC . payout   0.000000 BTC : LOSE
  8 : Won  3; Lost  4; W:L ratio 0.75000   bet   0.088824 BTC . payout   0.000000 BTC : LOSE
  9 : Won  3; Lost  5; W:L ratio 0.60000   bet   0.177649 BTC .... payout   0.355482 BTC : WIN
      [ net win:   0.008787 BTC; stashing 90% =   0.007908 BTC; total stashed =   0.034854 BTC ]

starting new round; balance   1.234552 BTC; min:   0.011111 BTC; max:   1.234552 BTC
 10 : Won  4; Lost  5; W:L ratio 0.80000   bet   0.011111 BTC . payout   0.021765 BTC : WIN
      [ net win:   0.010154 BTC; stashing 90% =   0.009138 BTC; total stashed =   0.043992 BTC ]

starting new round; balance   1.235567 BTC; min:   0.011120 BTC; max:   1.235567 BTC
 11 : Won  5; Lost  5; W:L ratio 1.00000   bet   0.011120 BTC . payout   0.000000 BTC : LOSE
 12 : Won  5; Lost  6; W:L ratio 0.83333   bet   0.022240 BTC . payout   0.000000 BTC : LOSE
 13 : Won  5; Lost  7; W:L ratio 0.71429   bet   0.044480 BTC . payout   0.088632 BTC : WIN
      [ net win:   0.009291 BTC; stashing 90% =   0.008362 BTC; total stashed =   0.052354 BTC ]

starting new round; balance   1.235996 BTC; min:   0.011124 BTC; max:   1.235996 BTC
      [ wait for confirms; bet =   0.011124 BTC; confirmed =   0.004471 BTC; unconfirmed =   1.231525 BTC .............. ]
 14 : Won  6; Lost  7; W:L ratio 0.85714   bet   0.011124 BTC .... payout   0.021791 BTC : WIN
      [ net win:   0.010167 BTC; stashing 90% =   0.009150 BTC; total stashed =   0.061505 BTC ]

starting new round; balance   1.237013 BTC; min:   0.011133 BTC; max:   1.237013 BTC
 15 : Won  7; Lost  7; W:L ratio 1.00000   bet   0.011133 BTC . payout   0.021809 BTC : WIN
      [ net win:   0.010176 BTC; stashing 90% =   0.009158 BTC; total stashed =   0.070663 BTC ]

starting new round; balance   1.238031 BTC; min:   0.011142 BTC; max:   1.238031 BTC
 16 : Won  8; Lost  7; W:L ratio 1.14286   bet   0.011142 BTC . payout   0.021827 BTC : WIN
      [ net win:   0.010185 BTC; stashing 90% =   0.009167 BTC; total stashed =   0.079830 BTC ]

starting new round; balance   1.238549 BTC; min:   0.011147 BTC; max:   1.238549 BTC
 17 : Won  9; Lost  7; W:L ratio 1.28571   bet   0.011147 BTC . payout   0.021837 BTC : WIN
      [ net win:   0.010190 BTC; stashing 90% =   0.009171 BTC; total stashed =   0.089000 BTC ]

starting new round; balance   1.239568 BTC; min:   0.011156 BTC; max:   1.239568 BTC
 18 : Won 10; Lost  7; W:L ratio 1.42857   bet   0.011156 BTC . payout   0.000000 BTC : LOSE
 19 : Won 10; Lost  8; W:L ratio 1.25000   bet   0.022312 BTC . payout   0.000000 BTC : LOSE
 20 : Won 10; Lost  9; W:L ratio 1.11111   bet   0.044624 BTC . payout   0.088921 BTC : WIN
      [ net win:   0.009328 BTC; stashing 90% =   0.008395 BTC; total stashed =   0.097395 BTC ]

starting new round; balance   1.240501 BTC; min:   0.011165 BTC; max:   1.240501 BTC
 21 : Won 11; Lost  9; W:L ratio 1.22222   bet   0.011165 BTC . payout   0.000000 BTC : LOSE
 22 : Won 11; Lost 10; W:L ratio 1.10000   bet   0.022329 BTC ... payout   0.000000 BTC : LOSE
 23 : Won 11; Lost 11; W:L ratio 1.00000   bet   0.044658 BTC . payout   0.000000 BTC : LOSE
 24 : Won 11; Lost 12; W:L ratio 0.91667   bet   0.089316 BTC . payout   0.000000 BTC : LOSE
      [ wait for confirms; bet =   0.178632 BTC; confirmed =   0.137693 BTC; unconfirmed =   0.950906 BTC .....

It should have stopped once I'd stashed 0.05 BTC of winnings, but there was a bug which meant that didn't happen.  It's fixed now.
legendary
Activity: 2940
Merit: 1330
February 04, 2013, 03:23:21 PM
I found a way of getting the true unconfirmed balance:

Code:
function get_confirmed_balance() {
    global $bitcoin;
    $unspent = 0;
    foreach ($bitcoin->listunspent(1) as $tx)
        $unspent += $tx['amount'];
    return $unspent;
}

I updated my script to use that instead, as well as fixing a couple of other bugs.
legendary
Activity: 2940
Merit: 1330
February 04, 2013, 02:25:03 PM
    BTC2 Bounty for Modding the php bot to:

    • Make the MIN_BET and MAX_BET a percentage/fraction of the current balance

    • If LOSE! use this same amount multiplied until WIN! OR MAX_BET reached

    • If WIN! send a fraction of win amount to "1XYZ1" address

    • If MAX_BET Reached, start over

    • Stop after X amount sent to "1XYZ1" address

      • OR count_won grater than XYZ2
        • OR after a WIN! and the ratio of win loses is grater than XYZ3 and a minimum of XYZ bets have been played

      Always wait for confirmed balance to avoid the larger fees.(no rush to lose everything)


    Here you go:

    https://github.com/dooglus/sdbot

    I lost about BTC1 testing it, but it seems to work pretty well.

    In the process I discovered that bitcoin's "getbalance '*' 1" lies about how much is confirmed, because it considers your change to always be confirmed, even when it isn't.  The script includes a patch to bitcoin that fixes the problem.  And if you don't want to bother rebuilding bitcoin, there's also a setting to get the script to wait for all your transactions to be confirmed each time before betting.

    My address: 135XYa4hDX8vof62UBE2zJVDwcidz52pPw[/list]
    legendary
    Activity: 2940
    Merit: 1330
    February 04, 2013, 02:43:05 AM
    I'm playing with these PHP martingale scripts.

    I see one that's doing a "bitcoind getbalance '*' 1" to work out the confirmed balance.

    When I run that, it's including change from old bets that didn't confirm yet.  If the change isn't confirmed, why's it being counted as confirmed balance?

    And - is there any (hopefully simple) way of finding out your real confirmed balance, not including unconfirmed change?

    Edit: note that the bitcoin-qt client's 'overview' tab shows "balance" and "unconfirmed", but the "unconfirmed" value doesn't include change from unconfirmed transactions you've made.  So the PHP SD bot checks if it has sufficient confirmed funds, thinks that it does, when it really doesn't, and ends up making a bet using unconfirmed change coins.

    Edit2: looks like the culprit is IsConfirmed() in wallet.h, which says:

            // If no confirmations but it's from us, we can still
            // consider it confirmed if all dependencies are confirmed
    legendary
    Activity: 2940
    Merit: 1330
    February 04, 2013, 02:40:23 AM
    and also
    rpcallowip=127.0.0.1
    rpcallowip=192.168.x.y

    Put as many of those as IP addresses you want to have RPC access to bitcoiond

    I've never needed any rpcallowip settings.  I'm guessing that localhost is allowed by default.
    legendary
    Activity: 4466
    Merit: 1798
    Linux since 1997 RedHat 4
    February 04, 2013, 02:04:00 AM
    How do I start it in server mode? I think I saw a script a while ago on it but I can't remember...

    Go to the folder with your wallet.dat and blockchain files in it.
    Edit or create bitcoin.conf
    Put these 3 lines in it:

    rpcuser=yourusername
    rpcpassword=yourpassword
    server=1
    ...
    and also
    rpcallowip=127.0.0.1
    rpcallowip=192.168.x.y

    Put as many of those as IP addresses you want to have RPC access to bitcoiond
    legendary
    Activity: 2940
    Merit: 1330
    February 04, 2013, 12:01:46 AM
    How do I start it in server mode? I think I saw a script a while ago on it but I can't remember...

    Go to the folder with your wallet.dat and blockchain files in it.
    Edit or create bitcoin.conf
    Put these 3 lines in it:

    rpcuser=yourusername
    rpcpassword=yourpassword
    server=1

    Then change the script so the user and password at the top match your bitcoin.conf:

    $btcu = array("user" => "yourusername",             // RPC Username
                "pass" =>   "yourpassword",               // RPC Password
                "host" =>   "localhost",      // RPC Hostname/IP
                "port" =>   8332);            // RPC Port

    Then restart bitcoin-qt.

    Pick something other than 'yourpassword' of course - so long as it's the same in the bitcoin.conf as in the script, it's ok.
    newbie
    Activity: 24
    Merit: 0
    February 03, 2013, 07:34:03 PM
    What do I have near the top as the ip address? I get this error right now :

    Warning: fopen(http://[email protected]:8332/): failed to open stream: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\jsonRPCClient.php on line 86


    Your bitcoin client prob need to be in server mode and listening on 127.0.0.1 which is local loopback ip addy.

    How do I start it in server mode? I think I saw a script a while ago on it but I can't remember...
    legendary
    Activity: 2072
    Merit: 1001
    February 03, 2013, 05:43:35 PM
    #99
    What do I have near the top as the ip address? I get this error right now :

    Warning: fopen(http://[email protected]:8332/): failed to open stream: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\jsonRPCClient.php on line 86


    Your bitcoin client prob need to be in server mode and listening on 127.0.0.1 which is local loopback ip addy.
    newbie
    Activity: 9
    Merit: 0
    February 03, 2013, 05:28:47 PM
    #98
      BTC2 Bounty for Modding the php bot to:


      • Make the MIN_BET and MAX_BET a percentage/fraction of the current balance

      • If LOSE! use this same amount multiplied until WIN! OR MAX_BET reached

      • If WIN! send a fraction of win amount to "1XYZ1" address

      • If MAX_BET Reached, start over

      • Stop after X amount sent to "1XYZ1" address

        • OR count_won grater than XYZ2
          • OR after a WIN! and the ratio of win loses is grater than XYZ3 and a minimum of XYZ bets have been played

        Always wait for confirmed balance to avoid the larger fees.(no rush to lose everything)

      newbie
      Activity: 24
      Merit: 0
      February 03, 2013, 12:19:13 AM
      #97
      That website is down so I downloaded a different version off of github... Guessing that will mess it up..   (Check post above)
      So I've got a good understanding of PHP but never heard of JSON. I've got everything you said. How do I make it work?  Roll Eyes



      http://bitcoin.org -> install bitcoin
      http://www.apachefriends.org/en/xampp.html -> install xampp (which includes php)

      have a read of https://en.bitcoin.it/wiki/PHP_developer_intro

      http://jsonrpcphp.org -> get jsonRPCClient.php


      the OP was aimed at coders who already have the basic dev environment set up.
      Download jsonRPCClient.php, place it in same directory.

      But don't try martingale. I lost 100BTC  Embarrassed
      newbie
      Activity: 24
      Merit: 0
      February 03, 2013, 12:16:28 AM
      #96
      What do I have near the top as the ip address? I get this error right now :

      Warning: fopen(http://[email protected]:8332/): failed to open stream: No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\jsonRPCClient.php on line 86
      vip
      Activity: 1302
      Merit: 1042
      👻
      February 03, 2013, 12:13:03 AM
      #95
      So I've got a good understanding of PHP but never heard of JSON. I've got everything you said. How do I make it work?  Roll Eyes



      http://bitcoin.org -> install bitcoin
      http://www.apachefriends.org/en/xampp.html -> install xampp (which includes php)

      have a read of https://en.bitcoin.it/wiki/PHP_developer_intro

      http://jsonrpcphp.org -> get jsonRPCClient.php


      the OP was aimed at coders who already have the basic dev environment set up.
      Download jsonRPCClient.php, place it in same directory.

      But don't try martingale. I lost 100BTC  Embarrassed
      Pages:
      Jump to: