Bitcoin Forum
May 04, 2024, 01:58:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Problem importing p2wpkh private key into mobile wallet - bluewallet  (Read 175 times)
sam00 (OP)
Legendary
*
Offline Offline

Activity: 1078
Merit: 1123



View Profile
September 02, 2021, 08:42:36 AM
Merited by OmegaStarScream (6), Coyster (5), LoyceV (4), hugeblack (4), o_e_l_e_o (4), bitmover (2), NotATether (2), n0nce (2), hosseinimr93 (1)
 #1

I created a vanity bitcoin address (bc1q...) and just came to realize that I can not import the given private key into my mobile wallet which is weird because blue wallet offers segwit addresses.

The private key starts with "p2wpkh:" and when I import it into electrum, it works and it shows me the correct public key.

However if I try importing the whole key into bluewallet or any other mobile iOS wallet I have tried so far, it never works.
If I leave the "p2wpkh:" out, it just imports a different address. I am not too familiar with the different address types and I couldn't find a solution on the forum or on google so far..

If anyone had the same problem or could tell me how to import my private key correctly, I would really appreciate it!
If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714831090
Hero Member
*
Offline Offline

Posts: 1714831090

View Profile Personal Message (Offline)

Ignore
1714831090
Reply with quote  #2

1714831090
Report to moderator
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18509


View Profile
September 02, 2021, 10:40:15 AM
Merited by LoyceV (4), hugeblack (4), sam00 (3), n0nce (3), NeuroticFish (2), Pmalek (2), bitmover (2), NotATether (2), SFR10 (1), hosseinimr93 (1)
 #2

If I remember correctly, when you import a private key in to BlueWallet it scans all the relevant addresses looking for which one has been used, and then imports that one. If it finds none of them have been used, it defaults to the nested segwit (P2SH-P2WPKH) address, which will start with a 3.

Have you ever used this vanity address? It might be that you need to send some funds to it before you can import it to BlueWallet.

Edit: Just had a look through the code and it looks like I'm right, except it will default to a legacy address beginning with a 1 if it finds no used addresses. You can see the code here if you are interested: https://github.com/BlueWallet/BlueWallet/blob/master/class/wallet-import.js#L250-L268
sam00 (OP)
Legendary
*
Offline Offline

Activity: 1078
Merit: 1123



View Profile
September 02, 2021, 10:57:19 AM
Last edit: September 02, 2021, 11:09:42 AM by sam00
Merited by LoyceV (4)
 #3

If I remember correctly, when you import a private key in to BlueWallet it scans all the relevant addresses looking for which one has been used, and then imports that one. If it finds none of them have been used, it defaults to the nested segwit (P2SH-P2WPKH) address, which will start with a 3.

Have you ever used this vanity address? It might be that you need to send some funds to it before you can import it to BlueWallet.

Edit: Just had a look through the code and it looks like I'm right, except it will default to a legacy address beginning with a 1 if it finds no used addresses. You can see the code here if you are interested: https://github.com/BlueWallet/BlueWallet/blob/master/class/wallet-import.js#L250-L268

Thank you so much man !
Ive tried importing several different addresses with and without the "p2wpkh:" prefix but it always imported the wrong address.
I sent a small amount to the address yesterday and just now tried it again and it imported the correct one!
Can't thank you enough since it took quite a while to generate and I would have been so sad if I couldn't use it as my daily wallet which it was meant for Tongue

edit: if anyone is curious, this is the address which took me about a day to find on three computers running simultaniously:
bc1qsam00000rymzeeyfwh7f3vcmc5y79fsqam5rc2
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
September 03, 2021, 07:06:49 AM
Merited by NotATether (1)
 #4

The private key starts with "p2wpkh:" and when I import it into electrum, it works and it shows me the correct public key.
Note that the use of prefixes ("p2pkh:", "p2wpkh-p2sh:", and "p2wpkh:") is, as far as I'm aware, an Electrum only thing.

I'm not aware of any other wallets that actually require or use the prefixes like this.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pmalek
Legendary
*
Offline Offline

Activity: 2758
Merit: 7131



View Profile
September 03, 2021, 09:06:02 AM
 #5

Note that the use of prefixes ("p2pkh:", "p2wpkh-p2sh:", and "p2wpkh:") is, as far as I'm aware, an Electrum only thing.

I'm not aware of any other wallets that actually require or use the prefixes like this.
I haven't experimented with too many alternative wallets, but do they all offer you an option to click on the type of address you want to recover? As in legacy, nested segwit, and native segwit.

If not, how does the wallet know which address format I want to recover? The same private key can be used for all three address formats. As HCP found, if all addresses are empty, the app will recover the legacy address? But what if all or 2/3 have inputs, what then?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10546



View Profile
September 04, 2021, 03:19:55 AM
 #6

I haven't experimented with too many alternative wallets, but do they all offer you an option to click on the type of address you want to recover? As in legacy, nested segwit, and native segwit.

If not, how does the wallet know which address format I want to recover? The same private key can be used for all three address formats. As HCP found, if all addresses are empty, the app will recover the legacy address? But what if all or 2/3 have inputs, what then?
I haven't tried that many wallets either but the handful I've seen didn't have any option to import a single key, they only accept mnemonics and derive all keys on demand in a tabbed design. For example you ask for a new address it shows a new page with 3 tabs each showing a different address type with a different derivation path for p2pkh, p2wpkh-p2sh and p2wpkh.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18509


View Profile
September 04, 2021, 07:45:55 AM
Last edit: September 04, 2021, 08:51:39 AM by o_e_l_e_o
Merited by Pmalek (1)
 #7

If not, how does the wallet know which address format I want to recover? The same private key can be used for all three address formats. As HCP found, if all addresses are empty, the app will recover the legacy address? But what if all or 2/3 have inputs, what then?
The possible options are that you specify which type of address you want to recover such as you do with Electrum, that it scans for one or more active addresses as is partially the case here with BlueWallet, or it just imports only a single type of address, as I believe is the case with blockchain.com web wallets only importing legacy addresses.

In terms of when 2 out of 3 have been used (this will be a very niche case), then looking at the code I linked above BlueWallet won't find them all. It first scans for an active P2WPKH address, and if found, imports that one. Only if the P2WPKH address is unused will it then scan for a P2SH-P2WPKH address, and only if that is also unused will it then scan for a P2PKH address.
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
September 04, 2021, 08:25:46 AM
Merited by Pmalek (1)
 #8

The old "legacy" format Bitcoin Core wallets will just scan all 3 variants of an imported WIF key... I'm not sure what happens with the new descriptor wallets, but given that you can specify the script type in the descriptor, it's possible it may only scan the one you specify (again, not 100% as I haven't played with descriptor wallets very much, and I think can also import WIFs into descriptor wallets).

Mycelium just does all 3 and you can "tap" on the screen to swap between Legacy, Nested and Native Segwit etc.

Electrum will only do one type per wallet file for HD wallets...  but for imported key wallets, you can mix and match... if you want to scan all three, you just put the private key in three times, once with each prefix.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!