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

Bug: failed to get block hash <block hash> #21

Open
redtigervn opened this issue Oct 29, 2024 · 1 comment
Open

Bug: failed to get block hash <block hash> #21

redtigervn opened this issue Oct 29, 2024 · 1 comment

Comments

@redtigervn
Copy link

redtigervn commented Oct 29, 2024

Hi there,

I've installed bitcoin node and electrs server on VPS. I write nodejs script to listen new transaction from specific addrs and I get this error when I use Electrum protocol method blockchain.scripthash.subscribe to subscribe scripthash. Then I use electrumClient.subscribe.on event to listen new tx. But I always get this error

Failed to get block: 0000000000000000000000b71ed0d9bec536d4fbbfa4da8dece0edb25324d11db0

This block hash has 66 characters instead of 64 characters. Anyone get this error?

I also delete electrs_db folder and sync data again but it doesn't help.

image

const crypto = require('crypto');
const ecc = require('tiny-secp256k1');
const bitcoin = require('bitcoinjs-lib');
bitcoin.initEccLib(ecc);

const script = bitcoin.address.toOutputScript('1GrwDkr33gT6LuumniYjKEGjTLhsL5kmqC');
const hash = crypto.createHash('sha256').update(script).digest();
const reversedHash = Buffer.from(hash.reverse());
cosnt scripthash = reversedHash.toString('hex');

electrumClient.blockchainScripthash_subscribe(scripthash).then((scripthash) => {              
    console.log(`Subscribed to updates for scripthash: ${scriptHash}`);
});

electrumClient.subscribe.on('blockchain.scripthash.subscribe', async (data) => {
    const [scripthash, status] = data;
    //receive a notification when the status of the script hash changes.
    //do something here....
});
@Overtorment
Copy link

sounds like electrs problem. you better take it to their github repo

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