spesmilo/electrum — pull request #880 by greenaddress (2014-09-30 14:29:32+00:00)
Title: Add GreenAddress 2of3 recovery plugin

This plugin adds a new wallet type which allows recovering/accessing GreenAddress 2of3 subaccounts (which were just deployed to GreenAddress production).

The new 2of3 model (similarly to BitGo's wallet) allows users to keep complete control of their funds using an additional backup key which in conjunction with wallet mnemonic can be used to access funds without GreenAddress signature.

This new Electrum wallet type allows setting up an Electrum wallet given (1) wallet's mnemonic, (2) subaccount backup mnemonic, (3) GreenAddress extended public key. These 3 values are provided to user on creation of "2of3 subaccount". Such Electrum wallet allows unlimited access to user's funds. It can be used in the case GreenAddress goes down or if you for some other reasons prefer to access your funds without our signatures.

Implementation notes:
1. Trezor's `mnemonic` (https://github.com/trezor/python-mnemonic) module is required for the plugin to work.
2. A 'multisig_recovery' wallet 'supertype' is added in `installwizard.py` to allow specifying wallet types which should be available only for recovery. It can be later used for other similar wallet providers like BitGo.
3. Some code is duplicated where the original code was using `sorted()` pubkeys order, because GreenAddress uses always the same order of keys in multisig (2,0,1 - GA key, wallet key, subaccount key).
4. Change addresses are not used because GreenAddress uses the same branch for change as for spending. The first level of BIP32 sequence is instead used to derive our 'REGULAR' (=1) branch which is usually used for payments. ('external social' transactions are done through 'EXTERNAL' (=2) priv-derived branch - not supported at the moment in this plugin)
5. BIP32 child numbers are 1-based, to make sure address lists are the same as shown in GreenAddress.
6. It was tested using regtest (with quickly hacked Electrum client to support testnet address versions) and production. It allows accessing funds in GA accounts and also limited wallet usage, like monitoring addresses and spending, but as spending doesn't use change addresses, it's recommended to avoid using it for day-to-day use. The main intention of this plugin is to allow accessing GreenAddress funds at any time, and second intention is to allow proof-of-concept verifying that users have full control of their funds.