A modern Altcoin Core REST and RPC client to execute administrative tasks, wallet operations and queries about network and the blockchain.
Install the package via npm:
The network will automatically determine the port to connect to, just like the bitcoind and bitcoin-cli commands.
By default, when ssl is enabled, strict checking is implicitly enabled.
For compatibility with other Altcoin Core clients.
Since version v0.14.0, it is possible to send commands 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 instance, take the getBalance() call written using positional arguments:
It is functionally equivalent 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.
By default, all methods are exposed on the client independently of the version it is connecting to. This is the most flexible option as defining methods for unavailable RPC calls does not cause any harm and the library is capable of handling a Method not found response error correctly.
However, if you prefer to be on the safe side, you can enable strict version checking. This will validate all method calls before executing the actual RPC request:
If you want to enable strict 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.
Start the bitcoind with the RPC server enabled and optionally configure a username and password:
These configuration values may also be set on the bitcoin.conf file of your platform installation.
By default, port 8332 is used to listen for requests in mainnet mode, or 18332 in 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 port of your choice too.
The RPC services binds to the localhost loopback network interface, so use rpcbind to change where to bind to and rpcallowip to whitelist source IP access.
All RPC methods are exposed on the client interface as a camelcase'd version of those available on bitcoind.
For a more complete reference about which methods are available, check the RPC documentation on the Altcoin Core Developer Reference website.
Batched requests are support by passing an array to the command method with a method and optionally, parameters. The return 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 REST interface is still experimental and the API is still subject to change. These endpoints are also unauthenticated so there are certain risks which you should be aware, specifically of leaking sensitive data of the node if not correctly protected.
Error handling is still fragile so avoid passing user input.
Start the bitcoind with the REST server enabled:
These configuration values may also be set on the bitcoin.conf file of your platform installation. Use txindex=1 if you'd like to enable full transaction query support (note: this will take a considerable amount of time on the first run).
Given a block hash, returns a block, in binary, hex-encoded binary or JSON formats.
Given a block hash, returns amount of block headers in upward direction.
Returns various state info regarding block chain processing.
Returns transactions in the transaction memory pool.
Returns various information about the transaction memory pool. Only supports JSON as output format.
Given a transaction hash, returns a transaction in binary, hex-encoded binary, or JSON formats.
Query unspent transaction outputs (UTXO) for a given set of outpoints. See BIP64 for input and output serialisation.
This client supports SSL out of the box. Simply pass the SSL public certificate to the client and optionally disable strict 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 procedure should only be used for testing purposes.
Generate an self-signed certificate together with an unprotected private key:
On Altcoin Core <0.12, you can start the bitcoind RPC server directly with SSL:
On Altcoin Core >0.12, use must use stunnel (brew install stunnel or sudo apt-get install stunnel4) or an HTTPS reverse proxy to configure SSL since the built-in support for SSL has been removed. The trade off with stunnel is performance and simplicity versus features, as it lacks more powerful capacities such as Basic Authentication and caching which are standard in reverse 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 file.
On some versions of stunnel it is also possible to start a service using command line arguments. The equivalent would be:
Then pass the public certificate to the client:
By default, all requests made with altcoin-rpc are logged using uphold/debugnyan with altcoin-rpc as the logging namespace.
Please note that all sensitive data is obfuscated before calling the logger.
Example output defining the environment variable DEBUG=altcoin-rpc:
A custom logger can be passed via the logger option and it should implement bunyan's log levels.
Currently the test suite is tailored for Docker (including docker-compose) due to the multitude of different bitcoind configurations that are required in order to get the test suite passing.
To test using a local installation of node.js but with dependencies (e.g. bitcoind) running inside Docker:
To test using Docker exclusively (similarly to what is done in Travis CI):
- 3 Reasons Why Ethereum Price Rallied 75% to Hit a 2-Year High at $400 - Cointelegraph - August 2nd, 2020
- Bitcoin SV Price Analysis: BSV/USD takes the altcoin rally a notch higher, approaching $250 - FXStreet - August 2nd, 2020
- DataDash: Two Crypto Newcomers Will Surge Alongside Bitcoin, Ethereum and XRP in New Bull Cycle - The Daily Hodl - August 2nd, 2020
- As Altcoin Season Presses on, Whats Next for Crypto Futures? - Finance Magnates - July 31st, 2020
- Altcoin Price Analysis Bitcoin Cash, Tezos and IOTA: BCH/USD and IOT/USD look to break past key levels - FXStreet - July 31st, 2020
- Bitcoin Price Touched $11,400, Altcoin Season Over? - CryptoPotato - July 31st, 2020
- Bitcoin Struggles At $11,000: Altcoins Starting To Regain Momentum? - CryptoPotato - July 31st, 2020
- Litecoin spikes 10% to lead top altcoin gains today | CoinJournal.net - CoinJournal - July 31st, 2020
- As Bitcoin tops $11,000 level, investor interest in India on the rise - Livemint - July 31st, 2020
- Long Gold, and Long Cryptos - InvestorPlace - July 31st, 2020
- Cardano and Litecoin Lead the Altcoin Market - Somag News - July 27th, 2020
- Top Analyst Bullish on Ethereum and Five Altcoins, Says Bitcoin Wont Lead Surge in Crypto Market Cap - The Daily Hodl - July 27th, 2020
- Bitcoin Analyst Says Crypto Traders Who Ignore Two Emerging Trends Will Miss Out, Warns Altcoins Set for Pullback - The Daily Hodl - July 27th, 2020
- Ethereum 2.0 validator testnet goes live: ETH Research Team - AMBCrypto - July 27th, 2020
- Altcoin Market Update: Akropolis and Ocean Protocol are unstoppable lately thanks to DeFi bull... - Forex Crunch - July 27th, 2020
- Prominent Bitcoin Whale Predicts Mass Altcoin Extinction Ahead of Next BTC Rally - The Daily Hodl - July 5th, 2020
- PrimeXBT Comparison: Will DeFi Defy The ICO-Fueled Ethereum All-Time High? - Ethereum World News - July 4th, 2020
- These Altcoins Set a New ATH While Bitcoin And Ethereum Tank | NewsBTC - newsBTC - July 4th, 2020
- Renowned analyst predicts Bitcoin to outperform altcoins in 2021 - FXStreet - July 4th, 2020
- Ouroboros, as explained by IOHK researchers - Altcoin Buzz - July 4th, 2020
- XRP Price Can Outperform Bitcoin in the Short Term Heres Why - Cointelegraph - July 4th, 2020
- Ethereum, Chainlink and Tezos price analysis: June 28 - AMBCrypto - June 29th, 2020
- This top-30 altcoin is integrating with Chainlink (LINK) for bolstering smart contract ecosystem - CryptoSlate - June 29th, 2020
- Brutal Drop In Altcoins Anticipated as Bitcoin Dominance Projected to Surge | NewsBTC - newsBTC - June 29th, 2020
- Chainlink (LINK) Near New All-Time High Heres 3 Reasons for the Rally - Cointelegraph - June 29th, 2020
- Pantera Capital: Bitcoin Set to Begin Meteoric Bull Run But Ethereum and Certain Altcoins Will Outperform BTC - The Daily Hodl - June 29th, 2020
- Most traded crypto in June 2020: are we in the altcoin season? - Capital.com - June 20th, 2020
- Top 3 Price Prediction Bitcoin, Ethereum, Ripple: Altcoin season just around the corner - FXStreet - June 20th, 2020
- Top Crypto Strategist Predicts Bitcoin (BTC) Will Surpass $20,000 in Just Two Months With Ethereum Leading Next Altcoin Rally - The Daily Hodl - June 17th, 2020
- Liquidations May Loom as Altcoin Bulls Hold Despite Shorts Spiking - Cointelegraph - June 13th, 2020
- Tether.io becomes second largest altcoin behind Ethereum tokens - HedgeWeek - June 13th, 2020
- ETH Miners Will Have Little Choice Once Ethereum 2.0 Launches With PoS - Cointelegraph - June 13th, 2020
- Sparks fly as developer suggests an altcoin will overtake Bitcoin in the next five years - CryptoSlate - June 9th, 2020
- Bitcoin Price To Hit $150,000; Ethereum At $9,000 In Next Bull Run, Blockfyre Founder Predicts - International Business Times - June 9th, 2020
- Despite Its Recent Controversy, This is the Latest Altcoin Ready to Moon - Bitcoin Exchange Guide - June 9th, 2020
- Why An Even Deeper Correction Is Expected For The Crypto Markets Hottest Altcoin | NewsBTC - newsBTC - June 8th, 2020
- Analyst Predicts Next Bull Run Will Send Bitcoin to $150K and Ether to $9K - Cointelegraph - June 8th, 2020
- Venture Capitalist Predicts Bitcoin Boom to $150,000, Says Ethereum and Four Altcoins Will Outperform BTC - The Daily Hodl - June 8th, 2020
- Stocks aren't the only asset climbing - InvestorPlace - June 8th, 2020
- Cryptocurrency in Undeveloped Nations - Altcoin Buzz - June 8th, 2020
- Ethereum, Binance Coin, Algorand Price Analysis: 03 June - AMBCrypto English - June 8th, 2020
- Ethereum looks bullish as its fees surpassed BTC's on June 7 - CoinJournal - June 8th, 2020
- Crypto Index Analysis: Boosted by altcoin breakout - Capital.com - June 2nd, 2020
- Ethereums price rush may run out of steam - AMBCrypto English - June 2nd, 2020
- ETH showing strong signals as EOS and XRP likely to regress - CoinJournal - June 2nd, 2020
- Cardano and Ethereum Price Surge Alongside Bitcoin Will XLM Follow? - Cointelegraph - June 1st, 2020
- Ethereum Chart Makes It Clear: Altcoin Season Is Already Over | NewsBTC - newsBTC - June 1st, 2020
- Max Keiser: There Isn't Anything Crypto Altcoins Do That Bitcoin Won't Do - Bitcoinist - June 1st, 2020
- Altcoins Outpace Bitcoin in Broad Crypto Rally: Cardano and Ethereum Biggest Gainers - The Daily Hodl - June 1st, 2020
- Are Altcoins Silver To Bitcoin As Gold? Unusual Correlation Discovered | NewsBTC - newsBTC - May 20th, 2020
- Polkadot: The Interoperable Blockchain Network - Altcoin Projects - Altcoin Buzz - May 20th, 2020
- Beware: this altcoins price action could be part of a pump and dump scheme - CryptoSlate - May 18th, 2020
- Is Tezos rapid progress a threat to both Bitcoin and Ethereum? - AMBCrypto English - May 18th, 2020
- XTZ Price Analysis: Bears Take a Breather on XTZ/USD As Price Swings Past $2.6, Tezos Becomes 2020 Altcoin With STO Pipeline Projects - Latest Crypto... - May 18th, 2020
- Bitcoin Cash struggles with negative pressure, while VET & LINK trend higher - AMBCrypto - May 15th, 2020
- Stellar Cryptocurrency Prints a TD9: Heres Why It Means More Upside is Likely - newsBTC - May 15th, 2020
- As Halving Nears, Ethereum (ETH) Stands More Chances Amid Altcoins - KryptoMoney - May 12th, 2020
- Heres Why Altcoins Bouncing as Bitcoin Retraced From $10K Is Bullish - Cointelegraph - May 11th, 2020
- Crypto scams are on the rise: 5 ways to avoid them - Livemint - May 11th, 2020
- Ethereum, Stellar Lumens, VET bounce back as alts resist corrections - AMBCrypto English - May 11th, 2020
- Coronavirus & Altcoins: Why are Some Crypto Assets Beating Bitcoin? - Finance Magnates - May 5th, 2020
- Binance Widget Incorporated on Brave Browser - Altcoin Buzz - May 5th, 2020
- Altcoins Face The Most Important Weekly Close in Crypto History - newsBTC - May 2nd, 2020
- Crypto Analyst: Bitcoin (BTC) Selloff Coming Heres Why Ethereum (ETH), XRP and Altcoin Market May Rise in Short Term - The Daily Hodl - May 2nd, 2020
- Bitcoin Yearly Moving Average Price Closes in on All-Time High - BeInCrypto - May 2nd, 2020
- Altcoins Could Get Crushed By BTC Halving Volatility, Heres Why - newsBTC - April 29th, 2020
- XRP, XLM, and ADA Win Big as Bitcoin Speculators Turn to Altcoins - ZyCrypto - April 29th, 2020
- 7 Explosive Cryptocurrencies to Buy for the Bitcoin Halvening - Investorplace.com - April 29th, 2020
- Neo (NEO) Bulls Again Going Against The Resistance Of $9.00 With Strong Pace - The Coin Republic - April 29th, 2020
- Accurate Crypto Sell Signal Issued For Two Top Performing Altcoins - newsBTC - April 26th, 2020
- 3 Reasons Why XRP is Unlikely to Benefit From Ongoing Altcoin Surge - Bitcoinist - April 26th, 2020
- Litecoin News Today - Litecoin LTC Climbs to $42 As Altcoin Market Resumes Recovery - April 23rd, 2020 - Smartereum - April 26th, 2020
- Ethereum [ETH] Makes 95% of the Altcoin Inflows in Q1 to Grayscale Trust Fund - Coingape - April 26th, 2020
- Chainlink, Ethereum lead altcoin recovery effort as BAT stalls - AMBCrypto English - April 26th, 2020
- Dogecoin (DOGE) Price Analysis: Dogecoin Price Shows Sustainability Over $0.0020 To Avoid Break Below The ... - The Coin Republic - April 26th, 2020
- Crypto Billionaire Says One Altcoin Reminds Him of Bitcoin and Ethereums Early Days - The Daily Hodl - April 20th, 2020
- 420 Day in Crypto: Remembering the Class of Altcoins That Went Up in Smoke - Bitcoinist - April 20th, 2020
- Bitcoin Halving: Can Ripple (XRP), Litecoin and other altcoins benefit? - Crypto News Flash - April 20th, 2020
- Ethereum 2.0 Precursor Topaz Testnet Released - Product Release & Updates - Altcoin Buzz - April 20th, 2020
- Why tokens are not the same thing as Bitcoin - CoinGeek - April 20th, 2020