7

I have a website which enables users to trade information for a price. The price is calculated based on an algorithm within the website. The website charges a percentage per transaction for the service.

I would like to know how to go about enabling the users to perform the transaction using bitcoins as an alternative to credit card transactions.

The website is coded in Ruby on Rails, I am currently investigating bitcoind, and the bitcoin-ruby library but I'm feeling a little overwhelmed with new technology.

Could someone please explain how I might go this? I'm looking for an overview of the process.

For example: The website connects to a bitcoind server, and creates a unique wallet per user, then to provide transactions the users will need to transfer coins from somewhere to their personal website wallet. When the user wishes to purchase information from another user, the website then connects to the bitcoind and creates a transaction between the two wallets, and creates a second transaction to cover the website commision.

I've made up this example from my basic understanding of the system - but what security issues are involved in this. Will this approach work, or is there a better way?

6
  • 1
    It may help you to think about the problem a little differently. All you really need to do is process deposits and withdrawals. Then you can track bitcoin balances in your own database. When someone does a deposit, you bump their balance in your database (and the bitcoins go in your wallet). Moving coins from one user to another is just done in your database. When someone does a withdrawal, you pay them from your wallet to the withdrawal address they specify. (Whatever you do though, don't forget about security!) Jul 11, 2012 at 7:04
  • OT: "enables users to trade information for a price. The price is calculated based on an algorithm within the website" <-- why don't you let the users set the price?
    – o0'.
    Jul 11, 2012 at 10:34
  • @Lohoris: That's probably what he does. For example, if he uses an auction, that's an algorithm within the website that lets the users set the price. Jul 12, 2012 at 9:17
  • @DavidSchwartz If I understand you correctly, the website only has one wallet and the "portion" of the wallet owned by the user is stored in the database? Sounds interesting, and probably a simpler implementation - thanks!!
    – ktec
    Aug 5, 2012 at 16:01
  • @Lohoris the value of information is based on users reputation - clearly I'm not going to allow users to directly set their own reputation.
    – ktec
    Aug 5, 2012 at 16:01

2 Answers 2

4

You need to set up bitcoind and look into accounts. If you want users to be able to pay each other in the system for anything, it is quite easy to move Bitcoins around without creating transactions simply by calling the move API. After that you just need to add the options for users to put money into their accounts and withdraw them, and you are set.

Can't really help you with Ruby-specific things though, as I don't know the language.

1
  • From the wiki: Account Weaknesses ... Wallet backups are an issue; ...a backup must be done every time an address is associated with an account and every time the 'move' command is used. ..does not scale up to thousands of accounts with tens of thousands of transactions... It is awkward at best to keep the bitcoin-maintained Berkely DB wallet database and the application database backed up and synchronized at all times. Sep 16, 2014 at 3:54
1

The satoshi bitcoin client doesn't currently support multiple wallets.

The way that website backends typically interact with bitcoin is through the bitcoind daemon.

Here's a brief overview of how you can handle the interaction:

When a customer wants to deposit bitcoins with you, run bitcoind getaccountaddress <userid> to get a deposit address and associate it with their userid.

To see which users have sufficiently confirmed deposits, run bitcoind listaccounts <conf> where conf is the number of confirmations you require. That will give you the balance of each user's account only considering deposits with enough confirmations.

For each deposit once it's confirmed enough, use bitcoind move <userid> admin <amount> to move the deposit from the user's bitcoin account to an account called admin and process the deposit (the same as you do once a credit card payment is received - send them the goods, or whatever). The move will stop the deposit showing up again next time you run listaccounts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.