question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to generate Litecoin address via xpub

See original GitHub issue

I’m attempting to generate/derive an address via a Litecoin xpub key using the following:

var bitcoin = require('bitcoinjs-lib');
import HDNode from "../../bitcoinjs-lib/src/hdnode";

const litecoin = bitcoin.networks.litecoin
const xpub = "Litecoin xpub";
const node = HDNode.fromBase58(xpub);
const address = node.derive(0).getAddress(litecoin);

However, it continues to generate a Bitcoin address. Is there anything I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
dcousenscommented, Feb 27, 2018

@tonychew1986 you are trying to use the litecoin network object, which has different BIP32 constants, if you want to support “both”, I recommend you do the following:

let litecoin = bitcoin.networks.litecoin
let litecoinX = Object.assign({}, bitcoin.networks.litecoin, {
  bip32: bitcoin.networks.bitcoin.bip32
})

let a = bitcoin.HDNode.fromBase58(xpub, [litecoin, litecoinX])
1reaction
dcousenscommented, Feb 27, 2018

@junderw maybe the above should be our official recommendation? (short of adding litecoinX)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to programmically generate unused receiving address ...
I'm trying to generate unused receiving Bitcoin address from xPub using PyWallet python library . I got the xPub from my BIP32 Electrum ......
Read more >
Unable to generate new address - Blockonomics
Unable to generate new address Print · 1.Error: "API Key is incorrect": Make sure you have setup your API key correctly and that...
Read more >
How to generate bitcoin address from XPUB - Stack Overflow
How to generate bitcoin address from XPUB, I am looking for pointers on how to use an XPUB to generate addresses. I would...
Read more >
Understanding the xPub and address generation
*While bitcoin and bitcoin cash addresses, once generated, never become invalid and can be used to receive multiple payments, we recommend using ......
Read more >
Generating Bitcoin Addresses Programmatically - Medium
How to generate Bitcoin addresses from an HD Wallets' XPUB key. ... if the server is compromised, the attacker would never be able...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found