I start Electrum in my cmdline like this:

./Electrum --testnet

I connect Ledger Nano S to my laptop. In Electrum I make a new HD Wallet with Derivation path using the Nano S's private key as seed:


In NodeJS (LedgerJS library) I write this code, using the exact same derivation path, also using the Nano S private key as seed:

const transport = await TransportNodeHid.create();
const btc = new AppBtc(transport);
const result = await btc.getWalletPublicKey("m/49'/1'/0'");

Now, since the TransportNodeHid connects to my Ledger Nano S, I expect that the AppBtc object generates a HD Wallet with the exact same seed, and therefore the derivation path


should give me the exact same Wallet Master Public key and receiving Bitcoin address right?

However, in Electrum:

Master Public Key: upub5EorGi4nr15AW.....
Receiving Address: 2NEYbAH7x6sXU2bS....

and in my NodeJS application, using getWalletPublicKey():

    bitcoinAddress: 'mtCKwjnNzNZr.....',

Now, I figured out that the publicKey and chainCode that the NodeJS code returns can be combined somehow to create the Master Public Key. However, the bitcoinAddress property should be the address associated with my HD wallet right? It's different from the receiving address in the Electrum app, but it should still be a receiving address.

However I already tried sending 0.0001 BTC to it with Testnet but it never arrived in my Electrum Wallet. So does this mean that this address is not associated with my Electrum Wallet? Even though I gave the exact same Derivation Path and used the exact same seed (hardware device Ledger Nano S)?

How can I "get" more receiving Address from my HD Wallet using the LedgerJS library?

I have checked LedgerJS documentation and examples, but I wouldn't go so far as to call it "documentation", because most functionality is barely explained and examples are virtually non-existent. There's a lot of guesswork involved in how exactly everything works.



1 Answer 1


A public key can have multiple addresses. It looks like what is happening here is that Electrum is creating a P2SH-P2WPKH type address while your NodeJS code is creating a P2PKH address. These are two different address types which have different spending requirements and transaction data. However Bitcoin sent to either address type can still be spent with the same private key and the same public key was used to create both addresses.

When you sent the Bitcoin to the P2PKH address, Electrum won't show it because it is not looking for Bitcoin sent to that address. Just because you have the private key necessary to spend some Bitcoin does not necessarily mean that your wallet will be looking for outputs of that kind. A wallet cannot track all possible output scripts that it can spend (it is infinite), it can only track the ones it is expecting to see. So for Electrum, it's only tracking the P2SH-P2WPKH address and not the P2PKH address that you sent Bitcoin to.

  • I see, so the bitcoin address given by Ledger is indeed connected to my wallet, but it isn't tracked. Then I suppose I have to get both apps to either use P2PKH or P2SH-P2WPKH. After that I need to find some way to either track the address given by LedgerJS in the Electrum app... Or I need to get an address from Electrum and use it in LedgerJS. Either way you have my gratitude, your elaborate answer has helped me greatly. Mar 19, 2019 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.