Saturday 3 June 2017

Creating Bitcoin Wallet with Public Key

when I understood this correctly: When you generate a BTC adress from your Public Key, its yours. There is a multi adress function in bitcoin core, so I want to generate adresses, that belong me, on my wallet.

So I got a Program, that should do that, but the wallets dont belong me. Heres the implementation in the main program:

for (var i = 1; i <= count; ++i) {
var address = lib.deriveAddress(i);
depositAddresses[address] = i;
}

console.log('Finished generating addresses', depositAddresses);

lib.deriveAdress is

exports.chunk = chunk;
exports.chunkRun = chunkRun;
exports.chunkSlow = chunkSlow;

var derivedPubKey = 'xpub6AK3Pskqnn12yJmiAA313sFBE5EABrqH1Ldb2WNUmXYxbQGW481hSCEQFvwdQoHkw7NuYbyN3*****************************';
if (!derivedPubKey)
    throw new Error('Must set env var BIP32_DERIVED_KEY');

var hdNode = bitcoinjs.HDNode.fromBase58(derivedPubKey);

exports.deriveAddress = function(index) {
    return hdNode.derive(index).pubKey.getAddress().toString();
};

Please help me, im really getting tired of this..



via GeT_rApEd

No comments:

Post a Comment