forked from bcoin-org/bcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,025 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
node_modules/ | ||
docs/ | ||
docs/reference/ | ||
docker_data/ | ||
browser/bcoin* | ||
bcoin* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
## Introduction | ||
|
||
Bcoin is an _alternative_ implementation of the bitcoin protocol, written in node.js. It is a full node which can be used for full blockchain validation and is aware of all known consensus rules. | ||
|
||
## Requirements | ||
|
||
- Linux, OSX, or Windows (\*) (\*\*) | ||
- node.js >=v5.0.0 | ||
- npm >=v4.0.0 | ||
- python2 (for node-gyp) | ||
- gcc/g++ (for leveldb and secp256k1) | ||
- git (optional, see below) | ||
|
||
(\*): Note that bcoin works best with unix-like OSes, and has not yet been thoroughly tested on windows. | ||
|
||
(\*\*): The BSDs and Solaris have also not been tested yet, but should work in theory. | ||
|
||
## Build & Install | ||
|
||
Bcoin is meant to be installed via npm, but for the security conscious, it may be better to clone from github. All tagged commits for release should be signed by @chjj's [PGP key][keybase] (`B4B1F62DBAC084E333F3A04A8962AB9DE6666BBD`). Signed copies of node.js are available from [nodejs.org][node], or from your respective OS's package repositories. | ||
|
||
### Installing via NPM | ||
|
||
``` bash | ||
$ npm install -g bcoin --production | ||
``` | ||
|
||
### Installing via Git | ||
|
||
``` bash | ||
$ curl https://keybase.io/chjj/pgp_keys.asc | gpg --import | ||
$ git clone git://github.com/bcoin-org/bcoin.git | ||
$ cd bcoin | ||
$ git tag | ||
... | ||
v1.0.0-alpha # latest version | ||
$ git tag -v v1.0.0-alpha # verify signature | ||
$ git checkout v1.0.0-alpha | ||
$ npm install -g --production | ||
``` | ||
|
||
### Troubleshooting | ||
|
||
If the build fails compilation for `bcoin-native` or `secp256k1-node` __validation will be slow__ (a block verification which should take 1 second on consumer grade hardware may take up to 15 seconds). Bcoin will throw a warning on boot if it detects a build failure. If you run into this issue, please post an issue on the repo. | ||
|
||
## Starting up your first bcoin node | ||
|
||
If bcoin is installed globally, `$ bcoin` should be in your PATH. If not, the bcoin bootstrap script resides in `/path/to/bcoin/bin/bcoin`. | ||
|
||
``` bash | ||
$ bcoin | ||
``` | ||
|
||
Will run a bcoin node as the foreground process, displaying all debug logs. | ||
|
||
To run as a daemon: | ||
|
||
``` bash | ||
$ bcoin --daemon | ||
``` | ||
|
||
This will start up a full node, complete with: a blockchain, mempool, miner, p2p server, wallet server, and an HTTP REST+RPC server. | ||
|
||
All logs will be written to `~/.bcoin/debug.log` by default. | ||
|
||
By default, the http server will only listen on `127.0.0.1:8332`. No auth will be required if an API key was not passed in. If you listen on any other host, auth will be required and an API key will be auto-generated if one was not passed in. | ||
|
||
## Listening Externally | ||
|
||
To listen publicly on the HTTP server, `--http-host=0.0.0.0` (ipv4) or `--http-host=::` (ipv4 and ipv6) can be passed. Additionally this: `--http-port=1337` can set the port. | ||
|
||
To advertise your node on the P2P network `--public-host=[your-public-ip]` and `--public-port=[your-public-port]` may be passed. | ||
|
||
## Using an API Key | ||
|
||
If listening publicly on the HTTP server, an API key is required. One will be generated and reported in the logs automatically if no key was chosen. An api key can be chosen with the `--api-key` option. | ||
|
||
Example: | ||
|
||
``` bash | ||
$ bcoin --http-host=0.0.0.0 --api-key hunter2 --daemon | ||
``` | ||
|
||
API keys are used with HTTP Basic Auth: | ||
|
||
``` bash | ||
$ curl http://x:hunter2@localhost:8332/ | ||
``` | ||
|
||
Bcoin CLI is the prepackaged tool for hitting both the REST and RPC api. | ||
|
||
``` bash | ||
$ bcoin cli info --api-key hunter2 | ||
$ bcoin rpc getblockchaininfo --api-key hunter2 | ||
``` | ||
|
||
## Using Tor/SOCKS | ||
|
||
Bcoin has native support for SOCKS proxies, and will accept a `--proxy` option in the format of `--proxy=[user]:[pass]@host:port`. | ||
|
||
Passing the `--onion` option tells bcoin that the SOCKS proxy is a Tor socks proxy, and will enable Tor resolution for DNS lookups, as well as try to connect to `.onion` addresses found on the P2P network. | ||
|
||
``` bash | ||
$ bcoin --proxy joe:[email protected]:9050 --onion | ||
``` | ||
|
||
### Running bcoin as a tor hidden service | ||
|
||
Your hidden service must first be configured with `tor`. Once you have the `.onion` address, it can be passed into `--public-host` in the form of `--public-host foo.onion`. | ||
|
||
## Target Nodes | ||
|
||
It's often desirable to run behind several trusted bitcoin nodes. To select permanent nodes to connect to, the `--nodes` option is available: | ||
|
||
``` bash | ||
$ bcoin --nodes foo.example.com:8333,1.2.3.4:8333,5.6.7.8:8333 | ||
``` | ||
|
||
If chosen, bcoin will _always_ try to connect to these nodes as outbound peers. They are top priority and whitelisted (not susceptible to permanent bans, only disconnections). | ||
|
||
To _only_ connect to these nodes. `--max-outbound` could be set to 3: | ||
|
||
``` bash | ||
$ bcoin --nodes foo.example.com,1.2.3.4,5.6.7.8 --max-outbound 3 | ||
``` | ||
|
||
## Disabling Listening | ||
|
||
To avoid accepting connections on the P2P network altogether, `--listen=false` can be passed to bcoin. | ||
|
||
### Selfish Mode | ||
|
||
Bcoin also supports a "selfish" mode. In this mode, bcoin still has full blockchain and mempool validation, but network services are disabled: it will not relay transactions or serve blocks to anyone. | ||
|
||
``` bash | ||
$ bcoin --selfish --listen=false | ||
``` | ||
|
||
Note: Selfish mode is not recommended. We encourage you to _help_ the network by relaying transactions and blocks. At the same time, selfish mode does have its uses if you do not have the bandwidth to spare, or if you're absolutely worried about potential DoS attacks. | ||
|
||
## Further Configuration | ||
|
||
See [Configuration][configuration]. | ||
|
||
[keybase]: https://keybase.io/chjj#show-public | ||
[node]: https://nodejs.org/dist/v7.5.0/ | ||
[configuration]: Configuration.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
Bcoin ships with bcoin-cli as its default HTTP client for command line access. | ||
|
||
## Configuration | ||
|
||
Examples: | ||
|
||
``` bash | ||
$ export BCOIN_API_KEY=hunter2 | ||
$ export BCOIN_NETWORK=main | ||
$ export BCOIN_URI=http://localhost:8332 | ||
$ bcoin cli info | ||
``` | ||
|
||
``` bash | ||
$ bcoin cli info --api-key=hunter2 --uri=http://localhost | ||
``` | ||
|
||
``` bash | ||
$ echo 'api-key: hunter2' > ~/cli.conf | ||
$ bcoin cli info --config=~/cli.conf | ||
``` | ||
|
||
## Examples | ||
|
||
``` 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 wallet get | ||
|
||
# View transaction history | ||
$ bcoin wallet history | ||
|
||
# Send a transaction | ||
$ bcoin wallet send [address] 0.01 | ||
|
||
# View balance | ||
$ bcoin wallet balance | ||
|
||
# Derive new address | ||
$ bcoin wallet address | ||
|
||
# Create a new account | ||
$ bcoin wallet account create foo | ||
|
||
# Send from account | ||
$ bcoin wallet send [address] 0.01 --account=foo | ||
``` | ||
|
||
RPC examples: | ||
|
||
``` bash | ||
$ bcoin rpc getblockchaininfo | ||
$ bcoin rpc getwalletinfo | ||
$ bcoin rpc getpeerinfo | ||
$ bcoin rpc getbalance | ||
$ bcoin rpc listtransactions | ||
$ bcoin rpc sendtoaddress [address] 0.01 | ||
``` | ||
|
||
## Commands | ||
|
||
bcoin-cli commands are split into 3 categories: cli, rpc, and wallet. | ||
|
||
### Top-level Commands | ||
|
||
- `info`: Get server info. | ||
- `wallets`: List all wallets. | ||
- `wallet create [id]`: Create wallet. | ||
- `broadcast [tx-hex]`: Broadcast transaction. | ||
- `mempool`: Get mempool snapshot. | ||
- `tx [hash/address]`: View transactions. | ||
- `coin [hash+index/address]`: View coins. | ||
- `block [hash/height]`: View block. | ||
- `rescan [height]`: Rescan for transactions. | ||
- `reset [height/hash]`: Reset chain to desired block. | ||
- `resend`: Resend pending transactions. | ||
- `backup [path]`: Backup the wallet db. | ||
- `wallet [command]`: Execute wallet command. | ||
- `rpc [command] [args]`: Execute RPC command. | ||
|
||
### Wallet Commands | ||
|
||
- `listen`: Listen for events. | ||
- `get`: View wallet. | ||
- `master`: View wallet master key. | ||
- `shared add [xpubkey]`: Add key to wallet. | ||
- `shared remove [xpubkey]`: Remove key from wallet. | ||
- `balance`: Get wallet balance. | ||
- `history`: View TX history. | ||
- `pending`: View pending TXs. | ||
- `coins`: View wallet coins. | ||
- `account list`: List account names. | ||
- `account create [account-name]`: Create account. | ||
- `account get [account-name]`: Get account details. | ||
- `address`: Derive new receiving address. | ||
- `change`: Derive new change address. | ||
- `nested`: Derive new nested address. | ||
- `retoken`: Create new api key. | ||
- `send [address] [value]`: Send transaction. | ||
- `mktx [address] [value]`: Create transaction. | ||
- `sign [tx-hex]`: Sign transaction. | ||
- `zap [age?]`: Zap pending wallet TXs. | ||
- `tx [hash]`: View transaction details. | ||
- `blocks`: List wallet blocks. | ||
- `block [height]`: View wallet block. | ||
- `view [tx-hex]`: Parse and view transaction. | ||
- `import [wif|hex]`: Import private or public key. | ||
- `watch [address]`: Import an address. | ||
- `key [address]`: Get wallet key by address. | ||
- `dump [address]`: Get wallet key WIF by address. | ||
- `lock`: Lock wallet. | ||
- `unlock [passphrase] [timeout?]`: Unlock wallet. | ||
- `resend`: Resend pending transactions. | ||
|
||
### RPC Commands | ||
|
||
Bcoin implements nearly all bitcoind calls along with some custom calls. | ||
|
||
- `stop` | ||
- `help` | ||
- `getblockchaininfo` | ||
- `getbestblockhash` | ||
- `getblockcount` | ||
- `getblock` | ||
- `getblockhash` | ||
- `getblockheader` | ||
- `getchaintips` | ||
- `getdifficulty` | ||
- `getmempoolancestors` | ||
- `getmempooldescendants` | ||
- `getmempoolentry` | ||
- `getmempoolinfo` | ||
- `getrawmempool` | ||
- `gettxout` | ||
- `gettxoutsetinfo` | ||
- `verifychain` | ||
- `invalidateblock` | ||
- `reconsiderblock` | ||
- `getnetworkhashps` | ||
- `getmininginfo` | ||
- `prioritisetransaction` | ||
- `getwork` | ||
- `getworklp` | ||
- `getblocktemplate` | ||
- `submitblock` | ||
- `setgenerate` | ||
- `getgenerate` | ||
- `generate` | ||
- `generatetoaddress` | ||
- `estimatefee` | ||
- `estimatepriority` | ||
- `estimatesmartfee` | ||
- `estimatesmartpriority` | ||
- `getinfo` | ||
- `validateaddress` | ||
- `createmultisig` | ||
- `createwitnessaddress` | ||
- `verifymessage` | ||
- `signmessagewithprivkey` | ||
- `setmocktime` | ||
- `getconnectioncount` | ||
- `ping` | ||
- `getpeerinfo` | ||
- `addnode` | ||
- `disconnectnode` | ||
- `getaddednodeinfo` | ||
- `getnettotals` | ||
- `getnetworkinfo` | ||
- `setban` | ||
- `listbanned` | ||
- `clearbanned` | ||
- `getrawtransaction` | ||
- `createrawtransaction` | ||
- `decoderawtransaction` | ||
- `decodescript` | ||
- `sendrawtransaction` | ||
- `signrawtransaction` | ||
- `gettxoutproof` | ||
- `verifytxoutproof` | ||
- `fundrawtransaction` | ||
- `resendwallettransactions` | ||
- `abandontransaction` | ||
- `addmultisigaddress` | ||
- `addwitnessaddress` | ||
- `backupwallet` | ||
- `dumpprivkey` | ||
- `dumpwallet` | ||
- `encryptwallet` | ||
- `getaccountaddress` | ||
- `getaccount` | ||
- `getaddressesbyaccount` | ||
- `getbalance` | ||
- `getnewaddress` | ||
- `getrawchangeaddress` | ||
- `getreceivedbyaccount` | ||
- `getreceivedbyaddress` | ||
- `gettransaction` | ||
- `getunconfirmedbalance` | ||
- `getwalletinfo` | ||
- `importprivkey` | ||
- `importwallet` | ||
- `importaddress` | ||
- `importprunedfunds` | ||
- `importpubkey` | ||
- `keypoolrefill` | ||
- `listaccounts` | ||
- `listaddressgroupings` | ||
- `listlockunspent` | ||
- `listreceivedbyaccount` | ||
- `listreceivedbyaddress` | ||
- `listsinceblock` | ||
- `listtransactions` | ||
- `listunspent` | ||
- `lockunspent` | ||
- `move` | ||
- `sendfrom` | ||
- `sendmany` | ||
- `sendtoaddress` | ||
- `setaccount` | ||
- `settxfee` | ||
- `signmessage` | ||
- `walletlock` | ||
- `walletpassphrasechange` | ||
- `walletpassphrase` | ||
- `removeprunedfunds` | ||
- `getmemory` | ||
- `selectwallet` | ||
- `setloglevel` |
Oops, something went wrong.