'effect of tx on wallet'

def get_wallet_delta(self, tx):

    addresses = self.get_addresses()
    is_relevant = False
    is_mine = False
    is_pruned = False
    is_partial = False
    v_in = v_out = v_out_mine = 0
    for item in tx.inputs():
        addr = item.get('address')
        if (addr in addresses):
            is_mine = True
            is_relevant = True
            d = self.txo.get(item['prevout_hash'], {}).get(addr, [])
            for (n, v, cb) in d:
                if (n == item['prevout_n']):
                    value = v
                    break
            else:
                value = None
            if (value is None):
                is_pruned = True
            else:
                v_in += value
        else:
            is_partial = True
    if (not is_mine):
        is_partial = False
    for (addr, value) in tx.get_outputs():
        v_out += value
        if (addr in addresses):
            v_out_mine += value
            is_relevant = True
    if is_pruned:
        fee = None
        if is_mine:
            v = (v_out_mine - v_out)
        else:
            v = v_out_mine
    else:
        v = (v_out_mine - v_in)
        if is_partial:
            fee = None
        else:
            fee = (v_in - v_out)
    if (not is_mine):
        fee = None
    return (is_relevant, is_mine, v, fee)
