@ -8,6 +8,7 @@ A pure, powerful core for your bitcoin project.
Bitcore is a complete, native interface to the Bitcoin network, and provides the core functionality needed to develop apps for bitcoin.
Bitcore is a complete, native interface to the Bitcoin network, and provides the core functionality needed to develop apps for bitcoin.
#Principles
#Principles
Bitcoin is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Bitcoin network allows for highly resilient bitcoin infrastructure, and the developer community needs reliable, open-source tools to implement bitcoin apps and services.
Bitcoin is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Bitcoin network allows for highly resilient bitcoin infrastructure, and the developer community needs reliable, open-source tools to implement bitcoin apps and services.
**Bitcore unchains developers from fallible, centralized APIs, and provides the tools to interact with the real Bitcoin network.**
**Bitcore unchains developers from fallible, centralized APIs, and provides the tools to interact with the real Bitcoin network.**
@ -15,11 +16,13 @@ Bitcoin is a powerful new peer-to-peer platform for the next generation of finan
#Get Started
#Get Started
Bitcore runs on [node](http://nodejs.org/), and can be installed via [npm](https://npmjs.org/):
Bitcore runs on [node](http://nodejs.org/), and can be installed via [npm](https://npmjs.org/):
```
```
npm install bitcore
npm install bitcore
```
```
It is a collection of objects useful to bitcoin applications; class-like idioms are enabled via [Soop](https://github.com/bitpay/soop). In most cases, a developer will require the object's class directly. For instance:
It is a collection of objects useful to bitcoin applications; class-like idioms are enabled via [Soop](https://github.com/bitpay/soop). In most cases, a developer will require the object's class directly. For instance:
```
```
var bitcore = require('bitcore');
var bitcore = require('bitcore');
var Address = bitcore.Address;
var Address = bitcore.Address;
@ -32,7 +35,9 @@ var PeerManager = bitcore.PeerManager;
Some examples are provided at the [examples](/examples) path. Here are some snippets:
Some examples are provided at the [examples](/examples) path. Here are some snippets:
For this example you need a running bitcoind instance with RPC enabled.
For this example you need a running bitcoind instance with RPC enabled.
```js
```js
var bitcore = require('bitcore');
var bitcore = require('bitcore');
var networks = bitcore.networks;
var networks = bitcore.networks;
@ -68,7 +76,6 @@ var handleBlock = function(info) {
var handleTx = function(info) {
var handleTx = function(info) {
var tx = info.message.tx.getStandardizedObject();
var tx = info.message.tx.getStandardizedObject();
console.log('** TX Received **');
console.log('** TX Received **');
console.log(tx);
console.log(tx);
};
};
@ -76,7 +83,6 @@ var handleTx = function(info) {
var handleInv = function(info) {
var handleInv = function(info) {
console.log('** Inv **');
console.log('** Inv **');
console.log(info.message);
console.log(info.message);
var invs = info.message.invs;
var invs = info.message.invs;
info.conn.sendGetData(invs);
info.conn.sendGetData(invs);
};
};
@ -96,9 +102,10 @@ peerman.start();
PeerManager will emit the following events: 'version', 'verack', 'addr', 'getaddr', 'error' 'disconnect'; and will relay events like: 'tx', 'block', 'inv'. Please see [PeerManager.js](PeerManager.js), [Peer.js](Peer.js) and [Connection.js](Connection.js)
PeerManager will emit the following events: 'version', 'verack', 'addr', 'getaddr', 'error' 'disconnect'; and will relay events like: 'tx', 'block', 'inv'. Please see [PeerManager.js](PeerManager.js), [Peer.js](Peer.js) and [Connection.js](Connection.js)
## Consuming bitcoind RPC
## Consuming bitcoind RPC
For this example you need a running bitcoind instance with RPC enabled.
For this example you need a running bitcoind instance with RPC enabled.
Bitcore is still under heavy development and not quite ready for "drop-in" production use. If you find a security issue, please email security@bitcore.io.
Bitcore is still under heavy development and not quite ready for "drop-in" production use. If you find a security issue, please email security@bitcore.io.
#Contributing
#Contributing
Bitcore needs some developer love. Please send pull requests for bug fixes, code optimization, and ideas for improvement.
Bitcore needs some developer love. Please send pull requests for bug fixes, code optimization, and ideas for improvement.
#Browser support
#Browser support
## Building the browser bundle
## Building the browser bundle
To build bitcore full bundle for the browser:
(this is automatically executed after you run `npm install`)
To build bitcore full bundle for the browser (this is automatically executed after you run `npm install`):
```
```
node browser/build.js -a
node browser/build.js -a
```
```
This will generate a `browser/bundle.js` file which you can include
in your HTML to use bitcore in the browser.
##
This will generate a `browser/bundle.js` file which you can include in your HTML to use bitcore in the browser.
##Example browser usage
##Example browser usage
@ -303,23 +308,21 @@ From example/simple.html
</html>
</html>
```
```
You can check a more complex usage example at examples/example.html
You can check a more complex usage example at examples/example.html.
## Generating a customized browser bundle
## Generating a customized browser bundle
To generate a customized bitcore bundle, you can specify
which submodules you want to include in it with the -s option:
To generate a customized bitcore bundle, you can specify which submodules you want to include in it with the -s option:
```
```
node browser/build.js -s Transaction,Address
node browser/build.js -s Transaction,Address
```
```
This will generate a `browser/bundle.js` containing only the Transaction
and Address class, with all their dependencies.
This will generate a `browser/bundle.js` containing only the Transaction and Address class, with all their dependencies. Use this option if you are not using the whole bitcore library, to optimize the bundle size, script loading time, and general resource usage.
Use this option if you are not using the whole bitcore library, to optimize
the bundle size, script loading time, and general resource usage.
## Tests
## Tests
Run tests in node:
Run tests in node:
```
```
mocha
mocha
@ -341,13 +344,10 @@ npm run-script coverage
And then open coverage/lcov-report/index.html in your browser.
And then open coverage/lcov-report/index.html in your browser.
#License
#License
**Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).**
**Code released under [the MIT license](https://github.com/bitpay/bitcore/blob/master/LICENSE).**
Copyright 2013-2014 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
Copyright 2013-2014 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.