Post
Topic
Board Web Wallets
Re: List of Bitcoin blockchain APIs
by
Tjopper
on 02/02/2015, 17:57:46 UTC
i. https://blockchain.info/api/api_send

ii. https://blockchain.info/api/api_receive

If you are offering similar alternative, can you please point me to the specific links on https://www.blocktrail.com/api/docs ? Conversion to any FIAT is not the requirement. bc.i does not offer it either.

The main issue with blockchain.info (and many other APIs) is that they have direct access to your coins. It's originally a webwallet where your password never leaves your browser, but their API requires you to provide their server with the password and thus gives them custody of your coins.
You'll never need to do that with BlockTrail because the transactions are created and signed on the client side using the SDK, and are then co-signed and broadcasted via BlockTrail.

The blockchain.info receive API actually makes the bitcoins go to their own address first before the coins come to you, again, giving them full custody of your coins.
This is done for various technical reasons and are considered bad practice nowadays - the main reason being that you can't monitor your own addresses for transactions and that they have a max amount of addresses (which is because you need to backup every private key for each address).

The Blocktrail Wallet API is a HD Wallet, so you can have unlimited addresses, create a new one every time you need to receive coins (as best practices dictate) and because of the HD 'magic' you never even need to create new backups.
And we also have 'webhooks' which allow you to get notifications ( we send data to your server using a HTTP POST ) when your addresses receive transactions.

Initialize SDK
Code:
$this->client  = new BlocktrailSDK($yourAPIKey, $yourAPISecret, "BTC", $testnetTrueOrFalse));


Create a wallet
Code:
list($wallet, $primaryMnemonic, $backupMnemonic, $blocktrailPublicKeys) = $this->client->createNewWallet($yourWalletID, $yourWalletPassword);

Setup transaction notifications
Code:
$wallet->setupWebhook('https://example.com/receive/wallet/transactions/notifications');

Receive a transaction
Code:
$wallet = $this->client->initWallet($yourWalletID, $yourWalletPassword);
$address = $wallet->getNewAddress();
you'll be automatically subscribed to notifications on these new addresses

Send a transaction
Code:
$wallet = $this->$client->initWallet($yourWalletID, $yourWalletPassword);
$txHash = $wallet->pay([$bitcoinAddress1 => $amount1, $bitcoinAddress2 => $amount2, /* .... */]);

Get wallet balance
Code:
$wallet = $this->client->initWallet($yourWalletID, yourWalletPassword);
list($confirmedBalance, $unconfirmedBalance) = $wallet->getBalance();

If you need any help feel free to email us or join us on #blocktrail on irc.freenode.net !