Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative confirmations, block height not syncing #4990

Closed
MrNaif2018 opened this issue Jan 5, 2019 · 3 comments
Closed

Negative confirmations, block height not syncing #4990

MrNaif2018 opened this issue Jan 5, 2019 · 3 comments

Comments

@MrNaif2018
Copy link
Contributor

I am writing app using electrum version 3.3.2 in python. My task is to get confirmations of bitcoin transaction. I get it as current block height minus block height of transaction, because(maybe it is a bug too) wallet(electrum.Wallet object).get_tx_height(tx_hash_passed_here) always returns 0 confirmations,for both my wallet and non wallet transactions,but tx height is correct. It works fine just after restart,but after some time(half a day or so),it stops syncing block height. For getting block height I don't use wallet.local_height() or similar,because they also return incorrect results. I get height as in block_headers.py script example in source tree, with some modifications done after asking in electrum group.
Code is the following:

from electrum.network import Network
from electrum.util import create_and_start_event_loop
#block_headers.py start

# start network
loop, stopping_fut, loop_thread = create_and_start_event_loop()
network = Network()
network.start()

# wait until connected
while not network.is_connected():
    time.sleep(1)

header_queue = asyncio.Queue()

timer=time.time()
 
async def update_height():
    global height_blocks
    try:
        await network.interface.session.subscribe('blockchain.headers.subscribe', [], header_queue)
        while True:
            if network.is_connected():
                timer=time.time()
                header = await header_queue.get()
                max_height=-99999999
                for i in header:
                    if i["height"] > max_height:
                        max_height=i["height"]
                height_blocks=max_height
            else:
                if time.time() - timer > 10:
                    timer=time.time()
                    network.stop() # check with and without: may not be required
                    network.start()
    finally:
        stopping_fut.set_result(1)

#block_headers.py end

And confirmations I get the following way:
conf=height_blocks-height+1
So confirmations are negative because of electrum not syncing height.

@MrNaif2018
Copy link
Contributor Author

Also,when looking at logs, I found some traceback from electrum(looks like from its network thread),maybe it will help. Probably it is because I have just removed blockhain_headers as suggested in other conversation. But still looking for help(is it a bug or not,seems to be a bug).
Here it is the error traceback:
https://imgur.com/a/YALcKg8

@MrNaif2018
Copy link
Contributor Author

Small bump! Sorry for this,but this issue is a bug and I thought to get some answers what is it. And on forums(bitcointalk) I was even said that negative confirmations is quite common problem. If it is not a bug,please,give me solution to this problem,as I couldn't get support in IRC group.

@SomberNight
Copy link
Member

My task is to get confirmations of bitcoin transaction

See the get_tx_status RPC in 8f5ca40
for wallet-related transactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants