Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSBT(bip174) implementation #4615 #4883

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions electrum/__init__.py
Expand Up @@ -10,6 +10,7 @@
from . import transaction
from . import daemon
from .transaction import Transaction
from .bip174 import PSBT
from .plugin import BasePlugin
from .commands import Commands, known_commands

Expand Down
21 changes: 12 additions & 9 deletions electrum/address_synchronizer.py
Expand Up @@ -26,6 +26,7 @@
import itertools
from collections import defaultdict
from typing import TYPE_CHECKING, Dict, Optional
from typing import List, Dict, Tuple

from . import bitcoin
from .bitcoin import COINBASE_MATURITY, TYPE_ADDRESS, TYPE_PUBKEY
Expand Down Expand Up @@ -86,6 +87,8 @@ def __init__(self, storage: 'WalletStorage'):
# thread local storage for caching stuff
self.threadlocal_cache = threading.local()

self._addr_to_addr_index = {}

self.load_and_cleanup()

def with_transaction_lock(func):
Expand All @@ -104,7 +107,7 @@ def load_and_cleanup(self):
def is_mine(self, address):
return address in self.history

def get_addresses(self):
def get_addresses(self) -> List[str]:
return sorted(self.history.keys())

def get_address_history(self, addr):
Expand Down Expand Up @@ -515,7 +518,7 @@ def get_history(self, domain=None):
delta = tx_deltas[tx_hash]
tx_mined_status = self.get_tx_height(tx_hash)
history.append((tx_hash, tx_mined_status, delta))
history.sort(key = lambda x: self.get_txpos(x[0]), reverse=True)
history.sort(key=lambda x: self.get_txpos(x[0]), reverse=True)
# 3. add balance
c, u, x = self.get_balance(domain)
balance = c + u + x
Expand Down Expand Up @@ -742,7 +745,7 @@ def get_addr_io(self, address):
for tx_hash, height in h:
l = self.txo.get(tx_hash, {}).get(address, [])
for n, v, is_cb in l:
received[tx_hash + ':%d'%n] = (height, v, is_cb)
received[tx_hash + ':%d' % n] = (height, v, is_cb)
for tx_hash, height in h:
l = self.txi.get(tx_hash, {}).get(address, [])
for txi, v in l:
Expand All @@ -758,12 +761,12 @@ def get_addr_utxo(self, address):
tx_height, value, is_cb = v
prevout_hash, prevout_n = txo.split(':')
x = {
'address':address,
'value':value,
'prevout_n':int(prevout_n),
'prevout_hash':prevout_hash,
'height':tx_height,
'coinbase':is_cb
'address': address,
'value': value,
'prevout_n': int(prevout_n),
'prevout_hash': prevout_hash,
'height': tx_height,
'coinbase': is_cb
}
out[txo] = x
return out
Expand Down