mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
Convert legacy restored hardware wallets
Hardware wallets do not have a seed and hardware wallet code should not have to worry about that case.
This commit is contained in:
parent
19f527c717
commit
f263f8b0fd
2 changed files with 15 additions and 2 deletions
|
@ -1932,7 +1932,18 @@ class Wallet(object):
|
||||||
else:
|
else:
|
||||||
WalletClass = NewWallet
|
WalletClass = NewWallet
|
||||||
|
|
||||||
return WalletClass(storage)
|
wallet = WalletClass(storage)
|
||||||
|
|
||||||
|
# Convert hardware wallets restored with older versions of
|
||||||
|
# Electrum to BIP44 wallets. A hardware wallet does not have
|
||||||
|
# a seed and plugins do not need to handle having one.
|
||||||
|
rwc = getattr(wallet, 'restore_wallet_class', None)
|
||||||
|
if rwc and storage.get('seed', ''):
|
||||||
|
storage.print_error("converting wallet type to " + rwc.wallet_type)
|
||||||
|
storage.put('wallet_type', rwc.wallet_type)
|
||||||
|
wallet = rwc(storage)
|
||||||
|
|
||||||
|
return wallet
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_seed(self, seed):
|
def is_seed(self, seed):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from electrum.bitcoin import EncodeBase58Check, DecodeBase58Check, public_key_to
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import BasePlugin, hook
|
from electrum.plugins import BasePlugin, hook
|
||||||
from electrum.transaction import deserialize
|
from electrum.transaction import deserialize
|
||||||
from electrum.wallet import BIP32_HD_Wallet, BIP32_Wallet
|
from electrum.wallet import BIP44_Wallet, BIP32_HD_Wallet, BIP32_Wallet
|
||||||
|
|
||||||
from electrum.util import format_satoshis_plain, print_error, print_msg
|
from electrum.util import format_satoshis_plain, print_error, print_msg
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -33,6 +33,7 @@ except ImportError:
|
||||||
class BTChipWallet(BIP32_HD_Wallet):
|
class BTChipWallet(BIP32_HD_Wallet):
|
||||||
wallet_type = 'btchip'
|
wallet_type = 'btchip'
|
||||||
root_derivation = "m/44'/0'"
|
root_derivation = "m/44'/0'"
|
||||||
|
restore_wallet_class = BIP44_Wallet
|
||||||
|
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
BIP32_HD_Wallet.__init__(self, storage)
|
BIP32_HD_Wallet.__init__(self, storage)
|
||||||
|
@ -416,6 +417,7 @@ class BTChipWallet(BIP32_HD_Wallet):
|
||||||
|
|
||||||
|
|
||||||
class LedgerPlugin(BasePlugin):
|
class LedgerPlugin(BasePlugin):
|
||||||
|
wallet_class = BTChipWallet
|
||||||
|
|
||||||
def __init__(self, parent, config, name):
|
def __init__(self, parent, config, name):
|
||||||
BasePlugin.__init__(self, parent, config, name)
|
BasePlugin.__init__(self, parent, config, name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue