Problem generating SegWit addresses.
See original GitHub issueI’m trying to generate a SegWit address using my wallet’s public key and it doesn’t seem to be working. I’ve tried two different transactions using the addresses generated and neither of them came through to the receiving wallet.
let btc_node = Bitcoin.HDNode.fromBase58( "[xpub key]" );
for( let i = 0; i < 3; i++ ) {
let btc_node_derivation = btc_node.derive( i );
let redeem_script = Bitcoin.script.witnessPubKeyHash.output.encode( Bitcoin.crypto.hash160( btc_node_derivation.getPublicKeyBuffer() ) );
// Generate P2SH address instead of Bech32 for backwards compatibility
let script_pub_key = Bitcoin.script.scriptHash.output.encode( Bitcoin.crypto.hash160( redeem_script ) );
console.log( "segwit address", Bitcoin.address.fromOutputScript( script_pub_key ) );
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Issue generating private Key and segwit address with python
I used the following script to generate my private key and the corresponding segwit address. Then to test it, i sent funds to...
Read more >Generate segwit address from public key · Issue #1667 - GitHub
Hi, I am new to bitcoinJ, and previously I was using bitcoinJS to generate the address which is very slow. The js code...
Read more >Hundreds of Bitcoin Cash Are Stuck in Segwit Addresses
Hundreds of thousands of dollars worth of BCH is languishing in segwit addresses. The funds were mistakenly sent there by users who have...
Read more >Segregated Witness (SegWit): Definition, Purpose, How It Works
The Main Issue SegWit Addressed. When one user sends another user some Bitcoin, two pieces of information are required: a public address and...
Read more >Bitcoin SegWit Wallet Address Calculation - c++ - Stack Overflow
The above code in my question will work quite happily for p2pkh address generation for Bitcoin/Litecoin etc, but when generating a Q (for ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ethereum ledger is not BIP44 compliant and there is no concept of change which is why it worked and bitcoin didn’t.
Derive the change layer first.
Change
.derive( i )
To
.derive(0).derive(i)