nodejs bitcoin api

The Blockchain Wallet API provides a simple interface Merchants can use to programmatically interact with their wallet.To use this API, you will need to run small local service which be responsible for managing your Blockchain Wallet.Your application interacts with this service locally via HTTP API calls.Click here for complete setup instructions on GitHub.CryptoCoinJS is a JavaScript project that helps you to interface with many of the crypto currencies such as Bitcoin, Litecoin, Dogecoin, and more.Most of the modules are fully compatible with the browser and Node.js.Naturally, the modules that interface directly with peer nodes won't run in the browser.We believe in the Node.js and UNIX philosophy - the idea of building small components that do one thing and do it well.Writing software in this manner allows individuals to use and contribute much more effectively than writing one monolithic library.We believe that people are more important than code and therefore it's critical to write code that is easy to read, document each module with the API and examples, and that code is the enemy 1 2.
We believe that writing tests is one of the best ways to communicate expectations between developers.If documentation is a way to commuincate for a consumer of your module, then tests are a way to communicate between devleopers.We have our work cut out for us.CryptoCoinJS is focused on Node.js and the browser using Browserify.We have made an active decision to NOT support legacy browsers.if your browser does not support ECMAScript 5 (2009-2010) and it doesn't support window.crypto.getRandomValues() some of the modules may not work.Note: If a component won't work on the client (browser), then it'll be marked as server only.(the following are poorly documented and need some TLC) /cryptocoinjs/cryptocoin.The NPM module is cryptocoin.Development moves quickly with each individual module and packaging up a release in the larger module is tedious and error prone.So, the state of the large bundle is unknown.Do you use any of CryptoCoinJS?If so, let us know by emailing us or opening a issue/pull request.
Please see our FAQ.If it's not answered on the FAQ, then email us.This library wouldn't be possible without some of the great work of Stefan Thomas, Tom Wu, authors of CryptoJS, and authors of SJCL.Also, recent contributions to BitcoinJS by Kyle Drake, Daniel Cousens, and Wei Lu have helped tremendously.We owe all of the aforementioned a heartfelt thank you for building the foundation for all of this.bitcoin mining using ubuntuLast, but surely not least, we owe Satoshi Nakamoto a heartfelt thank you for inventing what will surely be one of the greatest inventions of mankind.bitcoin-days-destroyed-min-yearReal-Time Notifications Block.io updates you in real-time when your wallet addresses' balances change for Bitcoin, Dogecoin, and Litecoin.reddit bitcoin documentary
This features opens up a vast variety of ways you can integrate digital currencies in your applications, and we can't wait to see how you use these notifications.We provide real-time notifications through Web Hooks, and Web Sockets: Through Web Hooks, we push data to you through HTTP Post requests to web servers of your choice.fake bitcoin pillsThrough Web Sockets, you subscribe to updates while staying connected to a Block.io Notifications server.bitcoin difficulty may 2014The following document provides more details on each of these mechanisms.litecoin gpu and cpu miningInstalling the Library You can download and install the official PHP library using Composer: "block_io-php/block_io-php": "1.1.4" Or manually require it in your PHP project (download from here): require_once 'path/to/block_io.php'; This library requires the mCrypt, GMP, and cURL extensions to work.
Before you start using the PHP library in your code, initialize it like so: > $apiKey = "YOUR API KEY FOR BITCOIN, DOGECOIN, OR LITECOIN"; > $version = 2; // API version > $pin = "YOUR SECRET PIN"; > $block_io = new BlockIo($apiKey, $pin, $version); If you're using Windows, you must do the following to make the library work properly: 1.Download this file to a directory of your choice 2.Make PHP use this file to validate Block.io's SSL certificate by adding this line to your php.ini: curl.cainfo=c:\path\to\cacert.pem Now you're good to go.Here's an example call: > $newAddressInfo = $block_io->get_new_address(array('label' => 'shibe1')); Web Hooks You can start using Web Hooks by creating a Notification on your Block.io account below.Keep in mind, however, that since we are pushing data to you, we need a web server of yours to communicate with through POST requests.Some points of information regarding Web Hooks: All notifications will be issued through n.block.io, so you can whitelist the domain if you use firewalls.
The source server (n.block.io) IP can change at any time.Your Web Server must respond with a Status Code of 2xx (i.e., between 200-299) for us to consider the notification successful.Unsuccessful notifications will be retried for ~24 hours with exponential back-off, after which your failing Web Hook will be disabled.Web Hooks are available for Bitcoin, Dogecoin, Litecoin, and Bitcoin/Dogecoin Testnets.All notification events will use JSON objects.A notification event will use the following structure: { "notification_id" : "...",// a unique identifier issued when you created the notification "delivery_attempt" : 1, // number of times we've tried deliverying this object "type" : "...",// the type of notification, helps you understand the data sent below "data" : { ... // the notification data }, "created_at" : 1426104819 // timestamp of when we created this notification } You can create a Web Hook notification for the following types of events: Account: Consists of balance changes for all your account's addresses for a given Network.
Whenever an address' balance changes, this event is fired.Address: This event is fired when balance changes for a given address (internal or external).This event is fired whenever a new group of transactions is confirmed (i.e., a new block is mined).Furthermore, when you create a notification, you will specify a URL where we can perform POST requests.This URL will receive the following object, and must respond with a Status Code between 200-299.If successful, the notification will be created.{ "type": "ping" } You can specify normal URLs guarded by parameters, or by a username/password (i.e., using Basic Auth), or just a simple URL without any parameters whatsoever.Securing this endpoint on your Web Server is completely up to you.Finally, create a notification using the following endpoints.If you encounter any issues, please make sure the URL is URI encoded so it is distinguishable as a parameter value.$block_io->create_notification(array('type' => 'account', 'url' => 'YOUR URL')); $block_io->create_notification(array('type' => 'address', 'address' => 'ANY ADDRESS', 'url' => 'YOUR URL')); $block_io->create_notification(array('type' => 'new-transactions', 'url' => 'YOUR URL')); $block_io->create_notification(array('type' => 'new-blocks', 'url' => 'YOUR URL')); If successful, you will receive a response with the following structure: { "status" : "success", "data" : { "network" : "BTC", "notification_id" : "306b6d...",
"type" : "account", "enabled" : true, "url" : "..."} } Try now Hide Create a notification for balance changes for all your addresses API KEY: (Your API Keys are in your Wallet) URL: TYPE: Go!Try now Hide Create a notification for balance changes for a specific address API KEY: (Your API Keys are in your Wallet) URL: TYPE: ADDRESS: Go!Try now Hide Create a notification for new blocks API KEY: (Your API Keys are in your Wallet) URL: TYPE: Go!You can disable a given notification at any time using the following action: $block_io->disable_notification(array('notification_id' => 'NOTIFICATION ID')); Try now Hide Disable a given notification API KEY: (Your API Keys are in your Wallet) NOTIFICATION ID: Go!You can enable a given notification at any time using the following action: $block_io->enable_notification(array('notification_id' => 'NOTIFICATION ID')); Try now Hide Enable a given notification API KEY: (Your API Keys are in your Wallet) NOTIFICATION ID: Go!
You can list notifications for a given Network (specified by the API Key).These notifications can be enabled, disabled, or deleted.12/02/15: Going forward, only upto the last 10,000 notifications created are returned by this API call.Future versions will allow pagination for this method.$block_io->get_notifications(); $block_io->get_notifications(array('notification_ids' => 'NOTIFICATION_ID1,NOTIFICATION_ID2,...'));Try now Hide List all notifications API KEY: (Your API Keys are in your Wallet) Go!Try now Hide Get a particular notification API KEY: (Your API Keys are in your Wallet) NOTIFICATION IDS: Go!Produces a log of the last 10 notification events we pushed, or attempted to push, to your web server for a given Notification ID.$block_io->get_recent_notification_events(array('notification_id' => 'NOTIFICATION ID')); Try now Hide Get the last 10 events for a Web Hook API KEY: (Your API Keys are in your Wallet) NOTIFICATION ID: Go!
You can delete a given notification completely if you wish.$block_io->delete_notification(array('notification_id' => 'NOTIFICATION ID')); Try now Hide Delete a given notification API KEY: (Your API Keys are in your Wallet) NOTIFICATION ID: Go!For reference, here is the structure of each type of notification.Please note that Web Hooks of type account provide balance change notifications of type address.Balance Change Notification { "notification_id": "...""delivery_attempt": 1, "created_at": 1426104819, "type": "address", "data": { "network": "BTC", "address": "3cBraN1Q...","balance_change": "0.01000000", // net balance change, can be negative "amount_sent": "0.00000000", "amount_received": "0.01000000", "txid": "7af5cf9f2...",// the transaction's identifier (hash) "confirmations": X, // see below "is_green": false // was the transaction sent by a green address?} } // X = {0,1,3} for Bitcoin, {0,1,10} for Dogecoin, {0,1,5} for Litecoin // if is_green=true, you can spend the funds (received) immediately, else // if is_green=false, you need confirmations = 3 (Bitcoin), 10 (Dogecoin), 5 (Litecoin) New Block Notification { "notification_id": "..."
"delivery_attempt": 1, "created_at": 1426104819, "type": "new-blocks", "data": { "network": "BTC", "block_hash": "fb0e1...",// the block identifier (hash) "previous_block_hash": "5b217...","block_no": 456485, // the block's height "confirmations": 1, // number of times this block has been confirmed // you will also receive an update at N confirmations: // N = 3 (Bitcoin), 10 (Dogecoin), 5 (Litecoin) "merkle_root": "8173983...","time": 1426062467, "nonce": 1544718438, "difficulty": "0.01240701", "txs": [ // an array of txids "81739...",] } } New Transaction Notification { "notification_id": "...""delivery_attempt": 1, "created_at": 1426104819, "type": "new-transactions", "data": { "network": "BTC", "txid": "cc5216...","confirmations": 0, // unconfirmed transaction "block_hash": null, "block_no": null, "block_time": null, "received_at": 1426062224, "network_fee": "0.00010000", "amount_received": "0.01047313", "is_green": false, // was this transaction issued by a green address?
"inputs": [ // an array of old outputs (now inputs) spent by this transaction { "previous_txid": "34181...","previous_output_no": 1, "type": "pubkeyhash", "address": "1GysXM...","amount": "0.01057313", "script": "...",// script signed by the sender "input_no": 0 } ], "outputs": [ // an array of new outputs (unspent) where coins were sent { "output_no": 0, "type": "pubkeyhash", "address": "1HY2W...","amount": "0.00115475", "script": "..."// the script to be signed to spend this output } ] } } Web Sockets You can start subscribing to real-time events by using the following Web Sockets link.These Web Sockets are secured using 2,048 bit SSL, and run on port 443.All notifications issued from Block.io will occur through n.block.io.wss://n.block.io/ Some important points to note: The real-time Web Sockets are only available for Bitcoin, Dogecoin, Litecoin, and the Bitcoin/Dogecoin Testnets.
All requests/responses will use the JSON format.The following example responses are commented for your convenience.Web Sockets will not "replay" events that occurred in the past.You must stay connected to receive updates.Once connected to our Web Sockets, you will receive the following response from the server.Please note that any successful subscription to a real-time event will result in this response from our servers.{ "status": "success" } If your request is invalid, the following error response will be received by you instead: { "status": "fail", "error_message": "An exception occurred.Please check your JSON object for accuracy and try again."} The notifications server will send the following connectedness check every 30 seconds to keep your connection to our Web Sockets server alive.This helps us maintain your connection to n.block.io in case there is little activity due to your subscriptions.You can ignore this message.{ "type": "ping" } Block.io provides a convenient method for you to subscribe to balance changes for all addresses on a given account for Bitcoin, Dogecoin, and Litecoin.
In order to subscribe to an all your account's address balance changes, you must provide the API Key for the account in the following request: { "type": "account", "api_key": "YOUR-API-KEY" } Please note that when you create new addresses on your account, you will need to re-issue the above request to subscribe to the new address' balance updates.If successful, you will start receiving balance updates for all addresses on your account in the following format.{ "type": "address", "data": { "network": "BTC", "address": "3cBraN1Q...",} } // X = {0,1,3} for Bitcoin, {0,1,10} for Dogecoin, {0,1,5} for Litecoin // if is_green=true, you can spend the funds (received) immediately, else // if is_green=false, you need confirmations = 3 (Bitcoin), 10 (Dogecoin), 5 (Litecoin) Alongside your account's addresses at Block.io, you can also subscribe to balance change updates for a specific address by issuing a request structured as follows.
You can subscribe to a non-Block.io address' balance updates using this method.{ "network": "BTC", "type": "address", "address": "3ran1Q..."} The balance change update will be similar to the previous section's response.You can also subscribe to new Blocks as they occur on the Bitcoin, Dogecoin, Litecoin Block Chains.You can do this using requests structured as follows: { "network": "BTC", "type": "new-blocks" } If successful, you will start receiving updates when new Blocks are mined for the specified Network.A block update response will be structured as follows: { "type": "new-blocks", "data": { "network": "BTC", "block_hash": "fb0e1...",] } } (ADVANCED) You can similarly subscribe to all new, unmined transactions as they are received by the Bitcoin, Dogecoin, and Litecoin networks.You can do this by issuing a request structured as follows: { "network": "BTC", "type": "new-transactions" } If successful, you will start receiving data for new transactions.