Skip to content
Switch branches/tags






Provides an interface to the TurtleCoin network, allowing wallet applications to be built.

  • Downloads blocks from the network, either through a traditional daemon, or a blockchain cache for increased speed
  • Processes blocks, decrypting transactions that belong to the user
  • Sends and receives transactions



npm install turtlecoin-wallet-backend --save


yarn add turtlecoin-wallet-backend


You can view the documentation here

You can see a list of all the other classes on the right side of the screen. Note that you will need to prefix them all with WB. to access them, if you are not using typescript style imports, assuming you imported with const WB = require('turtlecoin-wallet-backend').

Quick Start

You can find an example project in the examples folder.


const WB = require('turtlecoin-wallet-backend');

(async () => {
    const daemon = new WB.Daemon('', 11898);
    /* OR
    const daemon = new WB.Daemon('', 443);

    const wallet = WB.WalletBackend.createWallet(daemon);

    console.log('Created wallet');

    await wallet.start();

    console.log('Started wallet');

    wallet.saveWalletToFile('mywallet.wallet', 'hunter2');

    /* Make sure to call stop to let the node process exit */
})().catch(err => {
    console.log('Caught promise rejection: ' + err);


import { WalletBackend, Daemon, IDaemon } from 'turtlecoin-wallet-backend';

(async () => {
    const daemon: IDaemon = new Daemon('', 11898);

    /* OR
    const daemon: IDaemon = new Daemon('', 443);

    const wallet: WalletBackend = WalletBackend.createWallet(daemon);

    console.log('Created wallet');

    await wallet.start();

    console.log('Started wallet');

    wallet.saveWalletToFile('mywallet.wallet', 'hunter2');

    /* Make sure to call stop to let the node process exit */
})().catch(err => {
    console.log('Caught promise rejection: ' + err);


There are a few features which you may wish to configure that are worth mentioning.

Auto Optimize

Auto optimization is enabled by default. This makes the wallet automatically send fusion transactions when needed to keep the wallet permanently optimized.

To enable/disable this feature, use the following code:

wallet.enableAutoOptimization(false); // disables auto optimization

Coinbase Transaction Scanning

By default, coinbase transactions are not scanned. This is due to the majority of people not having solo mined any blocks.

If you wish to enable coinbase transaction scanning, run this line of code:



By default, the logger is disabled. You can enable it like so:


and in typescript:


The logger uses console.log, i.e. it outputs to stdout.

If you want to change this, or want more control over what messages are logged, you can provide a callback for the logger to call.

wallet.setLoggerCallback((prettyMessage, message, level, categories) => {
    if (categories.includes(WB.LogCategory.SYNC)) {

and in typescript:

wallet.setLoggerCallback((prettyMessage, message, level, categories) => {
    if (categories.includes(LogCategory.SYNC)) {

In this example, we only print messages that fall into the SYNC category.

You can view available categories and log levels in the documentation.



  • Fix bug when scanning coinbase transactions and not using /sync/raw


  • Upgrade turtlecoin-utils and other dependencies
  • Documentation updates
  • Test suite updates


  • Fix issue halting sync when transaction is missing a transaction public key


  • Fix issue generating transactions with a ledger


  • Update turtlecoin-utils
  • New events emitted when a ledger is waiting for user input


  • Fix object-sizeof being incorrectly imported


  • Fix bug where package.json was not correctly read in npm release


  • Supports v1.0.0 daemon API
  • No longer supports v0.28.3 daemon API
  • Supports using a ledger nano to control private keys
  • Can specify whether you want to sync with raw blocks or not when initializing daemon
  • Fix auto optimize disabling not working correctly
  • Warn users when using non native crypto
  • Can send extra data with tx
  • More prepared transaction functions


  • Sleeping between block download failures or when fully synced has been re-added, in a more effective way.
  • sendTransactionBasic and sendTransactionAdvanced now also returns the node fee and destinations sent to.
  • Fusion transactions are now fixed


  • It is now possible to specify multiple destinations when setting sendAll. See the new docs for more information.


  • Fix prepared transactions being incorrectly stored


  • Fix storing prepared transactions not working after loading from file
  • Fix relayToNetwork parameter not being respected


  • Add fee per byte support
  • Add sendPreparedTransaction
  • Add sendRawPreparedTransaction
  • Add deletePreparedTransaction
  • Add includeFusions param to getNumTransactions
  • Improved transaction logging

Breaking Changes

The return type of both sendTransactionBasic and sendTransactionAdvanced has changed. The type of the fee parameter for sendTransactionAdvanced has changed.


  • Fix rare failure to sync when swapping from non cache node to cache node with blocks stored
  • Fix failure to sync when enabling coinbase transaction scanning with blocks stored
  • Disable sleeping between block download failures
  • Log all public function calls in WalletBackend class
  • Fix issue where transactions would be incorrectly reported as errored


  • Amount of blocks per request will ramp up/down as requests succeed/fail.
  • More detailed logging


  • Bump turtlecoin-utils


  • Allow passing custom checkRingSignatures to turtlecoin-utils
  • Bump turtlecoin-utils to support passing checkRingSignatures


  • Bump turtlecoin-utils to fix issue where transaction signatures would be misordered when supplying a custom generateRingSignatures function


  • Bump turtlecoin-utils to fix issue in some environments


  • Add a subwallets beta. API may change. Functionality may be buggy.
  • No longer will create inputs of over than 1 billion in transactions to prevent creating unmixable funds
  • Export the validateAddress() function
  • Add getConnectionString(), for retrieving the daemon connection ip:port pair
  • Add an optional subwallet address filter for getTransactions


  • Allow passing custom options to request() calls
  • Allow making an empty string a valid paymentID false


  • Update turtlecoin-utils
  • Add error code DAEMON_STILL_PROCESSING returned when a transaction may or may not have failed
  • Fix bug causing balance double counts with fusions in rare case


  • Fix package.json not being published to NPM causing require() fail


  • Fix auto-optimize not functioning after loading from file
  • Increase node threadpool size to prevent issues with timeouts
  • Sort outputs before requesting random outs


  • Adds a TRACE log level for logging of daemon request+response data
  • Adds a simpler validateAddress function to the ValidateParameters module
  • Slightly improves the Auto Optimization implementation
  • Removes BlockchainCacheApi and ConventionalDaemon - Please use Daemon instead
  • Returns additional information from transaction failure when available
  • More logging information added
  • Transaction creation process sped up by not re-generating keyimages


  • Adds a customizable user agent option to the config
  • Ring signatures are now always checked before sending


  • Add on('deadnode') event


  • Calculate balance in an alternative way which fixes historical balances being incorrect after a rewind > 5000 blocks


  • Fix heightchange being emitted on topblock when there are still blocks remaining to be processed


  • on('heightchange') is now emitted when reset(), rewind(), or rescan() is used.
  • on('heightchange') is now emitted when a top block is stored, fixing wallet height lagging behind network height.


  • Fix issue with removeForkedTransactions, which also effected rewind()


  • Add rewind()
  • Add on('heightchange') event
  • More improvements to keep-alive, max sockets, etc


  • Fix bug causing balance from sent transaction to appear in both locked + unlocked balance


  • Fix bug with how forked transactions were handled
  • Increase max sockets to use with request to fix timeouts in some environments
  • Fix bug where transactions to yourself had an incorrect amount when locked


  • Add on('disconnect') and on('connect') events for daemon
  • Update turtlecoin-utils dependency


  • Set keep-alive to true for Daemon and BlockchainCacheApi
  • Use IP regex instead of net module to allow working in non node environments


  • Fix transactions being broken


  • Add type assertions for JavaScript users
  • May possibly break your code if you were using implicit conversions to pass strings as numbers, etc
  • Fix bug where cancelledTransactionsFailCount was not correctly initialized when loading from file
  • Fix warning when using TLS with raw IP address
  • Known regression - Transactions are broken. Update to 3.4.1


  • Migrate from node-fetch to request for BlockchainCacheApi as it works better in odd environments
  • Remove maxBodyRequestSize property as abort-controller significantly complicated code and didn't work in odd environments
  • Known regression - Transactions are broken. Update to 3.4.1


  • Improve auto optimization
  • Update turtlecoin-utils dependency
  • Known regression - Transactions are broken. Update to 3.4.1


  • Adds swapNode() method


  • Adds getDaemonConnectionInfo() method
  • Removes compiled JavaScript from GitHub - GitHub install is no longer supported


  • Fixes bug where wallet may not correctly halt after calling stop().


  • Adds Daemon class. This class supports Blockchain cache api's, conventional daemons, http and https, all automatically.
  • Marks ConventionalDaemon and BlockchainCacheApi as deprecated. These will be removed in v4.0.0. Please use the Daemon class instead.


  • Fix issue where reset() would cause double wallet scanning.


  • Fix bug where using multiple wallet instances with different configs would only use the latest config.
  • API change - You must now provide a config to the Utilities/ValidateParameters functions if you are using a non default config, for example if you are using the library for another cryptocurrency. Otherwise, the default TurtleCoin config will be used.


Start of changelog.


Building (For Developers)

git clone

cd turtlecoin-wallet-backend

npm install -g yarn (Skip this if you already have yarn installed)

yarn install

yarn build

Generated javascript files will be written to the dist/lib/ folder.

Running tests

yarn test - This will run the basic tests

yarn test-all - This will run all tests, including performance tests.

Before making a PR

  • Ensure you are editing the TypeScript code, and not the JavaScript code (You should be in the lib/ folder)
  • Ensure you have updated the documentation if necessary - Documentation is generated from inline comments, jsdoc style.
  • Ensure you have rebuilt the documentation, if you have changed it: yarn docs
  • Ensure the tests all still pass: yarn test, or yarn test-all if you have a local daemon running.
  • If adding a feature/fixing a bug, adding a test to verify your fix/feature functions as expected would be great. But don't sweat it.