Giter VIP home page Giter VIP logo

hdwallet's Introduction

hdwallet

Build Status Coverage Status npm version

js-standard-style

Installation

$ npm i hdwallet

Constructor

var HDWallet = require('hdwallet')

var hd = new HDWallet({
  settings = settings || {}
  redisPort: 'optional',
  redisHost: 'optional',
  network: 'optional',
  mnemonic: 'optional',
  privateSeed: 'optional' // deprecated
})

API's

HDWallet.encryptPrivateKey(privateWif, password, progressCallback)	// BIP38
HDWallet.decryptPrivateKey(encryptedPrivKey, password, network, progressCallback)  // BIP38
HDWallet.createNewKey(network, password, progressCallback)
HDWallet.generateMnemonic()  // BIP39
HDWallet.validateMnemonic()  // BIP39
HDWallet.getInputAddresses(txHex, network)
HDWallet.sign(unsignedTxHex, privateKey)
HDWallet.prototype.init(cb)
HDWallet.prototype.afterRedisInit(cb)
HDWallet.prototype.getKeyPrefix()
HDWallet.prototype.getSavedKey(key, cb)
HDWallet.prototype.getNextAccount(cb)
HDWallet.prototype.setNextAccount(nextAccount)
HDWallet.prototype.registerAddress(address, accountIndex, addressIndex, change)
HDWallet.prototype.setDB(key, value)
HDWallet.prototype.getAddressPrivateKey(address, cb)
HDWallet.prototype.getAddressPath(address, cb)
HDWallet.prototype.discover(cb)
HDWallet.prototype.discoverAccount(accountIndex, cb)
HDWallet.prototype.discoverAddress(accountIndex, addressIndex, interval, cb)
HDWallet.prototype.registerAccount(account)
HDWallet.prototype.getPrivateSeed()
HDWallet.prototype.getMnemonic()
HDWallet.prototype.getPrivateKey(account, addressIndex)
HDWallet.prototype.getPublicKey(account, addressIndex)
HDWallet.prototype.isAddressActive(addresses, cb)
HDWallet.prototype.getAddress(account, addressIndex)
HDWallet.prototype.sign(unsignedTxHex, cb)

Testing

$ mocha

License

Apache-2.0

hdwallet's People

Contributors

assafshomer avatar bejavu avatar mdemri avatar tal-beja avatar thehobbit85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hdwallet's Issues

isValidSeed is not working correct

I had hard times convincing Colu SDK to accept privateSeed generated from mnemonic (BIP39, implementation by Bitcore). It failed on isValidSeed step saying "privateSeed should be a 256 bits hex (64 chars), if you are using WIF, use privateSeedWIF instead.". If I comment out this check, everything works correct.

Here is the code to test. It derives an address from mnemonic using Bitcore and then tries to do the same with Colu. Same addresses are expected to be derived.

var Colu = require('colu');
var bitcore = require('bitcore-lib');

var Mnemonic = require('bitcore-mnemonic');

var mnemonic = new Mnemonic('legal winner thank year wave sausage worth useful legal winner thank yellow');

// generate address from mnemonic
var hdPrivateKey = mnemonic.toHDPrivateKey();
var accountKey = hdPrivateKey.derive(44, true).derive(0, true).derive(0, true);
var addr = accountKey.derive(0).derive(0).privateKey.toAddress();
console.log(addr);

// try do the same with Colu
var seed = mnemonic.toSeed();
var seedHex = seed.toString('hex');

var settings = {
    apiKey: 'Your API key',
    network: 'mainnet',
    privateSeed: seedHex // <-- this is not going to work?!
}

var colu = new Colu(settings);
colu.on('connect', function () {
    console.log(colu.hdwallet.getAddress()); // <-- should be the same as addr
});
colu.init();

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.