Giter Site home page Giter Site logo

kryptokrona / kryptokrona-wallet-backend-js Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 2.48 MB

Kryptokrona library in JS/TS for building decentralized private communication and payment systems.

Home Page: https://kryptokrona.org

License: GNU Affero General Public License v3.0

TypeScript 99.76% JavaScript 0.24%
blockchain crypto cryptocurrency cryptography decentralized distributed-systems javascript kryptokrona nodejs typescript

kryptokrona-wallet-backend-js's Introduction

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.

kryptokrona-wallet-backend-js's People

Contributors

brandonlehmann avatar dependabot[bot] avatar f-r00t avatar marcuscvj avatar n9lsjr avatar sayuki0x avatar swepool avatar ux33-331 avatar zoidbergza avatar zpalmtree avatar

Stargazers

 avatar

Watchers

 avatar  avatar

kryptokrona-wallet-backend-js's Issues

Rename to kryptokrona-js-sdk

Should we perhaps rename this to kryptokrona-js-sdk? My take on it is that the current name is confusing and to rename it to such as suggested here could reduce that for new people coming to the project.

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.