I would like to build an online wallet service. I thinks it will be easy to implement all the functionalities if I go with Bitcoind. Here is a possible workflow:
New user with email
[email protected]
can obtain a new account (in Bitcoind) with new address by callinggetnewaddress [email protected]
We can then start polling
listsinceblock xxx
to get all new transactions. If we receive a new incoming transaction, storetxid
in database, then iteratively callgettransaction txid
on all unconfirmed transactions. When the number of confirmations are bigger than a certain threshold, credit the account in database, then callmove [email protected] safe
, just to make the next step easier.When
safe
account exceeds say 50BTC, send them to offline wallet.When user wants to withdraw, refill
safe
if necessary, send the coins fromsafe
, and update user's balance in the database.
However, in all the related questions I've read, most people say Bitcoind won't scale. Even the Bitcoin wiki says so. Now, if we are only to use the JSONRPC to interface the network, I can imagine the following workflow:
We generate say 1M addresses in database. When user signs up or require new address, we assign one address to them.
We enable
blocknotify
to get new block hashblkhash
.Call
getblock blkhash
to get all transaction hashes in the new block.Call
getrawtransaction txid
to see whether we received an incoming transaction to our addresses. If so, keep thetxid
and keep pollinggettransaction txid
to update the confirmation number.Call
signrawtransaction
,sendrawtransaction
to move funds to offline wallet.
My questions are,
- Do you think my proposals are reasonable?
What are the nuances in the operations above? For example,
- by moving all funds to one account and then send money, does that count as one transaction or one transaction for each account? Are transaction fees the same?
- when doing
getrawtransaction
, in thevout
array, each object represents a destination, but each of them has anaddresses
array. There are cases where it contains multiple addresses. Does it mean it's a "multisig" transaction? Or is it related toreqSigs
field? How do we handle such cases?
I've read following questions, but didn't find my answer:
Does the original Bitcoin client scale to contain millions of addresses?
Bitcoin Client API-RPC: Efficient way to list transactions from a list of addresses
Please help.. Thank you very much!