BlueWallet icon indicating copy to clipboard operation
BlueWallet copied to clipboard

[Feature Request] option to import bitcoin HD private keys (xprv/yprv/zprv)

Open Ero-gamer opened this issue 2 years ago • 3 comments

Import feature within BlueWallet app is limited, for instance it doesn't recognize or allow importation of private keys. (xprv/yprv/zprv private keys format) I created new single address in mycelium app using the same wallet seed, and it work as intended but new created address is not recognized in BlueWallet app, hence I tried to export private keys of said address to BlueWallet app but it does not recognize xprv private keys format.

Ero-gamer avatar Oct 01 '23 00:10 Ero-gamer

I have the same issue. I generated a zprv from iancoleman.io and I can't import the key into my Blue Wallet. It does not recognize it as a valid key.

I can and I'd like to contribute and try to add this feature but I have no familiarity with this code base whatsoever. I also don't have any experience developing bitcoin apps, but I have an extensive full stack dev experience overall.

If someone is willing to at least tell me where these changes are supposed to be made and to point out anywhere in the code base where I'll find a similar thing to that what I should be aiming for, then I could start working.

@marcosrdz or @Overtorment, as the top project contributors, maybe you can shed me some light?

pedrokohler avatar May 26 '24 20:05 pedrokohler

@pedrokohler if you want to tackle it, good place to start would be looking at tests/unit/hd-segwit-bech32-wallet.test.js and adding a few testcases for zprv: wallet should be able to set it as a secred, derive addresses from it, and create transactions. if done right, you would only need to change unit test file and wallet implementation file (class/wallets/abstract-hd-electrum-wallet.ts) and nevereven having to run the whole app in the emulator

Overtorment avatar May 26 '24 20:05 Overtorment

@Overtorment

I see... I just played around a couple of hours with this code and I found some issues that I'm not sure how to deal with.

You say I must be able to use the setSecret method with the zprv, correct? But the current setSecret method expects mnemonics.

It's not possible to derive the mnemonics from the zprv, so I'm not sure exactly what you had in mind there. It's probably a big chain of changes if we start accepting other sorts of values there other than the mnemonics, is it not?

Also this setSecret method is not defined in the class/wallets/abstract-hd-electrum-wallet.ts file, but rather in the class/wallets/abstract-hd-wallet.ts one so I guess I'd have to change this file too?

Finally, bitcoinjs-lib seems to not be able to deal with BIP84... I saw that you can work around that by transforming it to xpub/xprv but it's still a bit confusing for me. Some tips about that?

pedrokohler avatar May 27 '24 01:05 pedrokohler