Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: MegaCookie on January 14, 2014, 06:26:16 PM



Title: Bitcoin API receiving payments
Post by: MegaCookie on January 14, 2014, 06:26:16 PM
Hello,

I want to make a similar function like Blockchain's receive payments API but with my own Bitcoin server (https://blockchain.info/api/api_receive). It should generate a new Bitcoin address for the user and if they send the BTC to that address it will notify the user of the amount of confirmations. When the transaction has 6 confirmations then notify the user and move the received Bitcoins to the main account. They can also use the same Bitcoin address again.

I was thinking of this:
1. Generate a Main Bitcoin address for the application and label it.
2. Generate a Bitcoin address for the user: getnewaddress(account=UniqueUserID)
3. In a 5min cronjob check all the transactions for the User's Bitcoin accounts and if an account receives BTC than store the amount&transactionID and the account etc.: listtransactions()
4. In the same cronjob check for confirmations and notify it to the user: gettransaction(TransactionID)
5. If there are 6 confirmations then notify the user and move the received Bitcoins to the main account: move(UniqueUserID, MainBTCAccount, ReceivedBitcoins, minconf=6, comment='Transaction from:'.UniqueUserID)

So will this work?
And do I need a cronjob in step 5? or is one time calling the move command enough?

Thanks in advance!


Title: Re: Bitcoin API receiving payments
Post by: piggybank on January 14, 2014, 09:02:22 PM
Probably.... but are you sure you really want to be generating a new address to send bitcoins to and store the private key on a server connected to the internet? What happens if the server gets hacked and you lose your wallet?


Title: Re: Bitcoin API receiving payments
Post by: MegaCookie on January 14, 2014, 09:36:24 PM
Yea that's a good problem but what should you suggest if I need to send Bitcoins as well?


Title: Re: Bitcoin API receiving payments
Post by: piggybank on January 14, 2014, 09:45:53 PM
Store the majority of the bitcoins offline. Only keep a small amount online. Only transfer to the online wallet when the balance gets low.

Otherwise your really going to be lining yourself up to be the next bad bitcoin news when you get hacked and lose the lot.