Example #1
0
def build_contact_tx_list(address : Address) -> list:
    parent = gui.ElectrumGui.gui
    ret = list()
    if isinstance(address, Address) and parent and parent.sigHistory:
        alltxs = parent.sigHistory.get(None)
        seen = set() # 'seen' set.. guard against the same address appearing in both inputs and outputs
        for hentry in alltxs:
            if hentry.tx:
                ins = hentry.tx.inputs()
                for x in ins:
                    xa = x['address']
                    if isinstance(xa, PublicKey):
                        xa = xa.toAddress()
                    if isinstance(xa, Address) and xa.to_storage_string() == address.to_storage_string() and hentry.tx_hash not in seen:
                        ret.append(hentry)
                        seen.add(hentry.tx_hash)
                        break
                outs = hentry.tx.get_outputs()
                for x in outs:
                    xa, dummy = x
                    if isinstance(xa, Address) and xa.to_storage_string() == address.to_storage_string() and hentry.tx_hash not in seen:
                        ret.append(hentry)
                        seen.add(hentry.tx_hash)
                        break
    #print("build_contact_tx_list: address", address.to_ui_string(), "found", len(ret),"associated txs")
    return ret
Example #2
0
 def delete_history(self, address: Address) -> None:
     if isinstance(address, str) and Address.is_valid(address):
         address = Address.from_string(address)
     storage = self.parent.wallet.storage if self.parent.wallet else None
     if storage:
         with self.lock:
             addrstr = address.to_storage_string()
             k = 'contact_history_%s' % (addrstr)
             storage.put(k, None)
             self.print_error("Deleted %s" % addrstr)
Example #3
0
 def get_history(self, address: Address) -> list:
     ret = list()
     if isinstance(address, str) and Address.is_valid(address):
         address = Address.from_string(address)
     storage = self.parent.wallet.storage if self.parent.wallet else None
     if storage:
         addrstr = address.to_storage_string()
         k = 'contact_history_%s' % (addrstr)
         hdict = storage.get(k)
         if hdict:
             ret = list(hdict.values())
             ret.sort(key=lambda x: x[1], reverse=True)
     return ret