send-crypto icon indicating copy to clipboard operation
send-crypto copied to clipboard

How to get segwit address from this library?

Open devturi opened this issue 2 years ago • 1 comments

  • I'm submitting a ... [ ] bug report [ tick] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project

  • Summary

I was using this code for sending btc transactions and it was working really good. I like the simplicity. However, when I imported my private key (mainnet BTC) and tried to see the wallet address, it was showing a legacy address. While, the wallet that I created was segwit. So, I am a bit confused here. Can some help me get the segwit address?

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Steps to reproduce:

  • First, I imported the private key and converted to buffer using ECPair

    const keyPair = ECPair.fromWIF(private_key); const account = new CryptoAccount(keyPair.privateKey);

  • Then I checked the account using the folllowing:

    var addr = await account.address("BTC"); console.log("Wallet address:", addr);

  • The address was shown as following

"1QAFzHidiMNVED9AfP*****************" Starting with "1"

Whereas, it should output something like this,

"bc1qlc9jt4kx5x***************" Starting with bc1

Can somebody please help out here?

devturi avatar Nov 06 '22 02:11 devturi

@devturi any update ?

MadhuraJoshi1 avatar Jan 30 '23 19:01 MadhuraJoshi1