0
I am using bitcoin core library in node js.
const privateKey = new bitcore.PrivateKey('testnet');
const address = privateKey.toAddress('testnet);
When i console.log it, it get result as below. How can i extract the address part only? I try to use address.Address but it returns undefined
<Address: mmNeqV9HWKUDRUAVdknRKDPHyKYGpBEDzm, type: pubkeyhash, network: testnet>
why is it better to get public key first before convert it to address? I found that it returns the same result also even without convert to public key first. any technical explanation on that? – vincentsty – 2018-06-05T07:26:02.870
Because you're creating the address from the public key not from the private key. so technically for better understanding when you call
privateKey.toAddressbitcore by default get thepublicKeyand then the address. – Adam – 2018-06-05T08:40:14.110please see this answer here: https://bitcoin.stackexchange.com/questions/75910/how-to-generate-a-native-segwit-address-and-p2sh-segwit-address-from-a-standard
– Adam – 2018-06-05T10:07:11.230