Browse Source

load_transactions

283
ThomasV 10 years ago
parent
commit
b04256b474
  1. 36
      lib/wallet.py

36
lib/wallet.py

@ -158,34 +158,16 @@ class Abstract_Wallet(object):
self.load_accounts()
self.transactions = {}
tx_list = self.storage.get('transactions',{})
for k, raw in tx_list.items():
try:
tx = Transaction.deserialize(raw)
except Exception:
print_msg("Warning: Cannot deserialize transactions. skipping")
continue
self.add_pubkey_addresses(tx)
self.transactions[k] = tx
for h,tx in self.transactions.items():
if not self.check_new_tx(h, tx):
print_error("removing unreferenced tx", h)
self.transactions.pop(h)
self.load_transactions()
# not saved
self.prevout_values = {} # my own transaction outputs
self.spent_outputs = []
# spv
self.verifier = None
# there is a difference between wallet.up_to_date and interface.is_up_to_date()
# interface.is_up_to_date() returns true when all requests have been answered and processed
# wallet.up_to_date is true when the wallet is synchronized (stronger requirement)
self.up_to_date = False
self.lock = threading.Lock()
self.transaction_lock = threading.Lock()
@ -193,6 +175,22 @@ class Abstract_Wallet(object):
for tx_hash, tx in self.transactions.items():
self.update_tx_outputs(tx_hash)
def load_transactions(self):
self.transactions = {}
tx_list = self.storage.get('transactions',{})
for k, raw in tx_list.items():
try:
tx = Transaction.deserialize(raw)
except Exception:
print_msg("Warning: Cannot deserialize transactions. skipping")
continue
self.add_pubkey_addresses(tx)
self.transactions[k] = tx
for h,tx in self.transactions.items():
if not self.check_new_tx(h, tx):
print_error("removing unreferenced tx", h)
self.transactions.pop(h)
def add_pubkey_addresses(self, tx):
# find the address corresponding to pay-to-pubkey inputs
h = tx.hash()

Loading…
Cancel
Save