iancoleman / bip39

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

Any plans to support p2wsh version bytes (with custom derivation path)? #351

Closed mflaxman closed 4 years ago

mflaxman commented 4 years ago

I'm writing a guide for multi hardware wallet multisig, and right now the best option for that is (unfortunately) Electrum. I love this tool you've built, and I'd like to recommend incorporating it for generating one key of a multisig to keep offline as an emergency recovery option. As you may know, the extended pubkeys generated with this tool are not compatible with electrum's segwit multisig implementation :(

Here is the workaround I've come up with:

  1. Generate seed on this site
  2. Click BIP32 tab
  3. Enter custom derivation BIP32 derivation path m/48'/1'/0'/2' (for native segwit)
  4. Copy the resulting BIP32 Extended Public Key
  5. Paste that xpub/tpub into https://jlopp.github.io/xpub-converter/ and select p2wsh.
  6. Copy the resulting Zpub/Vpub into electrum.
  7. Save the seed offline (paper, cryptosteel, USB drive, etc)

This does work, but the UX is awful and the risk of mistakes for average users is high. Instead, I have to recommend they use regular old P2SH (with custom BIP32 derivation path m/45'/0). To clarify, I'm asking if you'd be open to adding the version bytes in SLIP-0032.

If we want all our seeds to be BIP39 (best practice) we could recommend a user could just paste their BIP39 seed from this site into electrum and generate a Zpub/Vpub that way, but I'm worried about them then properly destroying the seed. Your site is easy enough for regular users to be able to run offline and delete afterwards.

It'd be great to also have an option for p2sh wrapped segwit (p2wsh-p2sh), but that's less important vs p2wsh. If you're open to it, the "Script Semantics" dropdown on the BIP141 tab is a nice UI option.

Thanks!

iancoleman commented 4 years ago

Thanks for this. Sounds good, I'll look into including this in the next release, it's a good feature to have.

mflaxman commented 4 years ago

Awesome, that would be super cool! Looking forward to it.

Any timeline? I know estimates are the worst :)

mflaxman commented 4 years ago

Any update on this? Thanks!

iancoleman commented 4 years ago

I've implemented this but when I tried to import Zpub to electrum to test compatibility it gave an error

This is Zpub for abandon abandon ability network BTC - Bitcoin derivation path m/0

Zpub6z87Hz4evmmy4ZWZCk3DHM9BkgJE5b7suj9fr2n28n7h76FFyQPScSz8rYmBaKZgggPSofEKxVRPkKCy8m2wnDE8ETKH6TPUv3A8tvu4ZwX

Steps in electrum 3.3.8:

Can you please let me know the steps to import these extended keys to electrum so I can check address generation is consistent?

Also I'm curious about your derivation path purpose being 48... where does that come from since the bips repository doesn't have a bip48?

mflaxman commented 4 years ago

I think for p2wsh you need to select "Multi-signature wallet" and not "Standard wallet" in Electrum:

Screen Shot 2019-12-15 at 6 14 58 PM

FWIW, I think their wording is confusing and has misled others before.

Does that work?

iancoleman commented 4 years ago

Electrum only allows multisig with 2 participants, and this tool only deals with 1 extended key, so I still have a problem of verifying this tool output with a third party tool. I was hoping to generate a 1-of-1 address and use the electrum value as an alternative / test / comparison for this tool.

Any tips on how to use a third-party tool for verification / testing of this feature in the context of this tool?

See TODOs in https://github.com/iancoleman/bip39/commit/5c203fab6ac25fc76e2b805b7709d9b06ccdd995

mflaxman commented 4 years ago

Awesome!

Some potential test vectors you could include: https://github.com/satoshilabs/slips/blob/master/slip-0132.md

Another way would be to confirm the output matches the workaround steps above (https://github.com/iancoleman/bip39/issues/351#issue-487822614). I just compiled your latest and confirm that worked, so that's exciting!

Alternatively, this is also manual but could work?:

  1. Generate 2 seeds (for 1-of-2) using your tool
  2. Create a watch-only Electrum wallet by pasting both of the Vpub/Zpubs into Electrum
  3. Generate address and test receiving funds
  4. Create new 1-of-2 Electrum wallet, but this time use one of the BIP39 seeds from your tool and a Vpub/Zpub for the other key.
  5. Test spending those funds.
iancoleman commented 4 years ago

https://github.com/iancoleman/bip39/commit/f7e9fdf002e7355a122a86a8407b470b56bf3f59

iancoleman commented 4 years ago

Decided to go with 1-of-1 multisig for these addresses.

https://github.com/iancoleman/bip39/commit/f7e9fdf002e7355a122a86a8407b470b56bf3f59 - Generate addresses for P2WSH and P2WSH-P2SH