Bitcoin Forum
May 21, 2019, 06:00:14 AM *
News: Latest Bitcoin Core release: 0.18.0 [Torrent] (New!)
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Importing Ledger nano s xpub into Electrum  (Read 245 times)
rabbitfairferry
Newbie
*
Offline Offline

Activity: 27
Merit: 16


View Profile
December 15, 2018, 05:55:30 PM
Merited by OmegaStarScream (2), LoyceV (1)
 #1

Hey everyone,

I am following the instructions on this site to import my xpub: https://bitcoinelectrum.com/creating-a-watch-only-wallet/

However, after importing the xpub, when I go to the Receive view on Electrum, it shows an address of 12zaX4EnQGZvzT2q3pzWceaEUqASHju69g. According to Ledger Live, my first address should be 339xN86kVE2DosHZN9D6AnzkGA2KpMLHdQ.

Is there a reason for this?

I think the issue is that the script type is incorrect. When I go to Wallet Information I see that the script type is p2pkh. Is there anyway to change it to p2wpkh-p2sh.

Thank you.
New Generation Antminer S17 Mining Plan Available Now! Highly Reduced Electricity Fee $0.067/T/DAY! Register To Experience
Free Mining Plan!
GET STARTED!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1558418414
Hero Member
*
Offline Offline

Posts: 1558418414

View Profile Personal Message (Offline)

Ignore
1558418414
Reply with quote  #2

1558418414
Report to moderator
1558418414
Hero Member
*
Offline Offline

Posts: 1558418414

View Profile Personal Message (Offline)

Ignore
1558418414
Reply with quote  #2

1558418414
Report to moderator
1558418414
Hero Member
*
Offline Offline

Posts: 1558418414

View Profile Personal Message (Offline)

Ignore
1558418414
Reply with quote  #2

1558418414
Report to moderator
TryNinja
Legendary
*
Offline Offline

Activity: 1008
Merit: 1249


ChipMixer's Badge of Honor


View Profile
December 15, 2018, 07:19:23 PM
Last edit: December 15, 2018, 08:03:54 PM by TryNinja
Merited by Abdussamad (1)
 #2

Try importing it with this prefix:
p2wpkh-p2sh:your_xpub_here

(P.S: This probably only works with private-keys - I probably also don't know what I'm talking about)


It really doesn't work. I found this from Ledger's CTO:
XPUBs do not work properly for Segwit yet - we're looking for a standard that'd make that possible

Edit:
try to use this tool to convert your xpub to the p2wpkh-p2sh format: https://github.com/AbdussamadA/electrum-convert-key

HCP
Legendary
*
Offline Offline

Activity: 966
Merit: 1495

<insert witty quote here>


View Profile
December 15, 2018, 08:09:27 PM
Merited by Abdussamad (1)
 #3

It seems they still haven't fixed this "bug" on the Ledger... I wrote about it here: https://bitcointalk.org/index.php?topic=2869129.msg29497443#msg29497443

Basically, you should be getting a YPUB, but for some reason, Ledger is still giving out XPUBs for the SegWit wallets Sad

The only method I currently know of to get the YPUB, is as outlined in the post I've linked... that is to say, you need to connect your Ledger Nano S to Electrum, and import the wallet using "New -> Standard Wallet -> Use a Hardware Device" and then specify the correct derivation path... once you've successfully created that wallet, if you use "Wallet -> Information", Electrum will display your YPUB.

Note that by connecting the Nano S to Electrum and using the "New -> Standard Wallet -> Use a Hardware Device" method... you're effectively just importing the YPUB and creating a watching only wallet anyway (it doesn't import the seed or private keys etc)... so it is probably the best way to achieve what you appear to be trying to achieve Wink

rabbitfairferry
Newbie
*
Offline Offline

Activity: 27
Merit: 16


View Profile
December 16, 2018, 09:07:22 AM
 #4

