|
@ -158,34 +158,16 @@ class Abstract_Wallet(object): |
|
|
|
|
|
|
|
|
self.load_accounts() |
|
|
self.load_accounts() |
|
|
|
|
|
|
|
|
self.transactions = {} |
|
|
self.load_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) |
|
|
|
|
|
|
|
|
|
|
|
# not saved |
|
|
# not saved |
|
|
self.prevout_values = {} # my own transaction outputs |
|
|
self.prevout_values = {} # my own transaction outputs |
|
|
self.spent_outputs = [] |
|
|
self.spent_outputs = [] |
|
|
|
|
|
|
|
|
# spv |
|
|
# spv |
|
|
self.verifier = None |
|
|
self.verifier = None |
|
|
|
|
|
|
|
|
# there is a difference between wallet.up_to_date and interface.is_up_to_date() |
|
|
# 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 |
|
|
# 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) |
|
|
# wallet.up_to_date is true when the wallet is synchronized (stronger requirement) |
|
|
|
|
|
|
|
|
self.up_to_date = False |
|
|
self.up_to_date = False |
|
|
self.lock = threading.Lock() |
|
|
self.lock = threading.Lock() |
|
|
self.transaction_lock = threading.Lock() |
|
|
self.transaction_lock = threading.Lock() |
|
@ -193,6 +175,22 @@ class Abstract_Wallet(object): |
|
|
for tx_hash, tx in self.transactions.items(): |
|
|
for tx_hash, tx in self.transactions.items(): |
|
|
self.update_tx_outputs(tx_hash) |
|
|
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): |
|
|
def add_pubkey_addresses(self, tx): |
|
|
# find the address corresponding to pay-to-pubkey inputs |
|
|
# find the address corresponding to pay-to-pubkey inputs |
|
|
h = tx.hash() |
|
|
h = tx.hash() |
|
|