Bcoin is an alternative implementation of the Bitcoin protocol, written in JavaScript and C/C++ for Node.js.
Bcoin is well tested and aware of all known consensus rules. It is currently used in production as the consensus backend and wallet system for purse.io.
- Full Node
- SPV Node
- Wallet Backend
- Mining Backend (getblocktemplate support)
- Layer 2 Backend (lightning)
- General Purpose Bitcoin Library
Try it in the browser: https://bcoin.io/browser/
$ git clone git://github.com/bcoin-org/bcoin.git
$ cd bcoin
$ npm rebuild
$ ./bin/bcoin
See the Getting started guide for more in-depth installation instructions, including verifying releases. If you're upgrading, see the latest changes via the Changelog.
- General docs: docs/
- Wallet and node API docs: https://bcoin.io/api-docs/
- Library API docs: https://bcoin.io/docs/
Join us on freenode in the A79F #bcoin channel.
Bcoin does not guarantee you against theft or lost funds due to bugs, mishaps, or your own incompetence. You and you alone are responsible for securing your money.
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 (c) 2014-2015, Fedor Indutny (MIT License).
- Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
See LICENSE for more info.
./bin/bcoin --network=regtest
./bin/bcoin --network=regtest --prefix /Users/iljapavlovs/Desktop/Projects/PoC/BitCoin/bcoin/bcoin_node1 --port 48133 --http-port 48132 --wallet-http-port 48134 --nodes 127.0.0.1:48233 --log-level=info
./bin/bcoin --network=regtest --prefix /Users/iljapavlovs/Desktop/Projects/PoC/BitCoin/bcoin/bcoin_node2 --port 48233 --http-port 48232 --wallet-http-port 48234 --nodes 127.0.0.1:48133 --log-level=info
--config /Users/iljapavlovs/Desktop/Projects/PoC/BitCoin/bcoin/bcoin_node1
./bin/bcoin-cli --network=regtest --http-port=48132 info
./bin/bcoin-cli --network=regtest --http-port=48232 info
Common node commands:
# View the genesis block
$ ./bin/bcoin-cli block 0 --network=regtest --http-port=48132
# View the mempool
$ ./bin/bcoin-cli mempool --network=regtest --http-port=48132
# Execute an RPC command to list network peers
$ ./bin/bcoin-cli rpc getpeerinfo --network=regtest --http-port=48132
Common wallet commands:
# View primary wallet - https://bcoin.io/api-docs/?shell--cli#configuration, https://bcoin.io/api-docs/?shell--cli#get-wallet-info
$ ./bin/bwallet-cli get --network=regtest --http-port=48134
# get all wallets
$ ./bin/bwallet-cli wallets --network=regtest --http-port=48134
# View transaction history
$ ./bin/bwallet-cli history --network=regtest --http-port=48134
# Send a transaction
$ ./bin/bwallet-cli send <address> 0.01 --network=regtest --http-port=48134
mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV
# View balance
$ ./bin/bwallet-cli balance --network=regtest --http-port=48134
# Derive new address
$ ./bin/bwallet-cli address --network=regtest --http-port=48134
# Derive new receiving address for account.
#https://bcoin.io/api-docs/?shell--cli#generate-receiving-address
./bin/bwallet-cli --id=primary --account=default address --network=regtest --http-port=48134
# bcoin cli RPC method - Mines blocknumber blocks, with address as coinbase (fee and reward?)
./bin/bcoin-cli rpc generatetoaddress 101 "mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV" --network=regtest --http-port=48132
./bin/bcoin-cli rpc generatetoaddress 101 "mgL6Ywhwq2s4PcofCVnZTZ2v6XQTfJ2djm" --network=regtest --http-port=48232
node1 = mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV
node2 = mgL6Ywhwq2s4PcofCVnZTZ2v6XQTfJ2djm
./bin/bwallet-cli send mgL6Ywhwq2s4PcofCVnZTZ2v6XQTfJ2djm 0.01 --network=regtest --http-port=48134
$ ./bin/bwallet-cli get --network=regtest --http-port=48134
$ ./bin/bwallet-cli get --network=regtest --http-port=48234 // here shuould be unconfirmed
./bin/bcoin-cli rpc generatetoaddress 1 "mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV" --network=regtest --http-port=48132
# Create a new account
$ ./bin/bwallet-cli account create foo --network=regtest --http-port=48134
# Send from account
$ ./bin/bwallet-cli send <address> 0.01 --account=foo --network=regtest --http-port=48134
./bin/bcoin-cli info
./bin/bcoin-cli --network=regtest --http-port=48132
bcoin-cli --network=regtest
bcoin --network=testnet --http-host=0.0.0.0 --wallet-http-host=0.0.0.0 --wallet-api-key=hunter2 --wallet-wallet-auth=true
-
getnewaddress obtain an address of our curent wallet (to this address we will be sending / generate some bitcoin that we will use later in our test case).
-
generatetoaddress 101 <copied_address_1> will initialize the blockchain and generate 101 blocks on the local block-chain this will send free (a.k.a. coinbase) coins generated by these blocks to your address <copied_address_1> - this is the normal process by which coins are generated in the network
./bin/bcoin-cli rpc generatetoaddress 101 mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV --network=regtest --http-port=48134
- getbalance should now be 50 Bitcoins, available to be spent anytime
8333, 18333, 18444, 28333, 28901
main: 8332, testnet: 18332, regtest: 48332, simnet: 18556
main: 8334, testnet: 18334, regtest: 48334, simnet: 18558
???? after ./bin/bcoin-cli rpc generatetoaddress 101 "mgEjCv68onhiPSSY9xAWSK2k4WZnPgZCmV" --network=regtest --http-port=48132
iljapavlovs@Iljas-MacBook-Pro bcoin % ./bin/bwallet-cli get --network=regtest --http-port=48134 { "network": "regtest", "wid": 0, "id": "primary", "watchOnly": false, "accountDepth": 1, "token": "6ca6ce18519075ed4138a9c5d5106c2695c77582e217ae0e2053057e2328cc08", "tokenDepth": 0, "master": { "encrypted": false }, "balance": { "tx": 101, "coin": 101, "unconfirmed": 505000000000, "confirmed": 505000000000 } }