Bitcoin Forum
December 07, 2016, 06:38:26 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1] 2 3 »  All
  Print  
Author Topic: [PHP] BitLuck Lottery Script - Released under MIT License  (Read 26765 times)
lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
April 19, 2011, 01:47:24 PM
 #1

11/15/2015 - BitLuck is deprecated and I've removed the public source for both security and licensing reasons. If you'd really like it for some reason, email me at contact@johnmaguire.me

WARNING: A vulnerability has been pointed out by PhilG in this script and it should not be used. This was an example script I made when I was 15. Additionally, I don't remember anything about this and don't plan to fix it. Feel free to fork it and work on it if you'd like. I'm not even sure it works anymore.

I created a lottery script which automates the process of payments and payouts, and I thought I'd open-source it since I'm not using it anyway... if you like it, please think about donating to me, my donation address is in my signature.

I am posting in this forum, as that's where I posted my initial thread about BitLuck. Mods: feel free to move it.

Version 0.3 is hosted only on Github. BitLuck on Github
You can download v0.2 here.
If for some reason you still want v0.1, you can find it here.

Changelog:

Version 0.2 - Added cost setting to waiting.html (used to be static 1 BTC.)
Version 0.1 - Initial Script

Requirements:

  • PHP 5
  • MySQLi for PHP
  • cURL for PHP
  • JSON for PHP

Installation instructions:

1. Create a database on your MySQL server and run lottery.sql on it.
2. Run "bitcoind" with either the -rpcuser and -rpcpass options, or with them specified in your bitcoin.conf
3. Type at the command prompt, to generate the lottery pool account (you don't need to do anything with the output): bitcoind getaccountaddress "Lottery Pool"
3. Edit config.inc.php, and update the $rpc_* variables to match your RCP server settings, the $sql_* variables to match your MySQL server settings, the owner's key, fee, draw time, and ticket cost.
4. Move give_prize.php outside of the webroot.
5. Setup cron, or a similar service to run give_prize.php at the time you wish the prize to be drawn.
6. Huh
7. Profit!

Let me know how it goes, and if there are any bugs, I'll attempt to fix them. As this isn't an ongoing project, I'm not using Git or another source versioning system as there shouldn't be too many changes, only bug fixes.

DISCLAIMER: I offer no warranty, and if anything goes wrong, it's not my fault. Please also note that this is NOT an example of my best work, rather a quick thing I hacked together in an hour or two when learning about the Bitcoin API.

I hope this helps someone. If you'd like to send a donation for my efforts, please use this address: 1B7aTxrcaEVopuqrqidTQMxE9mpDUZRwAb

1481135906
Hero Member
*
Offline Offline

Posts: 1481135906

View Profile Personal Message (Offline)

Ignore
1481135906
Reply with quote  #2

1481135906
Report to moderator
1481135906
Hero Member
*
Offline Offline

Posts: 1481135906

View Profile Personal Message (Offline)

Ignore
1481135906
Reply with quote  #2

1481135906
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481135906
Hero Member
*
Offline Offline

Posts: 1481135906

View Profile Personal Message (Offline)

Ignore
1481135906
Reply with quote  #2

1481135906
Report to moderator
1481135906
Hero Member
*
Offline Offline

Posts: 1481135906

View Profile Personal Message (Offline)

Ignore
1481135906
Reply with quote  #2

1481135906
Report to moderator
1481135906
Hero Member
*
Offline Offline

Posts: 1481135906

View Profile Personal Message (Offline)

Ignore
1481135906
Reply with quote  #2

1481135906
Report to moderator
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
April 19, 2011, 02:20:30 PM
 #2

Well, if you don't mind i'll give it a chance.
Just need to find a nice domain for it and give it a warm fuzzy look  Tongue

Thanks a lot!

lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
April 19, 2011, 02:28:58 PM
 #3

Well, if you don't mind i'll give it a chance.
Just need to find a nice domain for it and give it a warm fuzzy look  Tongue

Thanks a lot!

No problem! You may want to do a bit of testing first to make sure entries are being counted, etc. I was unable to do much testing as I have only had a total of .11 BTC in my whole time with Bitcoin (.05 BTC right now.) I think it works, the logic is there, and when I use static variables it seems to input correctly, but I'm not 100% sure it'll detect payments correctly.

Also, please check the initial post as I forgot one step in the installation instructions.

jimbo77
Member
**
Offline Offline

Activity: 78


View Profile
April 19, 2011, 02:42:33 PM
 #4

Well, if you don't mind i'll give it a chance.
Just need to find a nice domain for it and give it a warm fuzzy look  Tongue

Thanks a lot!
Sounds interesting. How are you going to make sure the players can see you didn't just pick someone and alter the code?
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
April 19, 2011, 02:46:55 PM
 #5

Yeah, you forgot the cron job Smiley

Can I use decimals on the ticket cost?
Now it shows
 /* Ticket cost, in BTC */
$ticket_cost = 1;

can I change it to
/* Ticket cost, in BTC */
$ticket_cost = .01;

Huh??

I'm asking because i still havent installed it, was just giving the code a quick glance.

btw, Nice touch, using phpbb templating engine Wink

Thanks

PS: Won't players get a little "suspicious/fearful" about the winner being chosen randomly by using a sql query instead it being chosen in a more open way?

jimbo77
Member
**
Offline Offline

Activity: 78


View Profile
April 19, 2011, 02:51:01 PM
 #6

Yeah, you forgot the cron job Smiley

Can I use decimals on the ticket cost?
Now it shows
 /* Ticket cost, in BTC */
$ticket_cost = 1;

can I change it to
/* Ticket cost, in BTC */
$ticket_cost = .01;

Huh??

I'm asking because i still havent installed it, was just giving the code a quick glance.

btw, Nice touch, using phpbb templating engine Wink

Thanks

PS: Won't players get a little "suspicious/fearful" about the winner being chosen randomly by using a sql query instead it being chosen in a more open way?

That's what I was wondering. What's to stop the person from just picking a winner.
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
April 19, 2011, 03:03:27 PM
 #7

Sounds interesting. How are you going to make sure the players can see you didn't just pick someone and alter the code?

Yeah, was thinking the same myself. Maybe time to find some other way to pick the winner, using some formula to transform wallet addresses in numbers.

But you know, it runs automatically, even sending the prize, so i would have to be very quick to change the winner just like that when it happens.
I suspect the whole script to choose the winner and send the prize doesn't take more than a couple miliseconds to execute.

I dunno, honnestly. I'll build the site the same way. the bet will only be 10cents. If someone wants to try it, great, if not, great the same way.
I like putting up quick and dirty websites up. Better to buy domains and have something there than leaving them empty. You don't want to know how many parked domains i have... really... Cheesy

jimbo77
Member
**
Offline Offline

Activity: 78


View Profile
April 19, 2011, 03:05:54 PM
 #8

After checking the wiki looks like there already is some lotteries. BitLotto.com and TAABL
jimbo77
Member
**
Offline Offline

Activity: 78


View Profile
April 19, 2011, 03:07:53 PM
 #9

Sounds interesting. How are you going to make sure the players can see you didn't just pick someone and alter the code?

Yeah, was thinking the same myself. Maybe time to find some other way to pick the winner, using some formula to transform wallet addresses in numbers.

But you know, it runs automatically, even sending the prize, so i would have to be very quick to change the winner just like that when it happens.
I suspect the whole script to choose the winner and send the prize doesn't take more than a couple miliseconds to execute.

I dunno, honnestly. I'll build the site the same way. the bet will only be 10cents. If someone wants to try it, great, if not, great the same way.
I like putting up quick and dirty websites up. Better to buy domains and have something there than leaving them empty. You don't want to know how many parked domains i have... really... Cheesy

I'm not saying you will but you could just not use the script and then make a script that pays one of your accounts. You would win all the time and no one can see what's happening behind the scenes.
Raoul Duke
aka psy
Legendary
*
Offline Offline

Activity: 1442



View Profile
April 19, 2011, 03:09:35 PM
 #10

I'm not saying you will but you could just not use the script and then make a script that pays one of your accounts. You would win all the time and no one can see what's happening behind the scenes.

No, I probably will be winning all the time! but thats because i'll probably be the only one playing Cheesy

lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
April 19, 2011, 04:14:06 PM
 #11

Yes, you should be able to use decimals in the ticket price. However, that piece of code is untested (I originally had it hardcoded to 1 BTC, and changed it when I uploaded it here,) so let me know how it goes.

Also: As for the MySQL RAND() it was just the easiest, quickest way to quickly grab a random entry from the table. If you would like to do it some other way, be my guest. However, I'm not sure how open you can really make it, since no matter how you do it, the code will still be on the server, out of user's eyes?

I don't know though.

HostFat
Staff
Legendary
*
Offline Offline

Activity: 2296


I support freedom of choice


View Profile WWW
April 20, 2011, 11:52:24 AM
 #12

I'm testing it.

Added line 186 on index.php:
'COST' => $ticket_cost
Now there is the dynamic cost to the waiting.html
Smiley

XAMPP 1.7.4 for Windows ( windows 7 x64 )

It seems that there is a bug. ( I'll check it later ... )
I counted 20 times just one entry ( so it collected 20 entries even if I sent only one time a single bitcoin )

EDIT:
Ok, It's working perfectly, my mistake Tongue


Thank you for sharing this, it's really useful! Cheesy


Eternity Wall: Messages lasting forever - The Rock Trading (ref): A good exchange / gateway Ripple, with support for multisig, since 2007. 
https://bitcointa.lk: Bitcointalk backup if offline - Bitcoin Foundation Italia - Blog: http://theupwind.blogspot.it
lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
April 20, 2011, 12:41:41 PM
 #13

I'm testing it.

Added line 186 on index.php:
'COST' => $ticket_cost
Now there is the dynamic cost to the waiting.html
Smiley

XAMPP 1.7.4 for Windows ( windows 7 x64 )

It seems that there is a bug. ( I'll check it later ... )
I counted 20 times just one entry ( so it collected 20 entries even if I sent only one time a single bitcoin )

EDIT:
Ok, It's working perfectly, my mistake Tongue


Thank you for sharing this, it's really useful! Cheesy



Thanks for pointing out the bug, I have updated the topic with a new link with the COST added to the waiting page. Smiley

If you use it and find it useful, feel free to donate. Tongue

HostFat
Staff
Legendary
*
Offline Offline

Activity: 2296


I support freedom of choice


View Profile WWW
April 21, 2011, 02:07:29 PM
 #14

I added some modifications Smiley

https://www.wuala.com/Slyck/bitcoin/lottery_V0.1_mod_by_Joozero.7z/?key=G0vvFcXPtnDz

I'm not an expert php developer, neither sql ... so I hope that you can take it as a simple idea.
If you like it, I'm sure that you will  make a better one Wink

I did it to avoid the point 5.
( 5. Setup cron, or a similar service to run give_prize.php at the time you wish the prize to be drawn. )

Now it auto-restart simple with the help of users Grin ( they just have to visit the page )

Please, can you give a look?



Eternity Wall: Messages lasting forever - The Rock Trading (ref): A good exchange / gateway Ripple, with support for multisig, since 2007. 
https://bitcointa.lk: Bitcointalk backup if offline - Bitcoin Foundation Italia - Blog: http://theupwind.blogspot.it
lulzplzkthx
Sr. Member
****
Offline Offline

Activity: 322



View Profile WWW
April 21, 2011, 02:23:01 PM
 #15

I added some modifications Smiley

https://www.wuala.com/Slyck/bitcoin/lottery_V0.1_mod_by_Joozero.7z/?key=G0vvFcXPtnDz

I'm not an expert php developer, neither sql ... so I hope that you can take it as a simple idea.
If you like it, I'm sure that you will  make a better one Wink

I did it to avoid the point 5.
( 5. Setup cron, or a similar service to run give_prize.php at the time you wish the prize to be drawn. )

Now it auto-restart simple with the help of users Grin ( they just have to visit the page )

Please, can you give a look?




Nice setup. I considered incorporating this into the original, and would add your mod to it, but there's always a chance it could take a long time for a user to view the page, and the funds may not be sent for quite some time. I decided to use the cron as it insures they will be sent on time.

~lulz

BitLex
Hero Member
*****
Offline Offline

Activity: 588


View Profile WWW
April 27, 2011, 12:50:12 AM
 #16

if anyone want's to see this in action,
i'v set up a test-lottery on http://fxnet.co.cc/lottery

didnt change much, except for some of the text.
i had some troubles to get it to work on my main-server due to the lack of mysqli,
so (for testing) it's set up on a different server.

seems to work alright so far.


bitlotto
Hero Member
*****
Offline Offline

Activity: 672


BitLotto - best odds + best payouts + cheat-proof


View Profile WWW
April 27, 2011, 01:11:24 AM
 #17

Interesting! How do the players keep track of who played/won? (It's cool as it is, I'm just worried lot's of scammers setting up something that looks just like it with the exception that it always pays to one of their own plays instead of using random like it should. I guess you have to trust the operator a little bit more I guess...)

*Next Draw Feb 1*  BitLotto: monthly raffle (0.25 BTC per ticket) Completely transparent and impossible to manipulate who wins. TOR
TOR2WEB
Donations to: 1JQdiQsjhV2uJ4Y8HFtdqteJsZhv835a8J are appreciated.
BitLex
Hero Member
*****
Offline Offline

Activity: 588


View Profile WWW
April 27, 2011, 01:14:14 AM
 #18

yeah, i also thought about that,
have to add some stats/overview of entered addresses and maybe last winners or such,
should be no big deal.

bitlotto
Hero Member
*****
Offline Offline

Activity: 672


BitLotto - best odds + best payouts + cheat-proof


View Profile WWW
April 27, 2011, 01:20:02 AM
 #19

yeah, i also thought about that,
have to add some stats/overview of entered addresses and maybe last winners or such,
should be no big deal.
Except proving that you didn't just pick whatever winner you wanted. (I guess people will just have to trust you.)

*Next Draw Feb 1*  BitLotto: monthly raffle (0.25 BTC per ticket) Completely transparent and impossible to manipulate who wins. TOR
TOR2WEB
Donations to: 1JQdiQsjhV2uJ4Y8HFtdqteJsZhv835a8J are appreciated.
BitLex
Hero Member
*****
Offline Offline

Activity: 588


View Profile WWW
April 27, 2011, 02:01:56 AM
 #20

that's true i guess,
but people would notice sooner or later if no *real player* wins and start complaining.

Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!