The number of blocks to count ter upward direction.

A modern Bitcoin Core Surplus and RPC client to execute administrative tasks, wallet operations and queries about network and the blockchain.

Install the package via npm :

  1. [agentOptions] (Object): Optional tuut options to configure SSL/TLS.
  2. [headers=false] (boolean): Whether to comeback the response headers.
  3. [host=localhost] (string): The host to connect to.
  4. [logger=debugnyan(‘bitcoin-core’)] (Function): Custom-made logger (by default, debugnyan ).
  5. [network=mainnet] (string): The network
  6. [password] (string): The RPC server user password.
  7. [port=[network]] (string): The RPC server port.
  8. [ssl] (boolean|Object): Whether to use SSL/TLS with stringent checking (boolean) or an expanded config (Object).
  9. [ssl.enabled] (boolean): Whether to use SSL/TLS.
  10. [ssl.rigorous] (boolean): Whether to do stringent SSL/TLS checking (certificate vereiste match host).
  11. [timeout=30000] (number): How long until the request times out (ms).
  12. [username] (number): The RPC server user name.
  13. [version] (string): Which version to check methods for (read more).

The network will automatically determine the port to connect to, just like the bitcoind and bitcoin-cli instructions.

By default, when ssl is enabled, rigorous checking is implicitly enabled.

For compatibility with other Bitcoin Core clients.

Since version v0.14.0, it is possible to send directives via the JSON-RPC interface using named parameters instead of positional ones. This comes with the advantage of making the order of arguments irrelevant. It also helps improving the readability of certain function calls when leaving out arguments for their default value.

For example, take the getBalance() call written using positional arguments:

It is functionally omschrijving to using the named arguments account and minconf , leaving out include_watchonly (defaults to false ):

This feature is available to all JSON-RPC methods that accept arguments.

Due to JavaScript’s limited floating point precision, all big numbers (numbers with more than 15 significant digits) are returned spil strings to prevent precision loss. This includes both the RPC and Surplus APIs.

By default, all methods are exposed on the client independently of the version it is connecting to. This is the most supple option spil defining methods for unavailable RPC calls does not cause any harm and the library is capable of treating a Method not found response error correctly.

However, if you choose to be on the safe side, you can enable stringent version checking. This will validate all method calls before executing the actual RPC request:

If you want to enable stringent version checking for the bleeding edge version, you may set a very high version number to exclude recently deprecated calls:

To avoid potential issues with prototype references, all methods are still enumerable on the library client prototype.

Begin the bitcoind with the RPC server enabled and optionally configure a username and password:

Thesis configuration values may also be set on the bitcoin.conf verkeersopstopping of your toneel installation.

By default, port 8332 is used to listen for requests ter mainnet mode, or 18332 te testnet or regtest modes. Use the network property to initialize the client on the desired mode and automatically set the respective default port. You can optionally set a custom-built port of your choice too.

The RPC services ties to the localhost loopback network interface, so use rpcbind to switch where to truss to and rpcallowip to whitelist source IP access.

All RPC methods are exposed on the client interface spil a camelcase’d version of those available on bitcoind .

For a more finish reference about which methods are available, check the RPC documentation on the Bitcoin Core Developer Reference webstek.

Batched requests are support by passing an array to the directive method with a method and optionally, parameters . The terugwedstrijd value will be an array with all the responses.

Note that batched requests will only throw an error if the batch request itself cannot be processed. However, each individual response may contain an error akin to an individual request.

Support for the Surplus interface is still experimental and the API is still subject to switch. Thesis endpoints are also unauthenticated so there are certain risks which you should be aware, specifically of leaking sensitive gegevens of the knot if not correctly protected.

Error treating is still fragile so avoid passing user input.

Embark the bitcoind with the Surplus server enabled:

Thesis configuration values may also be set on the bitcoin.conf verkeersopstopping of your podium installation. Use txindex=1 if you’d like to enable total transaction query support (note: this will take a considerable amount of time on the very first run).

