lulzplzkthx (OP)
|
|
April 19, 2011, 01:47:24 PM Last edit: November 15, 2015, 07:52:53 AM by lulzplzkthx |
|
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.meWARNING: 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 GithubYou 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. 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
|
|
|
|
Raoul Duke
aka psy
Legendary
Offline
Activity: 1358
Merit: 1002
|
|
April 19, 2011, 02:20:30 PM |
|
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 Thanks a lot!
|
|
|
|
lulzplzkthx (OP)
|
|
April 19, 2011, 02:28:58 PM |
|
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 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
Activity: 224
Merit: 10
|
|
April 19, 2011, 02:42:33 PM |
|
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 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
Activity: 1358
Merit: 1002
|
|
April 19, 2011, 02:46:55 PM Last edit: April 19, 2011, 03:03:13 PM by psy |
|
Yeah, you forgot the cron job 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; ?? I'm asking because i still havent installed it, was just giving the code a quick glance. btw, Nice touch, using phpbb templating engine 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
Activity: 224
Merit: 10
|
|
April 19, 2011, 02:51:01 PM |
|
Yeah, you forgot the cron job 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; ?? I'm asking because i still havent installed it, was just giving the code a quick glance. btw, Nice touch, using phpbb templating engine 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
Activity: 1358
Merit: 1002
|
|
April 19, 2011, 03:03:27 PM |
|
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...
|
|
|
|
jimbo77
Member
Offline
Activity: 224
Merit: 10
|
|
April 19, 2011, 03:05:54 PM |
|
After checking the wiki looks like there already is some lotteries. BitLotto.com and TAABL
|
|
|
|
jimbo77
Member
Offline
Activity: 224
Merit: 10
|
|
April 19, 2011, 03:07:53 PM |
|
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... 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
Activity: 1358
Merit: 1002
|
|
April 19, 2011, 03:09:35 PM |
|
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
|
|
|
|
lulzplzkthx (OP)
|
|
April 19, 2011, 04:14:06 PM |
|
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
Activity: 4256
Merit: 1208
I support freedom of choice
|
|
April 20, 2011, 11:52:24 AM Last edit: April 20, 2011, 12:05:37 PM by Joozero |
|
I'm testing it. Added line 186 on index.php: 'COST' => $ticket_cost Now there is the dynamic cost to the waiting.html 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 Thank you for sharing this, it's really useful!
|
|
|
|
lulzplzkthx (OP)
|
|
April 20, 2011, 12:41:41 PM |
|
I'm testing it. Added line 186 on index.php: 'COST' => $ticket_cost Now there is the dynamic cost to the waiting.html 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 Thank you for sharing this, it's really useful! Thanks for pointing out the bug, I have updated the topic with a new link with the COST added to the waiting page. If you use it and find it useful, feel free to donate.
|
|
|
|
HostFat
Staff
Legendary
Offline
Activity: 4256
Merit: 1208
I support freedom of choice
|
|
April 21, 2011, 02:07:29 PM |
|
I added some modifications https://www.wuala.com/Slyck/bitcoin/lottery_V0.1_mod_by_Joozero.7z/?key=G0vvFcXPtnDzI'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 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 ( they just have to visit the page ) Please, can you give a look?
|
|
|
|
lulzplzkthx (OP)
|
|
April 21, 2011, 02:23:01 PM |
|
I added some modifications https://www.wuala.com/Slyck/bitcoin/lottery_V0.1_mod_by_Joozero.7z/?key=G0vvFcXPtnDzI'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 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 ( 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
|
|
April 27, 2011, 12:50:12 AM |
|
if anyone want's to see this in action, i'v set up a test-lottery on http://fxnet.co.cc/lotterydidnt 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 mysql i, so (for testing) it's set up on a different server. seems to work alright so far.
|
|
|
|
bitlotto
|
|
April 27, 2011, 01:11:24 AM |
|
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
|
|
April 27, 2011, 01:14:14 AM |
|
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
|
|
April 27, 2011, 01:20:02 AM |
|
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
|
|
April 27, 2011, 02:01:56 AM |
|
that's true i guess, but people would notice sooner or later if no *real player* wins and start complaining.
|
|
|
|
|