It seems they still haven't fixed this "bug" on the Ledger... I wrote about it here: https://bitcointalk.org/index.php?topic=2869129.msg29497443#msg29497443

Basically, you should be getting a YPUB, but for some reason, Ledger is still giving out XPUBs for the SegWit wallets Sad

The only method I currently know of to get the YPUB, is as outlined in the post I've linked... that is to say, you need to connect your Ledger Nano S to Electrum, and import the wallet using "New -> Standard Wallet -> Use a Hardware Device" and then specify the correct derivation path... once you've successfully created that wallet, if you use "Wallet -> Information", Electrum will display your YPUB.

Note that by connecting the Nano S to Electrum and using the "New -> Standard Wallet -> Use a Hardware Device" method... you're effectively just importing the YPUB and creating a watching only wallet anyway (it doesn't import the seed or private keys etc)... so it is probably the best way to achieve what you appear to be trying to achieve Wink

Hi HCP thank you very much for the detailed explanation. With regards to the link you posted, could you please explain the following. I am new to this so apologies in advance. Have tried to google but can't find good explanations.

1) Why did you say "So, I believe that the Ledger SegWit wallet should be giving a "ypub"". Why couldn't this have been the zpub?

2) You also mentioned the use of m/0 as the derivation path. What exactly is this? Reading this link (https://medium.com/bitcraft/hd-wallets-explained-from-high-level-to-nuts-and-bolts-9a41545f5b0), it means that you are setting the purpose' to 0? Why is this so?

Thank you.
TryNinja
Legendary
*
Offline Offline

Activity: 1008
Merit: 1249


ChipMixer's Badge of Honor


View Profile
December 16, 2018, 01:25:08 PM
Merited by ETFbitcoin (1), HCP (1)
 #5

1) Why did you say "So, I believe that the Ledger SegWit wallet should be giving a "ypub"". Why couldn't this have been the zpub?
From the same post by HCP:

Basically:
- xpub = Legacy wallet (legacy Bitcoin addresses)
- ypub = SegWit wallet (P2SH-P2WPKH addresses)
- zpub = SegWit wallet (P2WPKH addresses)

Which means that:
- ypub is for nested Segwit address (segwit addresses starting with a 3) - which are the one Ledger uses.
- zpub is for native Segwit wallets (segwit addresses starting with bc1) - Ledger doesn't use those.

HCP
Legendary
*
Offline Offline

Activity: 966
Merit: 1495

<insert witty quote here>


View Profile
December 16, 2018, 09:59:59 PM
Merited by joniboini (1)
 #6

1) Why did you say "So, I believe that the Ledger SegWit wallet should be giving a "ypub"". Why couldn't this have been the zpub?
As already explained by TryNinja... YPUBs are for the "3"-type SegWit (aka P2SH-P2WPKH) addresses... whereas the ZPUBs are for the "bc1" (aka bech32) addresses... and Ledger does not generate bech32 addresses at this time.


