All Projects → cryptotx → hd-address

cryptotx / hd-address

Licence: Apache-2.0 license
An extensible HD Wallet Address management utility

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hd-address

Awesome Coins
₿ A guide (for humans!) to cryto-currencies and their algos.
Stars: ✭ 3,469 (+15668.18%)
Mutual labels:  wallet, btc, coin
cryptowallet-cli
CW is a crypto wallet generator CLI tool for a lot of blockchains: Bitcoin, Ethereum, Binance Smart Chain and many others
Stars: ✭ 45 (+104.55%)
Mutual labels:  wallet, btc
ethereum-hdwallet
CLI and Node.js library for Ethereum HD Wallet derivations from mnemonic
Stars: ✭ 44 (+100%)
Mutual labels:  wallet, mnemonic
Plutus
An automated bitcoin wallet collider that brute forces random wallet addresses
Stars: ✭ 404 (+1736.36%)
Mutual labels:  wallet, btc
CryptoLuKa
LuKa's Official Repository
Stars: ✭ 37 (+68.18%)
Mutual labels:  wallet, coin
willwallet
以太坊钱包
Stars: ✭ 17 (-22.73%)
Mutual labels:  wallet, mnemonic
mnemonic-sdk
Mnemonic bip39 bip32 bip44 生成助记词 私钥
Stars: ✭ 25 (+13.64%)
Mutual labels:  wallet, mnemonic
Coinexchange
数字货币交易所 (开源免费、基于java、无限扩展、高并发、高可靠性、美观?我尽量吧)
Stars: ✭ 61 (+177.27%)
Mutual labels:  btc, coin
Etherwalletkit
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.
Stars: ✭ 96 (+336.36%)
Mutual labels:  wallet, coin
Coinselect
An unspent transaction output (UTXO) selection module for bitcoin.
Stars: ✭ 121 (+450%)
Mutual labels:  wallet, coin
Multicurrencywallet
Bitcoin, Ethereum, ERC20 crypto wallets with Atomic Swap exchange. Release announce: https://twitter.com/SwapOnlineTeam/status/1321844352369500160
Stars: ✭ 136 (+518.18%)
Mutual labels:  wallet, btc
Crypto-Wallet
Open source SHA-512 loginless bitcoin wallet
Stars: ✭ 24 (+9.09%)
Mutual labels:  wallet, btc
wallet-eos
wallet-eos EOS钱包 助记词 私钥 转账
Stars: ✭ 28 (+27.27%)
Mutual labels:  wallet, mnemonic
bitcoinz-wallet
BitcoinZ Wallet - nice graphical user interface BTCZ wallet
Stars: ✭ 19 (-13.64%)
Mutual labels:  wallet, btc
tokencore
The core components of the blockchain wallet backend, support a variety of blockchain address generation and offline signatures
Stars: ✭ 412 (+1772.73%)
Mutual labels:  trx, btc
Unstoppable Wallet Ios
A secure and decentralized Bitcoin and other cryptocurrency wallet for iPhone. Supports Bitcoin, Ethereum, EOS, Binance Chain, Bitcoin Cash, DASH, ...
Stars: ✭ 180 (+718.18%)
Mutual labels:  wallet, btc
coindis
Bitcoin faucet supporting service without time limit.
Stars: ✭ 23 (+4.55%)
Mutual labels:  btc, coin
ChainWallet
一个以研究技术为目地的基础项目,也只有最基本 Bitcoin、Ethereum 、EOS 相关的加密算法。
Stars: ✭ 26 (+18.18%)
Mutual labels:  btc, mnemonic
Walletwasabi
Open-source, non-custodial, privacy focused Bitcoin wallet for Windows, Linux, and Mac. Built-in Tor, CoinJoin, and coin control features.
Stars: ✭ 1,197 (+5340.91%)
Mutual labels:  wallet, coin
Unstoppable Wallet Android
A secure and decentralized Bitcoin and other cryptocurrency wallet for Android phones. Supports Bitcoin, Ethereum, EOS, Binance Chain, Bitcoin Cash, DASH, ...
Stars: ✭ 165 (+650%)
Mutual labels:  wallet, btc

hd-address

NPM version

An extensible HD Wallet Address management utility

中文说明

Please contact us if you have any special needs [email protected]

Install

$ npm i hd-address
$ yarn add hd-address

Reference

m / purpose' / coin_type' / account' / change / address_index

                                                        / address 0
                coinType 0(btc) -- account 0 -- change 0  
              /                                         \ address 1
root -- BIP44 
              \
                coinType 60(eth) -- account 0 -- change 1 -- address 0
                          

API

1.HD Wallet private key API

const hdAddress = require("hd-address")  
// Generate mnemocie seed base58
const mnemocie = hdAddress.mnemocie.getRandomMnemocie()
const seed = hdAddress.seed.getRandomSeed()
const base58 = hdAddress.base58.getRandomBase58()

// Create Hd wallet
const hdWallet =new hdAddress.mnemocie(mnemocie)
const hdWallet =new hdAddress.seed(seed)
const hdWallet =new hdAddress.base58(base58)

