2.5.5 • Published 2 months ago

kryptokrona-wallet-backend-js v2.5.5

Weekly downloads
6
License
AGPL-3.0
Repository
-
Last release
2 months ago

image

Master Build Status

Build Status

NPM

https://www.npmjs.com/package/kryptokrona-wallet-backend-js

Github

https://github.com/kryptokrona/kryptokrona-wallet-backend-js

Kryptokrona-wallet-backend

Provides an interface to the Kryptokrona 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 kryptokrona-wallet-backend-js --save

Yarn:

yarn add kryptokrona-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('kryptokrona-wallet-backend-js').

Javascript

const WB = require('kryptokrona-wallet-backend-js');

(async () => {
    const daemon = new WB.Daemon('127.0.0.1', 11898);
    
    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 } from 'kryptokrona-wallet-backend-js';

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

    const wallet: WalletBackend = await 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.

2.5.5

2 months ago

2.5.4

2 months ago

2.5.3

2 months ago

2.5.2

5 months ago

2.5.0

10 months ago

2.5.1

9 months ago

2.4.3

1 year ago

2.4.5

1 year ago

2.4.4

1 year ago

2.4.2

2 years ago

2.4.1

2 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.0.0

3 years ago

1.9.0

4 years ago

1.7.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

7.8.0

4 years ago

7.7.0

4 years ago

7.5.0

4 years ago

7.4.0

4 years ago

4.3.1

4 years ago

5.3.1

4 years ago

6.3.1

4 years ago

3.3.1

4 years ago

2.3.1

4 years ago

1.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago