25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jojapoppa 2186bd6b77 build.. 4 달 전
dist build.. 4 달 전
examples/example1 initial checkin 5 달 전
lib build.. 4 달 전
tests build.. 4 달 전
.gitignore docs 5 달 전
LICENSE initial checkin 5 달 전
README.md docs 5 달 전
build.sh build working... 5 달 전
info.txt initial checkin 5 달 전
package.json build.. 4 달 전
tsconfig.json initial checkin 5 달 전
typedoc.js initial checkin 5 달 전
yarn.lock build.. 4 달 전

README.md

Javascript backend for fedoragold wallet (a javascript walletd)

image]

Github

https://git.fedoragold.com/jojapoppa/fedoragold-wallet-backend.git

fedoragold-wallet-backend

Provides an interface to the FedoraGold (FED) 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

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

Quick Start

You can find an example project in the examples folder.

Javascript

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

(async () => {
    const daemon = new WB.Daemon('127.0.0.1', 11898);
    /* 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 'fedoragold-wallet-backend';

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

    /* 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

v6.0.7

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

v6.0.6

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

v6.0.5

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

v6.0.4

  • Fix issue generating transactions with a ledger

v6.0.3

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

v6.0.2

  • Fix object-sizeof being incorrectly imported

v6.0.2

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

v6.0.0

  • 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

v5.0.4

  • 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

v5.0.3

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

v5.0.2

  • Fix prepared transactions being incorrectly stored

v5.0.1

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

v5.0.0

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

Building (For Developers)

`git clone https://git.fedoragold.com/jojapoppa/fedoragold-wallet-backend

cd fedoragold-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.