// Generate keypair
hdWallet.getHdPath(coinTypeCode, index, account = 0, change = 0) 
hdWallet.getKeyPair(coinTypeCode, index, account, change) 
hdWallet.getCoinKeyPair(coin, index, account, change) 

// ChainCode
hdWallet.getChainCodeByPath(path)
hdWallet.getPublicKeyByChainCode(parentPub, chainCode, path)
hdWallet.getPrivateKeyByChainCode(parentPri, chainCode, path)

2.Get coin address API

const hdAddress = require("hd-address")  
// Create a wallet with Coin Info
let hd = hdAddress.HD(mnemonic,hdAddress.keyType.mnemonic,pwd)
let hd = hdAddress.HD(seed,hdAddress.keyType.seed) 
let hd = hdAddress.HD(base58,hdAddress.keyType.base58) 

// Get coin info
hd.BTC.getCoinKeyPair(index, account, change)
hd.ETH.getCoinAddressKeyPair(index, account, change)
hd.TRX.getAddress(index, account, change)
hd.LTC.getAddressByPath(hdPath) 
hd.BCH.getAddressByPrivateKey(privateKey)
hd.BTC_TEST.getAddressByPublicKey(publicKey)

Example

Initialization

1.Mnemonic Initialization

    const mnemonic = hdAddress.mnemocie.getRandomMnemonic()    
    let hd = hdAddress.HD(mnemonic,hdAddress.keyType.mnemonic)  

2.Seed Initialization

    const {seed} =hdAddress.mnemocie.getRandomSeed() 
    let hd = hdAddress.HD(seed,hdAddress.keyType.seed)  

3.Base58 Initialization

    const {base58} =hdAddress.mnemocie.getRandomBase58() 
    let hd = hdAddress.HD(base58,hdAddress.keyType.base58) //v3.1

Get coin address info

1.Get BTC ETH TRX address example

    let hdIndex=6677
    let btcAddr =  hd.BTC.getAddress(hdIndex)
    console.log("BTC",btcAddr.address)
    let ethAddr =  hd.ETH.getAddress(hdIndex)
    console.log("ETH",ethAddr.address)
    let trxAddr =  hd.TRX.getAddress(hdIndex)
    console.log("TRX",trxAddr.address)

2.Get address by path

    let hdpath = "m/0'/1/1" // account/change/index
    let {address, pub, pri, path} = hd.BTC.getAddressByPath(hdpath)
    console.log(address, pub, pri, path) 

3.Get keypair

  let {address, path, pri, pub} =  hd.BTC.getCoinAddressKeyPair(hdIndex)
  console.log(address, path)

4.Get address using private key or public key

  let priAddr =  hd.BTC.getAddressByPrivateKey(pri)
  console.assert(priAddr.address == address)

  let pubAddr =  hd.BTC.getAddressByPublicKey(pub)
  console.assert(pubAddr.address == address)

Generate safe secret key

1.Get Random Mnemonic

    let wordList = hdAddress.mnemonic.wordLists.CN
    let strength = hdAddress.mnemonic.strength.high 
    let cnMnemo = hdAddress.mnemonic.getRandomMnemonic(strength, wordList)
    let isMnemo = hdAddress.mnemonic.validateMnemonic(cnMnemo) 
    console.log(isMnemo)

2.Get Random base58

    let strength = hdAddress.base58.strength.high 
    let base58 = hdAddress.mnemonic.getRandombase58(strength)

EOS extension: example

You can extend hd-address by implementing AddressClass

const AddressClass =  require("hd-address").AddressClass //v3.0

module.exports = class EosAddress extends AddressClass {
    constructor(hd) {
        let coin = "EOS"
        super(hd, coin);
    }

    getAddress(index) {
        console.log(this.coin, "implement  getAddress method")
    }

    getAddressByPrivateKey(privateKey) {
        console.log(this.coin, "implement  getAddressByPrivateKey method")
    }

    getAddressByPublicKey(privateKey) {
        console.log(this.coin, "implement  getAddressByPublicKey method")
    }
}

Get address using chain code: example

Chain Code can do hierarchical authorization management

    let hdPath = "m/44'/0'/1'"
    let {pub, chainCode} = hd.wallet.getChainCodeByPath(hdPath)
    console.log(hdPath, "chainCode", chainCode.toString("hex"),"\n")

    // pubKey + chainCode +childPath =>  address
    let childPath = "m/1/" + hdIndex
    let child = hd.wallet.getPublicKeyByChainCode(pub, chainCode, childPath)
    let childAaddr = hd.BTC.getAddressByPublicKey(child.pub)
    console.log(childPath, child.pub.toString("hex"),"BTC Address",childAaddr.address)

    //path =>  address
    let testPath = "m/44'/0'/1'/1/" + hdIndex
    let test = hd.wallet.getChainCodeByPath(testPath)
    let testAaddr = hd.BTC.getAddressByPublicKey(test.pub)
    console.log(testPath, test.pub.toString("hex"),"BTC Address",testAaddr.address)

Testing

  mocha 

License

Apache-2.0 License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].