fix #1181
This commit is contained in:
parent
df73b8017a
commit
75ddc066bb
|
@ -462,39 +462,45 @@ class Abstract_Wallet(object):
|
|||
fee = v_out - v_in
|
||||
return is_relevant, is_send, v, fee
|
||||
|
||||
def get_addr_utxo(self, address):
|
||||
def get_addr_io(self, address):
|
||||
h = self.history.get(address, [])
|
||||
coins = {}
|
||||
received = {}
|
||||
sent = {}
|
||||
for tx_hash, height in h:
|
||||
l = self.txo.get(tx_hash, {}).get(address, [])
|
||||
for n, v, is_cb in l:
|
||||
coins[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:
|
||||
coins.pop(txi)
|
||||
sent[txi] = height
|
||||
return received, sent
|
||||
|
||||
def get_addr_utxo(self, address):
|
||||
coins, spent = self.get_addr_io(address)
|
||||
for txi in spent:
|
||||
coins.pop(txi)
|
||||
return coins.items()
|
||||
|
||||
#return the total amount ever received by an address
|
||||
# return the total amount ever received by an address
|
||||
def get_addr_received(self, address):
|
||||
h = self.history.get(address, [])
|
||||
received = 0
|
||||
for tx_hash, height in h:
|
||||
l = self.txo.get(tx_hash, {}).get(address, [])
|
||||
for n, v, is_cb in l:
|
||||
received += v
|
||||
return received
|
||||
received, sent = self.get_addr_io(address)
|
||||
return sum([v for height, v, is_cb in received.values()])
|
||||
|
||||
# return the confirmed balance and pending (unconfirmed) balance change of a bitcoin address
|
||||
def get_addr_balance(self, address):
|
||||
"returns the confirmed balance and pending (unconfirmed) balance change of a bitcoin address"
|
||||
coins = self.get_addr_utxo(address)
|
||||
received, sent = self.get_addr_io(address)
|
||||
c = u = 0
|
||||
for txo, v in coins:
|
||||
tx_height, v, is_cb = v
|
||||
for txo, (tx_height, v, is_cb) in received.items():
|
||||
if tx_height > 0:
|
||||
c += v
|
||||
else:
|
||||
u += v
|
||||
if txo in sent:
|
||||
if sent[txo] > 0:
|
||||
c -= v
|
||||
else:
|
||||
u -= v
|
||||
return c, u
|
||||
|
||||
|
||||
|
@ -525,17 +531,6 @@ class Abstract_Wallet(object):
|
|||
coins = coins[1:] + [ coins[0] ]
|
||||
return [value for height, value in coins]
|
||||
|
||||
def get_addr_balance2(self, address):
|
||||
"returns the confirmed balance and pending (unconfirmed) balance change of a bitcoin address"
|
||||
coins = self.get_addr_utxo(address)
|
||||
c = u = 0
|
||||
for txo, v, height in coins:
|
||||
if height > 0:
|
||||
c += v
|
||||
else:
|
||||
u += v
|
||||
return c, u
|
||||
|
||||
def get_account_name(self, k):
|
||||
return self.labels.get(k, self.accounts[k].get_name(k))
|
||||
|
||||
|
|
Loading…
Reference in New Issue