Index
Wallet-lib
A pure and extensible JavaScript Wallet Library for Dash
What it is
Wallet-lib provides all the wallet features needed for node and browser usage. From being able to display an account balance, to paying to another address, passing by the need to automate back-end task related to a cold-storage.
Wallet-lib allows you to easily work with Wallets/Accounts for HDWallets, or from just a single private key.
It also allows you to monitor public keys and HDPubKey.
You might also wish to create your own set of plugins or your own coin selection logic.
Install
ES5/ES6 via NPM
In order to use this library in Node, you will need to add it to your project as a dependency.
Having NodeJS installed, just type in your terminal :
npm install @dashevo/wallet-lib
CDN Standalone
For browser usage, you can also directly rely on unpkg :
<script src="https://unpkg.com/@dashevo/wallet-lib"></script>
Usage
In your file, where you want to execute it :
const { Wallet, EVENTS } = require('@dashevo/wallet-lib');
const wallet = new Wallet();
// We can dump our initialization parameters
const mnemonic = wallet.exportWallet();
// Hook on headers and TX sync progress events
wallet.on(EVENTS.HEADERS_SYNC_PROGRESS, (progressInfo) => {
const {
confirmedProgress,
totalProgress,
confirmedSyncedCount,
totalSyncedCount,
totalCount
} = progressInfo;
})
wallet.on(EVENTS.TRANSACTIONS_SYNC_PROGRESS, (progressInfo) => {
const {
progress,
syncedBlocksCount,
totalBlocksCount,
transactionsCount
} = progressInfo;
})
wallet.getAccount().then((account) => {
// At this point, account has fetch all UTXOs if they exists
const balance = account.getTotalBalance();
console.log(`Balance: ${balance}`);
// We easily can get a new address to fund
const { address } = account.getUnusedAddress();
});
Licence
MIT © Dash Core Group, Inc.