bithodl-service
v2.0.0
Published
Bitcore service to expose necessary endpoints for the BitHodl app.
Downloads
6
Readme
BitHodl Service
Bitcore service to expose necessary endpoints for the BitHodl app.
Getting started
- Create a Bitcore node
- Install the BitHodl service:
$ npm install --save bithodl-service
- Open
bitcore-node.json
and setservices
to:
"bitcoind",
"web",
"bithodl-service"
- Start the node:
$ bitcored
Hacks
Bitcore Library will complain about multiple instances.
To workaround this, comment out line 12 in bithodl-service/node_modules/bitcore-lib/index.js
:
//throw new Error(message);
https://github.com/bitpay/bitcore/issues/1454
API
GET
/v1/public-key/:publicKey/addresses
Scans the UTXO set for addresses matching a public key (as a DER hex encoded string). Only time locked P2SH addresses generated by BitHodl will be returned.
Returns
Returns the addresses together with UTXO data as JSON.
GET
/v1/address/:address/utxos
Returns the unspent outputs for the given address.
Returns
Returns the unspent outputs as a JSON array.
GET
/v1/fee/estimate
Estimates the transaction fee based on the fees from the last 3 blocks.
Returns
Returns the estimated fee per byte in satoshis, e.g.
{
"satoshisPerByte": 4
}
POST
/v1/transaction
Broadcasts a transaction to the Bitcoin network. Body must be a serialized transaction in raw format (https://bitcoin.org/en/developer-reference#raw-transaction-format).
Returns
The txid
of the transaction.
Error handling
Errors are returned as JSON in the following format:
{
"error": "<error message>"
}
Use with testnet
During development and testing it is recommended to use the testnet network. By doing so you can use testnet coins and don't risk losing any real money. Running a testnet node is also much lighter than running a mainnet node.
Run the Bitcore node with testnet
Open
bitcore-node.json
and setnetwork
totestnet
instead oflivenet
.Configure the BitHodl Service to use testnet
Open
node_modules/bithodl-service/src/config.js
and setnetwork
totestnet
instead oflivenet
.Configure the BitHodl app to use testnet
You need to configure the app to use testnet and point it to your testnet node. This requires you to build and run the app yourself. Follow the instructions in the BitHodl app repo.
Contributing
Want to help us making BitHodl better? Great, but first read the CONTRIBUTING.md file for instructions.
Licensing
BitHodl is licensed under the Apache License, Version 2.0. See LICENSE for full license text.