mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 07:23:25 +00:00
various bugfixes for imported addresses
This commit is contained in:
parent
57a0864055
commit
0c6d470296
2 changed files with 24 additions and 17 deletions
|
@ -91,6 +91,9 @@ class ImportedAccount(Account):
|
||||||
addr = self.get_addresses(0)[i]
|
addr = self.get_addresses(0)[i]
|
||||||
return self.keypairs[addr][0]
|
return self.keypairs[addr][0]
|
||||||
|
|
||||||
|
def get_xpubkeys(self, *sequence):
|
||||||
|
return self.get_pubkeys(*sequence)
|
||||||
|
|
||||||
def get_private_key(self, sequence, wallet, password):
|
def get_private_key(self, sequence, wallet, password):
|
||||||
from wallet import pw_decode
|
from wallet import pw_decode
|
||||||
for_change, i = sequence
|
for_change, i = sequence
|
||||||
|
|
|
@ -383,11 +383,12 @@ class Abstract_Wallet:
|
||||||
|
|
||||||
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.get_seed(password)
|
self.check_password(password)
|
||||||
|
|
||||||
addr_list, xpub_list = tx.inputs_to_sign()
|
addr_list, xpub_list = tx.inputs_to_sign()
|
||||||
for addr in addr_list:
|
for addr in addr_list:
|
||||||
if self.is_mine(addr):
|
if self.is_mine(addr):
|
||||||
private_keys = self.get_private_key(address, password)
|
private_keys = self.get_private_key(addr, password)
|
||||||
for sec in private_keys:
|
for sec in private_keys:
|
||||||
pubkey = public_key_from_private_key(sec)
|
pubkey = public_key_from_private_key(sec)
|
||||||
keypairs[ pubkey ] = sec
|
keypairs[ pubkey ] = sec
|
||||||
|
@ -1005,6 +1006,20 @@ class Abstract_Wallet:
|
||||||
c, u = self.get_addr_balance(address)
|
c, u = self.get_addr_balance(address)
|
||||||
return len(h), len(h) > 0 and c == -u
|
return len(h), len(h) > 0 and c == -u
|
||||||
|
|
||||||
|
def address_is_old(self, address, age_limit=2):
|
||||||
|
age = -1
|
||||||
|
h = self.history.get(address, [])
|
||||||
|
if h == ['*']:
|
||||||
|
return True
|
||||||
|
for tx_hash, tx_height in h:
|
||||||
|
if tx_height == 0:
|
||||||
|
tx_age = 0
|
||||||
|
else:
|
||||||
|
tx_age = self.network.get_local_height() - tx_height + 1
|
||||||
|
if tx_age > age:
|
||||||
|
age = tx_age
|
||||||
|
return age > age_limit
|
||||||
|
|
||||||
|
|
||||||
class Imported_Wallet(Abstract_Wallet):
|
class Imported_Wallet(Abstract_Wallet):
|
||||||
|
|
||||||
|
@ -1033,6 +1048,9 @@ class Imported_Wallet(Abstract_Wallet):
|
||||||
h = self.history.get(address,[])
|
h = self.history.get(address,[])
|
||||||
return len(h), False
|
return len(h), False
|
||||||
|
|
||||||
|
def get_master_public_keys(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
class Deterministic_Wallet(Abstract_Wallet):
|
class Deterministic_Wallet(Abstract_Wallet):
|
||||||
|
|
||||||
|
@ -1115,20 +1133,6 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
if n > nmax: nmax = n
|
if n > nmax: nmax = n
|
||||||
return nmax + 1
|
return nmax + 1
|
||||||
|
|
||||||
def address_is_old(self, address):
|
|
||||||
age = -1
|
|
||||||
h = self.history.get(address, [])
|
|
||||||
if h == ['*']:
|
|
||||||
return True
|
|
||||||
for tx_hash, tx_height in h:
|
|
||||||
if tx_height == 0:
|
|
||||||
tx_age = 0
|
|
||||||
else:
|
|
||||||
tx_age = self.network.get_local_height() - tx_height + 1
|
|
||||||
if tx_age > age:
|
|
||||||
age = tx_age
|
|
||||||
return age > 2
|
|
||||||
|
|
||||||
def synchronize_sequence(self, account, for_change):
|
def synchronize_sequence(self, account, for_change):
|
||||||
limit = self.gap_limit_for_change if for_change else self.gap_limit
|
limit = self.gap_limit_for_change if for_change else self.gap_limit
|
||||||
new_addresses = []
|
new_addresses = []
|
||||||
|
@ -1274,7 +1278,7 @@ class NewWallet(Deterministic_Wallet):
|
||||||
|
|
||||||
def create_accounts(self, password):
|
def create_accounts(self, password):
|
||||||
# First check the password is valid (this raises if it isn't).
|
# First check the password is valid (this raises if it isn't).
|
||||||
pw_decode(self.seed, password)
|
self.check_password(password)
|
||||||
self.create_account('Main account', password)
|
self.create_account('Main account', password)
|
||||||
|
|
||||||
def add_master_public_key(self, name, mpk):
|
def add_master_public_key(self, name, mpk):
|
||||||
|
|
Loading…
Add table
Reference in a new issue