使用 Blockchain 的服务进行比特币交易
Use blockchain bitcoin service to transfer bitcoins
Wallet api
1 | https://blockchain.info/merchant/$guid/payment |
Request tips:
The My Wallet API provides a simple interface Merchants can use interact with their wallet. Blockchain.info will decrypt the wallet on our server manipulate it as necessary and re-save. HTTP GET and POST are supported. However, if a POST request is sent without “Content-Type: application/x-www-form-urlencoded” header, some endpoints may not work correctly.
/payment
1 | https://blockchain.info/merchant/59fee004-0115-4861-8e4a-7f8af3ba31fb/payment |
returns:
1 | { |
Then we have to enable API access from the Account Settings on Blockchain.
1 | [Account Settings] -> [IP Restrictions] -> [Enable Api Access] |
Then we call the API, returns:
1 | { |
From our Email inbox, we got a alert Authorize API access attempt
, we only have to click the link to get the access continue.
Otherwise, user can add the server ip to their account IP white list.
From the 1st December 2014, in order to use this API, access must be explicitly enabled, and all client ip addresses whitelisted by the wallet owner. Manage access in [Account Settings] -> [IP Restrictions]. Wallets created via the Create Wallet API can bypass this by including the same API key used to create the wallet, in all requests.
Then we update our request to this form(filled some blank parameters):
1 | https://blockchain.info/merchant/a4bde787-3512-4b68-a669-91771dff514c/payment |
Of course, got an ‘error’:
1 | { |
That’s it!
Transfer real bitcoins
Next, charge a few bitcoins to my wallet, then transfer 100฿ to another wallet.
API call finished, returns:
1 | { |
Transfer process seems to be failed
But the target wallet didn’t get the money.
Check the Blockchain dashboard, it shows:
Unconfirmed Transaction!
Thus, I need to confirm this transaction.
For the exactly meaning of confirm, I checked the transaction I transfered from LocalBitcoins to Blockchain, it shows 7 Confirmations
. So I think it’s some kind of p2p server confirmation. Maybe not managed by myself.
After over 20 minutes, it still not confirmed.
Transfer some bitcoins to another account again
In the meantime, I did it again, to a different wallet(at Coinbase, 200 bit):
1 | { |
YES, That’s because my previous transaction was still unconfirmed.
As a note, php script here:
1 |
|
Bitcoins transfer was succeeded a hour ago
Finally, after a couple of hours, I noticed the message there: +68 minutes to confirm, That means the transfer finally succeeded.
1 | 06/18/2015 19:17 0.000002 1E6Ki2WdWzDKng35hohQmmuTG1yfnMd3QF |
Too slow to me, I blamed this on the influence of LocalBitcoins™, too small to be noticed ;p