Quote
2) You also mentioned the use of m/0 as the derivation path. What exactly is this? Reading this link (https://medium.com/bitcraft/hd-wallets-explained-from-high-level-to-nuts-and-bolts-9a41545f5b0), it means that you are setting the purpose' to 0? Why is this so?
It is because, in this instance, the XPUB that you see is NOT actually the Master Public Key for your wallet... instead, it is the Extended Public Key for the particular account within the Ledger wallet. In other words, it is already at the "m/49'/0'/0'" derivation level... so you just need to use "m/0" to start deriving addresses from this point.

If you were to specify the "full" derivation path (ie. m/49'/0'/0'/0) with this particular XPUB, you'd actually be deriving addresses at the starting point: "m/49'/0'/0'/49'/0'/0'/0"  Shocked

You can test this by experimenting with the Ian Coleman website:
- generate a random seed... DO NOT USE YOUR ACTUAL SEED!
- Click on BIP49...
- Copy the "Account Extended Public Key" and check the first address (path = m/49'/0'/0'/0/0)
- Paste the "Account Extended Public Key" into the "BIP32 Root Key" section at the top
- Click BIP141 tab
- Make sure the BIP32 derivation path = m/0 and that the Script Type is "P2WPKH nested in P2SH".
- Check the first address... (path = m/0/0)... it *SHOULD* be the same address as the one in step 3.

It works the same for legacy accounts from Ledger... (you just use BIP44 tab instead of BIP49... and BIP32 tab instead of BIP141 on the Ian Coleman website)

rabbitfairferry
Newbie
*
Offline Offline

Activity: 27
Merit: 16


View Profile
December 22, 2018, 05:30:26 AM
 #7

Try importing it with this prefix:
p2wpkh-p2sh:your_xpub_here

(P.S: This probably only works with private-keys - I probably also don't know what I'm talking about)


It really doesn't work. I found this from Ledger's CTO:
XPUBs do not work properly for Segwit yet - we're looking for a standard that'd make that possible

Edit:
try to use this tool to convert your xpub to the p2wpkh-p2sh format: https://github.com/AbdussamadA/electrum-convert-key

Thanks for the reply. Apart from using the tool you linked, is there an easier way for non-technical people? Thank you.
Lucius
Legendary
*
Offline Offline

Activity: 1414
Merit: 1193


Fortis Fortuna Adiuvat


View Profile WWW
December 22, 2018, 11:20:18 AM
 #8

Thanks for the reply. Apart from using the tool you linked, is there an easier way for non-technical people? Thank you.

I think you do not need to complicate the situation with YPUB/XPUB, everything is quite well explained and you need only listen to advice from HCP :

Note that by connecting the Nano S to Electrum and using the "New -> Standard Wallet -> Use a Hardware Device" method... you're effectively just importing the YPUB and creating a watching only wallet anyway (it doesn't import the seed or private keys etc)... so it is probably the best way to achieve what you appear to be trying to achieve Wink

There is no reason to import any PUBs from Ledger to Electrum with a reason to create watch-only wallets because you can get same thing by doing what HCP write above, and only thing you need to pay attention is derivation paths. For Segwit you need to choose m/49'/0'/0' and for Legacy account
m/44'/0'/0' .

TryNinja
Legendary
*
Offline Offline

Activity: 1008
Merit: 1249


ChipMixer's Badge of Honor


View Profile
December 22, 2018, 01:19:29 PM
 #9

Note that by connecting the Nano S to Electrum and using the "New -> Standard Wallet -> Use a Hardware Device" method... you're effectively just importing the YPUB and creating a watching only wallet anyway (it doesn't import the seed or private keys etc)... so it is probably the best way to achieve what you appear to be trying to achieve Wink

There is no reason to import any PUBs from Ledger to Electrum with a reason to create watch-only wallets because you can get same thing by doing what HCP write above, and only thing you need to pay attention is derivation paths. For Segwit you need to choose m/49'/0'/0' and for Legacy account
m/44'/0'/0' .
In that case, you actually need to have the device connected every time you open the watch-only wallet.

If OP wants to be able to check his wallet (watch-only) anywhere without having to connect his Nano S to the PC and unlock it, he can do the method above, then go to Wallet -> Information -> Copy the ypub, then import it to create a new independent watch-only wallet  (not linked to the Nano S device).

rabbitfairferry
Newbie
*
Offline Offline

Activity: 27
Merit: 16


View Profile
December 22, 2018, 01:50:49 PM
 #10

Note that by connecting the Nano S to Electrum and using the "New -> Standard Wallet -> Use a Hardware Device" method... you're effectively just importing the YPUB and creating a watching only wallet anyway (it doesn't import the seed or private keys etc)... so it is probably the best way to achieve what you appear to be trying to achieve Wink

