Skip to content

Commit

Permalink
Added ability to generate nuetered addresses from account extended pu…
Browse files Browse the repository at this point in the history
…blic keys and tests. Updated documentation.
  • Loading branch information
tboydston committed Jun 22, 2021
1 parent c1805bc commit 964a1d0
Show file tree
Hide file tree
Showing 19 changed files with 4,070 additions and 376 deletions.
20 changes: 16 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Generate hierarchical deterministic(HD) coin specific crypto addresses from sing

# Features

- Mnemonic generation
- BIP 32,44,49,84,141 address logic.
- p2pkh(legacy), p2wpkhInP2sh(segwit compatible), p2wpkh(bech32) hashing.
- Unique address building logic for ETH,EOS,XRP,XLM, and others.
- Custom BIP 39 Passphrases.
- BIP 38 private key encryption.
- Neutered address generation from extended public keys.

# Installation

Expand Down Expand Up @@ -56,6 +58,7 @@ Note: Not all initiation functions require all options.

- mnemonic: BIP39 mnemonic with spaces between words.
- seed: BIP39 seed used instead of a mnemonic.
- xpub: Account extended public key used to generate addresses without private keys.
- passphrase: Additional BIP39 passphrase custom passphrase to further secure mnemonic.
- coin: Coin short name ( BTC, ETH, XRP, ect.).
- hardened: Should the resulting addresses be hardened?
Expand All @@ -82,27 +85,36 @@ HdAddGen.withSeed(seed,coin,hardened=false,bip=44,account=0,change=0,bip38Passwo
### Generate BIP 32 legacy addresses with custom path, mnemonic, and optional pass phrase.

`
withMnemonicBIP32(mnemonic,passphrase,coin,customPath,hardened=false,bip38Password=false)
HdAddGen.withMnemonicBIP32(mnemonic,passphrase,coin,customPath,hardened=false,bip38Password=false)
`

### Generate BIP 32 legacy addresses with custom path and seed.

`
withSeedBIP32(seed,coin,customPath,hardened=false,bip38Password=false)
HdAddGen.withSeedBIP32(seed,coin,customPath,hardened=false,bip38Password=false)
`

### Generate BIP 141 addresses with custom path, mnemonic, and hashing algo.

`
withMnemonicBIP141(mnemonic,passphrase,coin,customPath,hashAlgo,hardened=false,bip38Password=false)
HdAddGen.withMnemonicBIP141(mnemonic,passphrase,coin,customPath,hashAlgo,hardened=false,bip38Password=false)
`

### Generate BIP 141 addresses with custom path, seed, and hashing algo.

`
withSeedBIP141(seed,coin,customPath,hashAlgo,hardened=false,bip38Password=false)
HdAddGen.withSeedBIP141(seed,coin,customPath,hashAlgo,hardened=false,bip38Password=false)
`

### Generate addresses without private keys from Account Extended Public Keys.

Addresses generated with only an extended public key ( extPub ) go not have private keys.

`
HdAddGen.withExtPub(extPub,coin,bip=44,account=0,change=0)
`


## Generating Addresses

### Options
Expand Down
19 changes: 19 additions & 0 deletions examples.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const HdAddGen = require('./hdAddressGenerator')
const mnemonic = "brand improve symbol strike say focus ginger imitate ginger appear wheel brand swear relief zero"
const seed = "09a0a3b58d10bbc456254f1915c2627d8f0e9968922505b39dbb08f6a5dc9dafdee40cff16aa488add7ee4e2ec6eaf40425d3f2aea81c18c2c314d58885e923a"
const xpub = "xpub6CfhGffKu2dhKxhxVS7gmTwtfK6NKA6pVAjgTgManuJoTVqLjiN6RTydgE13GPGCShaEQk1BjbHZ7Lps7eE5ECTk48vJuYjcf2FsPN1n9av"

;(async()=>{

Expand Down Expand Up @@ -165,6 +166,24 @@ bip141Addresses.forEach(address => {
)
})

/**
* Generate Neutered BIP 44 ( Legacy '1' ) addresses for bitcoin with XPUB.
*/

let bip44xpub = {}

bip44xpub = HdAddGen.withExtPub(xpub,"BTC",44)

// Generate 3 address pairs starting from index 0,
let bip44xpubAddresses = await bip44xpub.generate(3)
bip44xpubAddresses.forEach(address => {
console.log(
address.path,
address.address,
address.pubKey,
address.privKey
)
})

/**
* BCH addresses conversion.
Expand Down
Loading

0 comments on commit 964a1d0

Please sign in to comment.