X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Fbitcoind%2Fstorage.py;h=6dcf0277265dac70880004a407ac0b2753d194c3;hb=2a8c19f5f3bdae38e9ef89bf7515dc10a7bb1893;hp=36f1366f3fddedc2f92c4fd85a7b78a27c098971;hpb=bea9f00bb679409a446ec7cf78a3b6aa905e2417;p=electrum-server.git diff --git a/backends/bitcoind/storage.py b/backends/bitcoind/storage.py index 36f1366..6dcf027 100644 --- a/backends/bitcoind/storage.py +++ b/backends/bitcoind/storage.py @@ -68,10 +68,13 @@ class Storage(object): return hash_160_to_bc_address(addr) - def get_address_path(self, addr): + def get_proof(self, addr): key = self.address_to_key(addr) - p = self.get_path(key) - p.append(key) + i = self.db_utxo.iterator(start=key) + k, _ = i.next() + + p = self.get_path(k) + p.append(k) out = [] for item in p: @@ -141,8 +144,7 @@ class Storage(object): def get_address(self, txi): - addr = self.db_addr.get(txi) - return self.key_to_address(addr) if addr else None + return self.db_addr.get(txi) def get_undo_info(self, height): @@ -489,7 +491,7 @@ class Storage(object): self.add_address(key + txo, value, tx_height) # backlink - self.db_addr.put(txo, key) + self.db_addr.put(txo, addr) @@ -504,6 +506,13 @@ class Storage(object): self.db_addr.delete(txo) + def get_utxo_value(self, addr, txi): + key = self.address_to_key(addr) + leaf = key + txi + s = self.db_utxo.get(leaf) + value = hex_to_int(s[0:8]) + return value + def set_spent(self, addr, txi, txid, index, height, undo): key = self.address_to_key(addr) @@ -532,7 +541,7 @@ class Storage(object): leaf = key + txi # restore backlink - self.db_addr.put(txi, key) + self.db_addr.put(txi, addr) v, height = undo.pop(leaf) self.add_address(leaf, v, height)