mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 07:23:25 +00:00
fix for notifications
This commit is contained in:
parent
8fc042ee22
commit
0e851a5f62
2 changed files with 35 additions and 8 deletions
|
@ -446,7 +446,7 @@ class Wallet:
|
||||||
for addr in domain:
|
for addr in domain:
|
||||||
h = self.history.get(addr, [])
|
h = self.history.get(addr, [])
|
||||||
if h == ['*']: continue
|
if h == ['*']: continue
|
||||||
for tx_hash, tx_height, in h:
|
for tx_hash, tx_height in h:
|
||||||
tx = self.transactions.get(tx_hash)
|
tx = self.transactions.get(tx_hash)
|
||||||
for output in tx.get('outputs'):
|
for output in tx.get('outputs'):
|
||||||
if output.get('address') != addr: continue
|
if output.get('address') != addr: continue
|
||||||
|
@ -459,7 +459,8 @@ class Wallet:
|
||||||
|
|
||||||
for addr in self.prioritized_addresses:
|
for addr in self.prioritized_addresses:
|
||||||
h = self.history.get(addr, [])
|
h = self.history.get(addr, [])
|
||||||
for tx_hash, tx_height, in h:
|
if h == ['*']: continue
|
||||||
|
for tx_hash, tx_height in h:
|
||||||
for output in tx.get('outputs'):
|
for output in tx.get('outputs'):
|
||||||
if output.get('address') != addr: continue
|
if output.get('address') != addr: continue
|
||||||
key = tx_hash + ":%d" % output.get('index')
|
key = tx_hash + ":%d" % output.get('index')
|
||||||
|
@ -571,7 +572,14 @@ class Wallet:
|
||||||
if hist != ['*']:
|
if hist != ['*']:
|
||||||
for tx_hash, tx_height in hist:
|
for tx_hash, tx_height in hist:
|
||||||
if tx_height>0:
|
if tx_height>0:
|
||||||
|
# add it in case it was previously unconfirmed
|
||||||
self.verifier.add(tx_hash, tx_height)
|
self.verifier.add(tx_hash, tx_height)
|
||||||
|
# set the height in case it changed
|
||||||
|
tx = self.transactions.get(tx_hash)
|
||||||
|
if tx:
|
||||||
|
if tx.get('height') != tx_height:
|
||||||
|
print_error( "changing height for tx", tx_hash )
|
||||||
|
tx['height'] = tx_height
|
||||||
|
|
||||||
|
|
||||||
def get_tx_history(self):
|
def get_tx_history(self):
|
||||||
|
@ -893,6 +901,7 @@ class Wallet:
|
||||||
def set_verifier(self, verifier):
|
def set_verifier(self, verifier):
|
||||||
self.verifier = verifier
|
self.verifier = verifier
|
||||||
|
|
||||||
|
# review transactions (they might not all be in history)
|
||||||
for tx_hash, tx in self.transactions.items():
|
for tx_hash, tx in self.transactions.items():
|
||||||
tx_height = tx.get('height')
|
tx_height = tx.get('height')
|
||||||
if tx_height <1:
|
if tx_height <1:
|
||||||
|
@ -909,6 +918,20 @@ class Wallet:
|
||||||
self.set_tx_timestamp(tx_hash, timestamp)
|
self.set_tx_timestamp(tx_hash, timestamp)
|
||||||
|
|
||||||
|
|
||||||
|
# review existing history
|
||||||
|
for addr, hist in self.history.items():
|
||||||
|
if hist == ['*']: continue
|
||||||
|
for tx_hash, tx_height in hist:
|
||||||
|
if tx_height>0:
|
||||||
|
# add it in case it was previously unconfirmed
|
||||||
|
self.verifier.add(tx_hash, tx_height)
|
||||||
|
# set the height in case it changed
|
||||||
|
tx = self.transactions.get(tx_hash)
|
||||||
|
if tx:
|
||||||
|
if tx.get('height') != tx_height:
|
||||||
|
print_error( "changing height for tx", tx_hash )
|
||||||
|
tx['height'] = tx_height
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def set_tx_timestamp(self, tx_hash, timestamp):
|
def set_tx_timestamp(self, tx_hash, timestamp):
|
||||||
|
@ -1064,6 +1087,7 @@ class WalletSynchronizer(threading.Thread):
|
||||||
|
|
||||||
elif method == 'blockchain.address.get_history':
|
elif method == 'blockchain.address.get_history':
|
||||||
addr = params[0]
|
addr = params[0]
|
||||||
|
print_error("receiving history", addr, result)
|
||||||
if result == ['*']:
|
if result == ['*']:
|
||||||
assert requested_histories.pop(addr) == '*'
|
assert requested_histories.pop(addr) == '*'
|
||||||
self.wallet.receive_history_callback(addr, result)
|
self.wallet.receive_history_callback(addr, result)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys
|
import sys, time
|
||||||
from electrum import Interface
|
from electrum import Interface
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -9,15 +9,18 @@ except:
|
||||||
print "usage: watch_address <bitcoin_address>"
|
print "usage: watch_address <bitcoin_address>"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
i = Interface({'server':'electrum.novit.ro:50001:t'})
|
i = Interface({'server':'ecdsa.org:50001:t'})
|
||||||
i.start()
|
i.start()
|
||||||
i.send([('blockchain.address.subscribe',[addr])] )
|
i.send([('blockchain.address.subscribe',[addr])] )
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r = i.responses.get(True, 100000000000)
|
r = i.get_response()
|
||||||
method = r.get('method')
|
method = r.get('method')
|
||||||
if method == 'blockchain.address.subscribe':
|
if method == 'blockchain.address.subscribe':
|
||||||
i.send([('blockchain.address.get_history',[addr])])
|
#i.send([('blockchain.address.get_history',[addr])])
|
||||||
|
print r
|
||||||
|
|
||||||
elif method == 'blockchain.address.get_history':
|
elif method == 'blockchain.address.get_history':
|
||||||
confirmed = unconfirmed = 0
|
confirmed = unconfirmed = 0
|
||||||
h = r.get('result')
|
h = r.get('result')
|
||||||
|
|
Loading…
Add table
Reference in a new issue