mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 20:35:13 +00:00
move master_private_keys and master_public_keys to NewWallet
This commit is contained in:
parent
3d78be8f46
commit
a471859a3a
1 changed files with 30 additions and 22 deletions
|
@ -147,8 +147,6 @@ class Abstract_Wallet(object):
|
||||||
self.history = storage.get('addr_history',{}) # address -> list(txid, height)
|
self.history = storage.get('addr_history',{}) # address -> list(txid, height)
|
||||||
|
|
||||||
self.fee = int(storage.get('fee_per_kb', 10000))
|
self.fee = int(storage.get('fee_per_kb', 10000))
|
||||||
self.master_public_keys = storage.get('master_public_keys',{})
|
|
||||||
self.master_private_keys = storage.get('master_private_keys', {})
|
|
||||||
|
|
||||||
self.next_addresses = storage.get('next_addresses',{})
|
self.next_addresses = storage.get('next_addresses',{})
|
||||||
|
|
||||||
|
@ -356,26 +354,6 @@ class Abstract_Wallet(object):
|
||||||
account_id, sequence = self.get_address_index(address)
|
account_id, sequence = self.get_address_index(address)
|
||||||
return self.accounts[account_id].get_pubkeys(sequence)
|
return self.accounts[account_id].get_pubkeys(sequence)
|
||||||
|
|
||||||
def can_sign(self, tx):
|
|
||||||
|
|
||||||
if self.is_watching_only():
|
|
||||||
return False
|
|
||||||
|
|
||||||
if tx.is_complete():
|
|
||||||
return False
|
|
||||||
|
|
||||||
addr_list, xpub_list = tx.inputs_to_sign()
|
|
||||||
for addr in addr_list:
|
|
||||||
if self.is_mine(addr):
|
|
||||||
return True
|
|
||||||
|
|
||||||
mpk = [ self.master_public_keys[k] for k in self.master_private_keys.keys() ]
|
|
||||||
for xpub, sequence in xpub_list:
|
|
||||||
if xpub in mpk:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def add_keypairs(self, tx, keypairs, password):
|
def add_keypairs(self, tx, keypairs, password):
|
||||||
# first check the provided password. This will raise if invalid.
|
# first check the provided password. This will raise if invalid.
|
||||||
self.check_password(password)
|
self.check_password(password)
|
||||||
|
@ -1260,6 +1238,8 @@ class NewWallet(Deterministic_Wallet):
|
||||||
|
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
Deterministic_Wallet.__init__(self, storage)
|
Deterministic_Wallet.__init__(self, storage)
|
||||||
|
self.master_public_keys = storage.get('master_public_keys', {})
|
||||||
|
self.master_private_keys = storage.get('master_private_keys', {})
|
||||||
|
|
||||||
def default_account(self):
|
def default_account(self):
|
||||||
return self.accounts["m/0'"]
|
return self.accounts["m/0'"]
|
||||||
|
@ -1341,6 +1321,21 @@ class NewWallet(Deterministic_Wallet):
|
||||||
self.add_master_public_key("m/", xpub)
|
self.add_master_public_key("m/", xpub)
|
||||||
self.add_master_private_key("m/", xpriv, password)
|
self.add_master_private_key("m/", xpriv, password)
|
||||||
|
|
||||||
|
def can_sign(self, tx):
|
||||||
|
if self.is_watching_only():
|
||||||
|
return False
|
||||||
|
if tx.is_complete():
|
||||||
|
return False
|
||||||
|
addr_list, xpub_list = tx.inputs_to_sign()
|
||||||
|
for addr in addr_list:
|
||||||
|
if self.is_mine(addr):
|
||||||
|
return True
|
||||||
|
mpk = [ self.master_public_keys[k] for k in self.master_private_keys.keys() ]
|
||||||
|
for xpub, sequence in xpub_list:
|
||||||
|
if xpub in mpk:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def find_root_by_master_key(self, xpub):
|
def find_root_by_master_key(self, xpub):
|
||||||
for key, xpub2 in self.master_public_keys.items():
|
for key, xpub2 in self.master_public_keys.items():
|
||||||
if key == "m/":continue
|
if key == "m/":continue
|
||||||
|
@ -1542,6 +1537,19 @@ class OldWallet(Deterministic_Wallet):
|
||||||
def check_pending_accounts(self):
|
def check_pending_accounts(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def can_sign(self, tx):
|
||||||
|
if self.is_watching_only():
|
||||||
|
return False
|
||||||
|
if tx.is_complete():
|
||||||
|
return False
|
||||||
|
addr_list, xpub_list = tx.inputs_to_sign()
|
||||||
|
for addr in addr_list:
|
||||||
|
if self.is_mine(addr):
|
||||||
|
return True
|
||||||
|
for xpub, sequence in xpub_list:
|
||||||
|
if xpub == self.master_public_key:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
# former WalletFactory
|
# former WalletFactory
|
||||||
class Wallet(object):
|
class Wallet(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue