npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

traaittplatform-wallet-backend

v5.1.3

Published

![image](https://github.com/TRRXITTE/traaittPlatform/blob/master/docs/etrx.png)

Downloads

21

Readme

image

Master Build Status

Build Status

NPM

NPM

Github

https://github.com/trrxitte/traaittplatform-wallet-backend-js

traaittplatform-wallet-backend

Provides an interface to the traaittPlatform 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

Installation

NPM:

npm install traaittplatform-wallet-backend --save

Yarn:

yarn add traaittplatform-wallet-backend

Installation from GitHub

If you need features which have not yet made it into a release, you can install from GitHub.

NPM:

npm install https://github.com/traaittplatform/traaittplatform-wallet-backend-js --save

Yarn:

yarn add https://github.com/traaittplatform/traaittplatform-wallet-backend-js

Documentation

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('traaittplatform-wallet-backend').

Quick Start

You can find an example project in the examples folder.

Javascript

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

(async () => {
    const daemon = new WB.Daemon('127.0.0.1', 24496);
    /* OR
    const daemon = new WB.Daemon('blockapi.turtlepay.io', 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 */
    wallet.stop();
})().catch(err => {
    console.log('Caught promise rejection: ' + err);
});

Typescript

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

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

    /* OR
    const daemon: IDaemon = new Daemon('blockapi.turtlepay.io', 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 */
    wallet.stop();
})().catch(err => {
    console.log('Caught promise rejection: ' + err);
});

Configuration

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:

wallet.scanCoinbaseTransactions(true)

Logging

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

wallet.setLogLevel(WB.LogLevel.DEBUG);

and in typescript:

wallet.setLogLevel(LogLevel.DEBUG);

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)) {
        console.log(prettyMessage);
    }
});

and in typescript:

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

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

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

Changelog

v4.0.8

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

v4.0.7

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

v4.0.6

  • Bump traaittplatform-utils to fix issue in some environments

v4.0.5

  • 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

v4.0.4

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

v4.0.3

  • Update traaittplatform-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

v4.0.2

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

v4.0.1

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

v4.0.0

  • 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

v3.4.12

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

v3.4.11

  • Add on('deadnode') event

v3.4.10

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

v3.4.9

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

v3.4.8

  • 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.

v3.4.7

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

v3.4.6

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

v3.4.5

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

v3.4.4

  • 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

v3.4.3

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

v3.4.2

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

v3.4.1

  • Fix transactions being broken

v3.4.0

  • 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

v3.3.2

  • 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

v3.3.1

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

v3.3.0

  • Adds swapNode() method

v3.2.0

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

v3.1.1

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

v3.1.0

  • 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.

v3.0.1

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

v3.0.0

  • 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 traaittPlatform config will be used.

v2.0.0

Start of changelog.

Contributing

Building (For Developers)

git clone https://github.com/traaittplatform/traaittplatform-wallet-backend-js.git

cd traaittplatform-wallet-backend

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

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 built the JavaScript code from the TypeScript code: yarn build
  • 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.
  • Ensure your code adheres to the style requirements: yarn style

You can try running yarn style --fix to automatically fix issues.