Given a block hash, comes back a block, te binary, hex-encoded binary or JSON formats.

  1. hash (string): The block hash.
  2. [options] (Object): The options object.
  3. [options.extension=json] (string): Terugwedstrijd ter binary ( bin ), hex-encoded binary ( hex ) or JSON ( json ) format.
  4. [callback] (Function): An optional callback, otherwise a Promise is returned.

Given a block hash, comebacks amount of block headers ter upward direction.

  1. hash (string): The block hash.
  2. count (number): The number of blocks to count te upward direction.
  3. [options] (Object): The options object.
  4. [options.extension=json] (string): Terugwedstrijd ter binary ( bin ), hex-encoded binary ( hex ) or JSON ( json ) format.
  5. [callback] (Function): An optional callback, otherwise a Promise is returned.

Comebacks various state informatie regarding block chain processing.

  1. [callback] (Function): An optional callback, otherwise a Promise is returned.

Comes back transactions te the transaction memory pool.

  1. [callback] (Function): An optional callback, otherwise a Promise is returned.

Comebacks various information about the transaction memory pool. Only supports JSON spil output format.

  • size: the number of transactions ter the transaction memory pool.
  • bytes: size of the transaction memory pool te bytes.
  • usage: total transaction memory pool memory usage.
  1. [callback] (Function): An optional callback, otherwise a Promise is returned.

Given a transaction hash, comebacks a transaction te binary, hex-encoded binary, or JSON formats.

  1. hash (string): The transaction hash.
  2. [options] (Object): The options object.
  3. [options.summary=false] (boolean): Whether to comeback just the transaction hash, thus saving memory.
  4. [options.extension=json] (string): Come back te binary ( bin ), hex-encoded binary ( hex ) or JSON ( json ) format.
  5. [callback] (Function): An optional callback, otherwise a Promise is returned.

Query unspent transaction outputs (UTXO) for a given set of outpoints. See BIP64 for input and output serialisation.

  1. outpoints (array<,Object>,|Object): The outpoint to query te the format < id: ‘<,txid>,’, index: ‘<,index>,’ >.
  2. [options] (Object): The options object.
  3. [options.extension=json] (string): Come back ter binary ( bin ), hex-encoded binary ( hex ) or JSON ( json ) format.
  4. [callback] (Function): An optional callback, otherwise a Promise is returned.

This client supports SSL out of the opbergruimte. Simply pass the SSL public certificate to the client and optionally disable stringent SSL checking which will bypass SSL validation (the connection is still encrypted but the server it is connecting to may not be trusted). This is, of course, discouraged unless for testing purposes when using something like self-signed certificates.

Please note that the following proces should only be used for testing purposes.

Generate an self-signed certificate together with an unprotected private key:

On Bitcoin Core <,0.12, you can begin the bitcoind RPC server directly with SSL:

On Bitcoin Core >,0.12, use vereiste use stunnel ( brew install stunnel or sudo apt-get install stunnel4 ) or an HTTPS switch roles proxy to configure SSL since the built-in support for SSL has bot eliminated. The trade off with stunnel is spectacle and plainness versus features, spil it lacks more powerful capacities such spil Basic Authentication and caching which are standard te switch sides proxies.

You can use stunnel by configuring stunnel.conf with the following service requirements:

The key option may be omitted if you concatenating your private and public certificates into a single stunnel.pem opstopping.

On some versions of stunnel it is also possible to embark a service using instruction line arguments. The omschrijving would be:

Then pass the public certificate to the client:

By default, all requests made with bitcoin-core are logged using uphold/debugnyan with bitcoin-core spil the logging namespace.

Please note that all sensitive gegevens is obfuscated before calling the logger.

Example output defining the environment variable DEBUG=bitcoin-core :

A custom-built logger can be passed via the logger option and it should implement bunyan’s loom levels.

Presently the test suite is tailored for Docker (including docker-compose ) due to the multitude of different bitcoind configurations that are required te order to get the test suite passing.

To test using a local installation of knot.js but with dependencies (e.g. bitcoind ) running inwards Docker:

To test using Docker exclusively (similarly to what is done te Travis CI):

Related movie: Bitcoin earning spel crazy edit… Bitcoin wonder machine


Leave a Reply