Lazy API: Difference between revisions
Thewinator (talk | contribs) More reasons why this would be a bad idea. |
Remove awkward example. |
||
Line 1: | Line 1: | ||
For the incredibly lazy and/or incompetent web developer, | For the incredibly lazy and/or incompetent web developer, present is the lazy man's bitcoin API (copied from [http://www.bitcoin.org/smf/index.php?topic=4324.msg77187#msg77187 a forum post]): | ||
==Problem== | |||
Lazy web designer | Lazy web designer wants to use bitcoins without dealing with installing bitcoin on a server, installing a shopping cart interface, or using ugly merchant services with callbacks. | ||
==Solution for sending bitcoins== | |||
Use the [https://mtgox.com/support/tradeAPI MtGox API] | Use the [https://mtgox.com/support/tradeAPI MtGox API] | ||
==Solution for receiving bitcoins== | |||
# Input a list of bitcoin receiving addresses to your database | # Input a list of bitcoin receiving addresses to your database | ||
# Give a bitcoin address to a potential customer | # Give a bitcoin address to a potential customer | ||
Line 19: | Line 19: | ||
You could avoid having a list of addresses and reusing them if one of the wallet services someday lets you get a new address via API call, but this will work for now. | You could avoid having a list of addresses and reusing them if one of the wallet services someday lets you get a new address via API call, but this will work for now. | ||
==Risks== | |||
===External Service=== | |||
BlockExplorer is a service that is provided by a private party. There is no guarantee that the information provided by BlockExplorer matches the blockchain. There have not been any reports that BlockExplorer has reported transaction data incorrectly. | |||
===Double Spending=== | |||
A merchant is exposed to a double spending attack when recognizing a payment before it has been [[confirmed]] with a sufficient number of blocks. | |||
'''Shameless begging:''' | '''Shameless begging:''' |
Revision as of 09:40, 21 August 2011
For the incredibly lazy and/or incompetent web developer, present is the lazy man's bitcoin API (copied from a forum post):
Problem
Lazy web designer wants to use bitcoins without dealing with installing bitcoin on a server, installing a shopping cart interface, or using ugly merchant services with callbacks.
Solution for sending bitcoins
Use the MtGox API
Solution for receiving bitcoins
- Input a list of bitcoin receiving addresses to your database
- Give a bitcoin address to a potential customer
- Have the customer tell you when they have sent the coins and have at least 1 confirmation (you can choose a number higher than 1 if you are worried about double-spending)
- Check blockexplorer to see if they sent the right amount (i.e. http://blockexplorer.com/q/getreceivedbyaddress/19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH/1) - the /1 is the number of confirmations you require
- Give them what they paid for
- After a reasonable amount of time has passed, you can re-use the address for another customer
You could avoid having a list of addresses and reusing them if one of the wallet services someday lets you get a new address via API call, but this will work for now.
Risks
External Service
BlockExplorer is a service that is provided by a private party. There is no guarantee that the information provided by BlockExplorer matches the blockchain. There have not been any reports that BlockExplorer has reported transaction data incorrectly.
Double Spending
A merchant is exposed to a double spending attack when recognizing a payment before it has been confirmed with a sufficient number of blocks.
Shameless begging:
If this info is useful to you, please consider a donation: 19hMEAaRMbEhfSkeU4GT8mgSuyR4t4M6TH
Thanks to theymos for making changes to blockexplorer.com to make it even easier to do this. You can support blockexplorer.com by donating to 1Cvvr8AsCfbbVQ2xoWiFD1Gb2VRbGsEf28