readme, license, and todo.

This commit is contained in:
Christopher Jeffrey 2016-08-26 05:37:36 -07:00
parent 740e8012a2
commit cf1251a211
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 125 additions and 72 deletions

23
LICENSE Normal file
View File

@ -0,0 +1,23 @@
This software is licensed under the MIT License.
Copyright (c) 2014-2015, Fedor Indutny (https://github.com/indutny)
Copyright (c) 2014-2016, Christopher Jeffrey (https://github.com/chjj)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

145
README.md
View File

@ -2,24 +2,23 @@
**BCoin** is a bitcoin library which can also act as an SPV node or a full **BCoin** is a bitcoin library which can also act as an SPV node or a full
node. It is consensus aware and is up to date with the latest BIPs: it supports node. It is consensus aware and is up to date with the latest BIPs: it supports
segregated witness, versionbits, and CSV. It also has preliminary support for segregated witness, versionbits, CSV, and compact block relay. It also has
bip151 (peer-to-peer encryption), bip152 (compact block relay), and bip114 preliminary support for bip151 (peer-to-peer encryption), bip150 (peer auth),
(MAST). It runs in node.js, but it can also be browserified. and bip114 (MAST). It runs in node.js, but it can also be browserified.
Try it in the browser: http://bcoin.io/browser.html Try it in the browser: http://bcoin.io/browser.html
## Features ## Features
- HD Wallets (using BIP44 derivation and accounts) - Browserifiable
- Fully browserifiable - Full blockchain validation
- Full block validation - Blockchain database
- Full block database - Mempool/Miner
- Fully validating mempool (stored in-memory or optionally on-disk) - Wallet system & wallet database (HD keys w/ bip44 derivation)
- Wallet database - Bitcoind-compatible JSON rpc api
- HTTP server which acts as a wallet server and can also serve: - REST api
blocks, txs (by hash/address), and utxos (by id/address). - Support for: Versionbits, CSV, Segwit, BIP70, BIP151, BIP152, BIP150,
- Full segregated witness support for block/tx validation and wallets. and MAST.
- Versionbits, CSV, BIP151, BIP152, MAST support.
- SPV mode - SPV mode
## Install ## Install
@ -28,11 +27,12 @@ Try it in the browser: http://bcoin.io/browser.html
$ git clone git://github.com/bcoin-org/bcoin.git $ git clone git://github.com/bcoin-org/bcoin.git
$ cd bcoin $ cd bcoin
$ npm install $ npm install
$ bcoin --fast
``` ```
The latest BCoin has not been published to NPM yet, as it is still under fairly Note that the latest BCoin has not been published to NPM yet, as it is still
heavy development (which may involve changing serialization formats for the under fairly heavy development (which may involve changing serialization
database). formats for the database).
## Documentation ## Documentation
@ -40,13 +40,50 @@ Read the docs here: http://bcoin.io/docs/
## Example Usage ## Example Usage
- [CLI Usage](#cli-usage)
- [Creating a blockchain and mempool](#creating-a-blockchain-and-mempool) - [Creating a blockchain and mempool](#creating-a-blockchain-and-mempool)
- [Connecting to the P2P network](#connecting-to-the-p2p-network) - [Connecting to the P2P network](#connecting-to-the-p2p-network)
- [Doing and SPV sync](#doing-an-spv-sync) - [Doing and SPV sync](#doing-an-spv-sync)
- [High-level usage with the Node object](#high-level-usage-with-the-node-object) - [High-level usage with the Node object](#high-level-usage-with-the-node-object)
- [Running the default full node](#running-the-default-full-node) - [Running the default full node](#running-the-default-full-node)
- [Running a full node in the browser](#running-a-full-node-in-the-browser) - [Running a full node in the browser](#running-a-full-node-in-the-browser)
- [CLI Usage](#cli-usage)
### CLI Usage
``` bash
$ export BCOIN_API_KEY=your-api-key
# View the genesis block
$ bcoin cli block 0
# View the mempool
$ bcoin cli mempool
# View primary wallet
$ bcoin cli wallet get
# View transaction history
$ bcoin cli wallet history
# Send a transaction
$ bcoin cli wallet send [address] 0.01
# View balance
$ bcoin cli wallet balance
# Derive new address
$ bcoin cli wallet address
```
#### RPC (bitcoind-like)
``` bash
$ bcoin rpc getblockchaininfo
$ bcoin rpc getwalletinfo
$ bcoin rpc getpeerinfo
$ bcoin rpc getbalance
$ bcoin rpc sendtoaddress [address] 0.01
```
### Creating a blockchain and mempool ### Creating a blockchain and mempool
@ -65,7 +102,7 @@ bcoin.set({
// Start up a blockchain, mempool, and miner using in-memory // Start up a blockchain, mempool, and miner using in-memory
// databases (stored in a red-black tree instead of on-disk). // databases (stored in a red-black tree instead of on-disk).
var chain = new bcoin.chain({ db: 'memory' }); var chain = new bcoin.chain({ db: 'memory' });
var mempool = new bcoin.mempool({ chain: chain, db: 'memory' }); var mempool = new bcoin.mempool({ chain: chain });
var miner = new bcoin.miner({ chain: chain, mempool: mempool }); var miner = new bcoin.miner({ chain: chain, mempool: mempool });
// Open the miner (initialize the databases, etc). // Open the miner (initialize the databases, etc).
@ -107,10 +144,10 @@ var bcoin = require('bcoin').set('main');
var prefix = process.env.HOME + '/my-bcoin-environment'; var prefix = process.env.HOME + '/my-bcoin-environment';
var chain = new bcoin.chain({ db: 'leveldb', location: prefix + '/chain' }); var chain = new bcoin.chain({ db: 'leveldb', location: prefix + '/chain' });
var mempool = new bcoin.mempool({ chain: chain, db: 'memory' }); var mempool = new bcoin.mempool({ chain: chain });
// Create a network pool of peers with a limit of 8 peers. // Create a network pool of peers with a limit of 8 peers.
var pool = new bcoin.pool({ chain: chain, mempool: mempool, size: 8 }); var pool = new bcoin.pool({ chain: chain, mempool: mempool, maxPeers: 8 });
// Open the pool (implicitly opens mempool and chain). // Open the pool (implicitly opens mempool and chain).
pool.open(function(err) { pool.open(function(err) {
@ -150,8 +187,7 @@ var tchain = new bcoin.chain({
var tmempool = new bcoin.mempool({ var tmempool = new bcoin.mempool({
network: 'segnet4', network: 'segnet4',
chain: tchain, chain: tchain'
db: 'memory'
}); });
var tpool = new bcoin.pool({ var tpool = new bcoin.pool({
@ -204,7 +240,7 @@ var chain = new bcoin.chain({
var pool = new bcoin.pool({ var pool = new bcoin.pool({
chain: chain, chain: chain,
spv: true, spv: true,
size: 8 maxPeers: 8
}); });
var walletdb = new bcoin.walletdb({ db: 'memory' }); var walletdb = new bcoin.walletdb({ db: 'memory' });
@ -279,7 +315,7 @@ node.open(function(err) {
type: 'pubkeyhash' type: 'pubkeyhash'
}; };
node.createWallet(options, function(err, wallet) { node.walletdb.create(options, function(err, wallet) {
if (err) if (err)
throw err; throw err;
@ -346,20 +382,13 @@ node.chain.on('full', function() {
### Running the default full node ### Running the default full node
``` bash ``` bash
$ node bin/node --fast $ bcoin --fast
``` ```
`--fast` will enable checkpoints, coin cache, and getheaders. `--fast` will enable checkpoints, coin cache, and getheaders.
Some environment variables are available for quick configuration: Your config file should reside in `~/.bcoin/bcoin.conf`. See `etc/sample.conf`
for an example.
- `BCOIN_USE_WORKERS=1` - Enable workers for TX verification.
- `BCOIN_SEED=[host]` - Use a preferred seed node to connect to.
- `BCOIN_NETWORK=[network]` - Set the network (main, testnet, regtest, segnet3,
or segnet4).
- `BCOIN_DB=[db-name]` - Default database backend (leveldb, rocksdb, lmdb,
memory).
- `BCOIN_LOGLEVEL=[level]` - Default log level (debug, info, warning, error).
### Running a full node in the browser ### Running a full node in the browser
@ -376,22 +405,6 @@ This is a simple proof-of-concept. It's not a pretty interface. I hope to see
others doing something far more interesting. A browser extension may be better: others doing something far more interesting. A browser extension may be better:
the chrome extension API exposes raw TCP access. the chrome extension API exposes raw TCP access.
### CLI Usage
``` bash
$ BCOIN_NETWORK=segnet4 node bin/node
# View the genesis block
$ node bin/bcoin-cli block 0
# View primary wallet
$ node bin/bcoin-cli wallet primary
# Send a tx
$ node bin/bcoin-cli send primary [address] 0.01
# View balance
$ node bin/bcoin-cli balance primary
# View the mempool
$ node bin/bcoin-cli mempool
```
## TX creation ## TX creation
Normal transactions in bcoin are immutable. The primary TX object contains a Normal transactions in bcoin are immutable. The primary TX object contains a
@ -404,7 +417,7 @@ inherit from the TX object, but can also be signed and modified.
``` js ``` js
var bcoin = require('bcoin'); var bcoin = require('bcoin');
var assert = require('assert'); var assert = require('assert');
var constants = bcoin.protocol.constants; var constants = bcoin.constants;
// Create an HD master keypair with a mnemonic. // Create an HD master keypair with a mnemonic.
var master = bcoin.hd.fromMnemonic(); var master = bcoin.hd.fromMnemonic();
@ -476,7 +489,7 @@ Let's try it more realistically:
``` js ``` js
var bcoin = require('bcoin'); var bcoin = require('bcoin');
var assert = require('assert'); var assert = require('assert');
var constants = bcoin.protocol.constants; var constants = bcoin.constants;
var master = bcoin.hd.fromMnemonic(); var master = bcoin.hd.fromMnemonic();
var key = master.derive('m/44/0/0/0/0'); var key = master.derive('m/44/0/0/0/0');
@ -689,31 +702,19 @@ bcoin, we now have a full node that will run on almost any browser, on laptops,
on servers, on smartphones, on most devices you can imagine, even by simply on servers, on smartphones, on most devices you can imagine, even by simply
visting a webpage. visting a webpage.
## LICENSE ## Contribution and License Agreement
This software is licensed under the MIT License. If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. `</legalese>`
Copyright Fedor Indutny, 2014-2016. ## License
Copyright Christopher Jeffrey, 2014-2016.
Permission is hereby granted, free of charge, to any person obtaining a Copyright (c) 2014-2015, Fedor Indutny (MIT License).
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS See LICENSE for more info.
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
[v8]: https://www.youtube.com/watch?v=UJPdhx5zTaw [v8]: https://www.youtube.com/watch?v=UJPdhx5zTaw
[libsecp256k1]: https://github.com/bitcoin-core/secp256k1 [libsecp256k1]: https://github.com/bitcoin-core/secp256k1

29
TODO.md Normal file
View File

@ -0,0 +1,29 @@
# Todo
Todo before release. Excuse the mess.
- prioritization for mining.
- switch entirely to secp256k1-node. bad for payment-protocol and ec.random
(add crypto/random.js).
- walletdb removes coins from txs - potentially have it clone the tx (slower).
- move siphash to utils?
- refactor and add all network packets.
- rename keyring object.
- browser-side dsa signing/verify for payment-protocol.
- add preliminary support for schnorr and bls signatures.
- potentially rewrite walletdb to avoid O(n) complexity for tx insertion to
multiple wallets (n=number-of-wallets-mapped: 1 in the average case, 2 in
average worst case, potentially thousands in bullshit worst case). doing
this, we would lose fast iteration over txs, coins, and undo coins.
- do not output bitcoin strings (utils.btc) on the api layer. use satoshis
instead.
- upgrade to leveldb 1.19.
- bindings to asm chacha20+poly1305.
- bindings to asm sha256 (use webgl shader in browser).
- implement jl's latest MAST.
- rewrite readme. move examples to wiki.
- fix docs.
- implement rpc calls:
- backupwallet
- listaddressgroupings
- importaddress (maybe)