Bitcoin Forum
May 11, 2024, 12:39:36 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitnoind- PHP user handling.  (Read 938 times)
Dumbo (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
January 24, 2014, 11:13:15 PM
 #1

I am trying to develop a php web application (a game, and not a gambling site) where users can make in-game purchases. Now if I am understanding it right, The architecture (using bitcoind and Json-rpc api) should be:

1. When a new user registers - generate a new address for the new user: $bitcoin->getnewaddress("username");

2. Store that wallet address for later use in my DB.

3. Display that address and let a user send bitcoins to that address.

3. Check the balance of that address using the  $bitcoin->getbalance($username,0)  for unonfirmed balance  and getbalance($username,6) confirmed balance.
 
4. Now I can let the user buy my in-game items and use $bitcoin->move($useraddress, $myaddress, $amount) to debit his account and give him the stuff he needs.


Questions:
1. Does this sound about right?  Or am I completely off here!
2. How long does it take for the unconfirmed balance to show up?  [$bitcoin->getbalance($username,0)]
3. $bitcoin->move($useraddress, $myaddress, $amount)  is a change of bitcoins between addresses within my wallet, so this should be offchain and instantaneous, right?
4.  How can some gambling dice sites like coinroll.it ( https://bitcointalk.org/index.php?topic=191176.0) accept unconfirmed transactions and lets  people play instantly? are they just taking the risk or there is something that I am not aware of.
5. How can I test out my bitcoind/php application with testnet? Anyone has any experience of this?
6. Suggestions on Security are welcome...

I am going to make parts of my code open source when I figure this shit out.

1715431176
Hero Member
*
Offline Offline

Posts: 1715431176

View Profile Personal Message (Offline)

Ignore
1715431176
Reply with quote  #2

1715431176
Report to moderator
1715431176
Hero Member
*
Offline Offline

Posts: 1715431176

View Profile Personal Message (Offline)

Ignore
1715431176
Reply with quote  #2

1715431176
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715431176
Hero Member
*
Offline Offline

Posts: 1715431176

View Profile Personal Message (Offline)

Ignore
1715431176
Reply with quote  #2

1715431176
Report to moderator
1715431176
Hero Member
*
Offline Offline

Posts: 1715431176

View Profile Personal Message (Offline)

Ignore
1715431176
Reply with quote  #2

1715431176
Report to moderator
1715431176
Hero Member
*
Offline Offline

Posts: 1715431176

View Profile Personal Message (Offline)

Ignore
1715431176
Reply with quote  #2

1715431176
Report to moderator
elbandi
Hero Member
*****
Offline Offline

Activity: 525
Merit: 529


View Profile
January 24, 2014, 11:23:02 PM
 #2

1. if a user can buy one time, it's ok. but if someone can buy A/B/C/etc items, use different address (so you can track what did he buy and what not. and use user_id !
3. 3-4 confirmation is need for avoid double spell, thats 1 hour (~15 min is btc blocktime)
4. risk
5. run the daemon with -testnet parameter
6. run the main (=$myaddress) node at different server. and the purchase checker nodes send the money to this server.

Elbandi
Dumbo (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
January 24, 2014, 11:59:50 PM
 #3

Thanks for the response mate!

1. So you are suggesting, I generate different addresses for the same user everytime he wants to deposit bitcoin in my web app? Is there a reason for that (security may be?) why can't he just deposit how ever much bitcoin he wants in his generated address, and I keep deducting the right amount whenever he makes a purchase. That seems less complicated, doesn't it?

3. Thanks!

4. Thought so!

5. I will have to play with it before I screw up with real money

6. Ah thank you!  - but the moment I use move between two wallets ...doesn't that become "one the blockchain" so to speak? not that it is terribly important for me to be offchain.
thenoblebot
Sr. Member
****
Offline Offline

Activity: 364
Merit: 252


View Profile
January 25, 2014, 07:48:23 AM
 #4

Using the -testnet parameter aren't you supposed to mine for testnet coins first ? or are they just available directly .. im notsure about that one
Shahrukh
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile WWW
January 25, 2014, 11:51:15 AM
 #5

Thanks for the response mate!

1. So you are suggesting, I generate different addresses for the same user everytime he wants to deposit bitcoin in my web app? Is there a reason for that (security may be?) why can't he just deposit how ever much bitcoin he wants in his generated address, and I keep deducting the right amount whenever he makes a purchase. That seems less complicated, doesn't it?

3. Thanks!

4. Thought so!

5. I will have to play with it before I screw up with real money

6. Ah thank you!  - but the moment I use move between two wallets ...doesn't that become "one the blockchain" so to speak? not that it is terribly important for me to be offchain.


Ref point number 1 if this is the first time user purchasing something then generate a new address and save that address in database corresponding to his username, he comes back to make another purchase check the database if that username have any bitcoin address allocated to him if yes show him the same address otherwise generate a new one.

P.S wheres the point not 2 Huh Do you count like 1,3,4,5,6,7, and so on ?

I turned everyone down Sad Sorry for that
Dumbo (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
January 25, 2014, 11:11:23 PM
 #6

haha, was responding to elbandi ...he did not bring up 2

Using the -testnet parameter aren't you supposed to mine for testnet coins first ? or are they just available directly .. im notsure about that one

I figured, I would use some testnet faucet to get hold of testnet BTC somehow. I have not really thought it through.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!