iancoleman / bip39

A web tool for converting BIP39 mnemonic codes
https://iancoleman.io/bip39/
MIT License
3.55k stars 1.45k forks source link

Issue with extended keys on Litecoin #96

Closed cdodd closed 7 years ago

cdodd commented 7 years ago

I'm looking to create a seed for Litecoin and import the Account Extended Public Key into Electrum-LTC as a "watching-only" wallet, however the latest version of Electrum-LTC (2.9.3.1) expects keys with the prefix xpub/xprv. This tool only generates keys with prefixes of Ltpv/Ltub for Litecoin.

Are the Ltpv/Ltub keys deprecated? If so, could the tool be updated to use xpub/xprv keys, or possible both?

I've read that it's possible to convert between the formats, but have not been able to find documentation on how to do so.

iancoleman commented 7 years ago

Thanks for this.

Looks like litecoin has been a bit inconsistent with the different options, but in the end litecoin core seems to be using xprv xpub so I'll change the default litecoin network constants to reflect that with an option to switch to Ltub. It's a bit of a mess since there's a lot of implementations out there using Ltpv Ltub.

See https://github.com/bitcoinjs/bitcoinjs-lib/pull/819

Relevant highlights:

Turns out we never used Ltub and Ltpv and stuck with the same as Bitcoin.

we have decided that using "xpub" and "xprv" for all assets is easiest. Please update the code.

I believe "Ltub" and "Ltpv" were chosen by the BIP32 creators and was never really supported by litecoin core.

If we stuck with Ltub/Ltpv, that would mean the majority of libraries/tooling are consistent.

TREZOR is not going to support both, just Ltub version

iancoleman commented 7 years ago

See https://github.com/iancoleman/bip39/commit/3abab9b0874904f610cfeb7d136e97ca0ebac1e1

The default for litecoin is now xprv xpub

It can be changed by checking the checkbox under the BIP32 Root Key to use Ltpv Ltub prefixes

Thanks again for reporting this. I think this implementation gives users the best of both worlds.

I also tested it using Electrum-LTC 2.9.3.1 - the account xpub gives the same address as this tool.

Querzel commented 5 years ago

Sorry for asking, but I can't find the answer elsewhere...

Why is BIP49 & BIP84 unavailable for Litecoin when not using Ltpv/Ltub prefixes but xprv? I am trying to restore LTC addresses from the xprv BIP32 Root Key I got from my BitBox PDF backup (@digitalbitbox @jonasschnelli). When putting in xprv BIP32 Root Key & checking Ltpv it says: 'invalid root key' or 'mnemonic empty'. When putting in xprv BIP32 Root Key & unchecking Ltpv it says: 'BIP49 & BIP84 unavailable'.

Restoring the addresses works for BTC & ETH, but the Extended Public Key are not translated to ypub & zpub. I am using v0.3.11 & I saw it working for BIP49 in an older release but long time ago ;)

Thanks.

Querzel commented 5 years ago

I think these are just missing, then it works for me creating the correct addresses ...

` bitcoinjs.bitcoin.networks.litecoinXprv.p2wpkh = { baseNetwork: "litecoin", messagePrefix: '\x19Litecoin Signed Message:\n', bech32: 'ltc', bip32: { public: 0x0488b21e, private: 0x0488ade4 }, pubKeyHash: 0x30, scriptHash: 0x32, wif: 0xb0 };

bitcoinjs.bitcoin.networks.litecoinXprv.p2wpkhInP2sh = { baseNetwork: "litecoin", messagePrefix: '\x19Litecoin Signed Message:\n', bech32: 'ltc', bip32: { public: 0x0488b21e, private: 0x0488ade4 }, pubKeyHash: 0x30, scriptHash: 0x32, wif: 0xb0 }; `

But still the BIP32 Root Key is changing unpredictable to Ltpv/Mtpv/zprv when changing the tabs. This is probably in context to the linked issue #190