1
1
I want to create bitcoin address from extended public key, without exposing private key but did not get any success till now. Do someone know how to do it? I am using bitcore-lib package
1
1
I want to create bitcoin address from extended public key, without exposing private key but did not get any success till now. Do someone know how to do it? I am using bitcore-lib package
2
According to BIP32 you're trying to generate a non-hardened child address, see BIP32 - Public parent key → public child key.
Using bitcore-lib, to derive a non-hardened child public key and a P2PKH address:
var bitcore = require('bitcore-lib');
var Address = bitcore.Address;
var PublicKey = bitcore.PublicKey;
var Networks = bitcore.Networks;
var hdPublickey = new bitcore.HDPublicKey('tpubD6NzVbkrYhZ4XLMmry7XriYJ6Xgx1vQqoUZHLUXQPDB32n7pQYaWSMpRttm2sHzYjsQqrsAZYyJCmoEJB51oSdqZxq7epGjP4vHriCYz7Tp');
var orderPublickey = hdPublickey.deriveChild("m/44/145/0/0");
var pubkey = new PublicKey(orderPublickey.publicKey);
var address = Address.fromPublicKey(pubkey, Networks.testnet);
console.log("address", address);
Returns:
address <Address: mkVBk6gZ7rBLYXvpdcKwTEq6SjHvSeLwZ8, type: pubkeyhash, network: testnet>
How can i get the privatekey for the above adddress mkVBk6gZ7rBLYXvpdcKwTEq6SjHvSeLwZ8 – Ishwar Chandra – 2019-11-18T14:18:35.307
@IshwarChandra you can't. If you could, then how would you ever hold Bitcoin without someone computing your private key and stealing your funds? – JBaczuk – 2019-11-18T15:59:02.710
@JBaczuk yeah i know .you are right..... – Ishwar Chandra – 2019-11-18T16:29:07.740
@JBaczuk today i exported xpub from coinomi and used in the above code to generate bitcoin address and sent bitcoin.... now my problem is how can i get the fund i sent to that new bitcoin address, which is not in my coinomi wallet and even i did not get any notification incoming transaction on my coinomi wallet – Ishwar Chandra – 2019-11-18T16:35:36.640
@IshwarChandra doing that is most likely is not supported by their application. Hopefully you can export your private key from coinomi, then you'll have to figure out how to sign a transaction with that key and send it back to an address in one of your wallet applications. – JBaczuk – 2019-11-18T17:16:07.400
@JBaczuk thanks, my requirement is if someone sharing me his xpub from exodus or any xpub supported wallet and i am creating bitcoin address using that xpub so is there any way like he can manage those funds. I mean, I will only generate the addresses using xpub and the one who is having xpub, xpriv and its mnemonic he can access/use that funds. – Ishwar Chandra – 2019-11-18T18:55:59.403
@IshwarChandra There are ways, but I don't know if there are any wallets that would support what you want out of the box. You might have to create your own. – JBaczuk – 2019-11-18T18:57:52.060
1ok thanks @JBaczuk – Ishwar Chandra – 2019-11-18T19:06:19.660
could we convert this publicKey into bitcoin base58 address? – rahul saini – 2018-07-24T13:51:54.457
I got this method bitcore.Address.fromPublicKey() but it is not working – rahul saini – 2018-07-24T13:58:22.923
What is it doing? Also, try var address = Address(publicKey, 'mainnet').toString(); Also it depends on what type of address you want (p2sh or p2pkh) – JBaczuk – 2018-07-24T14:02:49.980
please define Address? do you have any working code that can generate bitcoin address from xpub? – rahul saini – 2018-07-24T14:05:29.680
Have you tried the above? Is it not working for you? – JBaczuk – 2018-07-24T14:14:38.417
i have tried lots of time in addr = Address(publicKey, 'mainnet').toString(), i am trying to figure out how to define Address?? – rahul saini – 2018-07-24T14:20:58.230
see my edit above. – JBaczuk – 2018-07-24T14:32:31.960
Let us continue this discussion in chat.
hii @JBaczuk i inboxed you – rahul saini – 2018-07-25T06:15:35.503
can you provide any code and the problems you're having? – JBaczuk – 2018-07-24T13:36:49.713