bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

multiple addresses for one wallet #176

Closed sahaviev closed 6 years ago

sahaviev commented 6 years ago

Hi guys! Could anybody help me with my task. I need to make many addresses for one wallet.

I have done following steps:

  1. create an extended private key with Mnemonic library.
  2. derive from this key another private key
  3. and getting from that keys address

try to send some satoshi from my wallet to this address and can't got anything...

Here's the code:

const bitcore = require("bitcore-lib")
const Mnemonic = require("bitcore-mnemonic")

function newline() {
    console.log()
}

async function run() {
    const passphraze = "passphraze here!"
    console.log("passphaze is valid " + Mnemonic.isValid(passphraze))

    const code = new Mnemonic(passphraze)
    const xPrivateKey = code.toHDPrivateKey()

    const hdPrivateKey0 = new bitcore.HDPrivateKey(xPrivateKey)
    const hdPrivateKey1 = hdPrivateKey0.derive("m/0'")

    newline()
    console.log(hdPrivateKey0.privateKey.toAddress().toString())
    console.log(hdPrivateKey1.privateKey.toAddress().toString())
}

run()

Please, help me: where do I make a mistake and what I don't understand in this area? Thanks so much in advance!

sahaviev commented 6 years ago

I want to recieve money in my wallet without using default network address. What I should looking for? p.s.: P2SH ?

sahaviev commented 6 years ago

The issue is resolved