There is no reason to import any PUBs from Ledger to Electrum with a reason to create watch-only wallets because you can get same thing by doing what HCP write above, and only thing you need to pay attention is derivation paths. For Segwit you need to choose m/49'/0'/0' and for Legacy account
m/44'/0'/0' .
In that case, you actually need to have the device connected every time you open the watch-only wallet.

If OP wants to be able to check his wallet (watch-only) anywhere without having to connect his Nano S to the PC and unlock it, he can do the method above, then go to Wallet -> Information -> Copy the ypub, then import it to create a new independent watch-only wallet  (not linked to the Nano S device).

Thanks, Lucius and TryNinja.

TryNinja, you are spot on. The reason why I did not want to follow HCP's method is that it required the hardware wallet to access. Is there an easier way to implement the tool you mentioned?
TryNinja
Legendary
*
Offline Offline

Activity: 1008
Merit: 1249


ChipMixer's Badge of Honor


View Profile
December 22, 2018, 02:02:09 PM
 #11

TryNinja, you are spot on. The reason why I did not want to follow HCP's method is that it required the hardware wallet to access. Is there an easier way to implement the tool you mentioned?
If you do the other steps I mentioned above, you will only need the hardware wallet once (to set up the watch-only and get the ypub). Afterwards, you won't need it anymore.

Can you try that?

rabbitfairferry
Newbie
*
Offline Offline

Activity: 27
Merit: 16


View Profile
December 22, 2018, 02:34:46 PM
 #12

TryNinja, you are spot on. The reason why I did not want to follow HCP's method is that it required the hardware wallet to access. Is there an easier way to implement the tool you mentioned?
If you do the other steps I mentioned above, you will only need the hardware wallet once (to set up the watch-only and get the ypub). Afterwards, you won't need it anymore.

Can you try that?

Oops, I missed that part, let me go try it out. thank you!
 
Can I confirm one more thing. If I set it up using the hardware wallet initially, my private key never leaves my device correct?
ETFbitcoin
Legendary
*
Offline Offline

Activity: 1638
Merit: 1764

Use SegWit and enjoy lower fees.


View Profile WWW
December 22, 2018, 03:42:29 PM
 #13

Can I confirm one more thing. If I set it up using the hardware wallet initially, my private key never leaves my device correct?

That depends on the HW wallet itself, but all HW wallet i know won't let private key "leave" from the device as it designed only to sent signed transaction/message based on received unsigned transaction/message.

You should think how to keep the seed secure instead.

TryNinja
Legendary
*
Offline Offline

Activity: 1008
Merit: 1249


ChipMixer's Badge of Honor


View Profile
December 22, 2018, 03:44:11 PM
 #14

Can I confirm one more thing. If I set it up using the hardware wallet initially, my private key never leaves my device correct?
That's correct. You only compromise your hardware wallet if you write your backup seed somewhere (a website, a text file, import your wallet with it, etc...).

HCP
Legendary
*
Offline Offline

Activity: 966
Merit: 1495

<insert witty quote here>


View Profile
December 24, 2018, 06:31:13 AM
 #15

In that case, you actually need to have the device connected every time you open the watch-only wallet.

If OP wants to be able to check his wallet (watch-only) anywhere without having to connect his Nano S to the PC and unlock it, he can do the method above, then go to Wallet -> Information -> Copy the ypub, then import it to create a new independent watch-only wallet  (not linked to the Nano S device).
TryNinja, you are spot on. The reason why I did not want to follow HCP's method is that it required the hardware wallet to access. Is there an easier way to implement the tool you mentioned?
That's not completely true...

You ONLY need the hardware device connected to check the wallet IF the wallet file is encrypted:


If you don't use encryption, you can open the watching wallet without the device connected. This isn't really a security concern as such, as no private keys or seeds etc are held in the wallet file. So, it only really has privacy implications, insofar that if your wallet file is somehow compromised/stolen, the thief will have access to your YPUB, addresses and transaction history. They can't spend your coins.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!