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

multicryptowallet

v1.0.0

Published

Multi crypto-currencies wallet

Downloads

8

Readme

MultiWallet

NodeJS multiple crypto-currencies wallet bindings that exposes the same API for every currency.

Not intented for browsers.

It uses external lightweight clients.

Supported currencies are:

To-do:

  • Monero
  • Decred
  • Ripple

Install

Make sure your server has Electrum, Electrum-LTC, Electrum-Dash and ethereum-cli installed. Run each one of them after installing in order to create your wallet/seed. Then install the lib.

npm i multicryptowallet

Usage

Start by requiring the lib.

const MultiWallet = require('multicryptowallet')

Now you have to instantiate it. You can have multiple instances. Use "btc", "ltc", "dash" or "eth".

let btcWallet = new MultiWallet('btc')
let dashWallet = new MultiWallet('dash')

As second argument, you can set a few optional settings:

let btcWallet = new MultiWallet('btc', {
	bin: '/path/to/electrum', // if not on PATH environment variable
	args: '', // additional electrum arguments (appended)
	rpchost: '127.0.0.1',
	rpcport: 7777,
	rpcuser: 'admin',
	rpcpassword: 'strong-password-here',
	walletpassword: 'stronger-password',
	testnet: false,
	web3: 'https://mainnet.infura.io' // for Ethereum only
	})

It's recommended to run the three Electrum versions outside your NodeJS application. You do not need to run ethereum-cli outside, as it is used as a library, and not as a command.

If you prefer so, the library can also try to load Electrum versions for you. However we highly advise not to do so, as it may not work in some environments or may not be safe at all.

await btcWallet.init()

It will initialize Electrum, although it is not recommended. To stop Electrum process:

await btcWallet.shutdown()

Note: when using Ethereum, you MUST call init(). But shutdown is not required.

await ethWallet.init()

Generating address

let walletAddr = await Wallet.getNewAddress()
console.log("New address: "+walletAddr)

Getting wallet balance

let confirmedBalance = await Wallet.getBalance(1)
let unconfirmedBalance = await Wallet.getBalance(0)
console.log("Confirmed balance: "+confirmedBalance)
console.log("Unconfirmed balance: "+(unconfirmedBalance-confirmedBalance))

Getting another address balance

let walletConfBalance = await Wallet.getReceivedByAddress(walletAddr, 1)
let walletUnconfBalance = await Wallet.getReceivedByAddress(walletAddr, 0)
console.log("Wallet confirmed balance: "+walletConfBalance)
console.log("Wallet unconfirmed balance: "+(walletUnconfBalance-walletConfBalance))

Sending coins

let txId = await Wallet.sendToAddress('wallet', '0.0007')

Raw Transactions

Creating ("from_wallet" is required if using Ethereum):

let rawTx = await Wallet.createRawTx('destination_wallet', '0.001', 'from_wallet')

Signing ("from" is required if using Ethereum):

let signedRawTx = await Wallet.signTx(rawTx, from)

Pushing:

let txId = await Wallet.pushTx(signedRawTx)

Developing new bindings

In order to add support for new coins, copy the source code at docs/currency-bootstrap.js and implement the functions listed. Copy your file to "lib/currencies", renaming it to your currency's code.

A testing script is available through npm test. Edit it on the "test" folder.