• About
  • FAQ
  • Earn Bitcoin while Surfing the net
  • Buy & Sell Crypto on Paxful
Newsletter
Approx Foundation
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
Approx Foundation
No Result
View All Result
Home Bitcoin

transactions – INVALID MAGIC BYTES and NOT MERKLE BLOCK RESPONSE

Moussa by Moussa
October 16, 2025
in Bitcoin
0
peer discovery – how to obtain the IP addresses of nodes for mining pools?
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


import socket
import struct
import time
import hashlib
from random import randint
from io import BytesIO

# MurmurHash3 implementation
def murmur_hash3(data, seed=0):
    c1 = 0xcc9e2d51
    c2 = 0x1b873593
    length = len(data)
    h1 = seed & 0xffffffff
    num_blocks = length // 4
    for i in range(num_blocks):
        k1 = struct.unpack("> 17)) & 0xffffffff
        k1 = (k1 * c2) & 0xffffffff
        h1 ^= k1
        h1 = ((h1 << 13) | (h1 >> 19)) & 0xffffffff
        h1 = ((h1 * 5) + 0xe6546b64) & 0xffffffff
    tail = data[num_blocks*4:]
    k1 = 0
    tlen = len(tail)
    if tlen >= 3:
        k1 ^= (tail[2] << 16) & 0xffffffff
    if tlen >= 2:
        k1 ^= (tail[1] << 8) & 0xffffffff
    if tlen >= 1:
        k1 ^= tail[0] & 0xffffffff
    if tlen > 0:
        k1 = (k1 * c1) & 0xffffffff
        k1 = ((k1 << 15) | (k1 >> 17)) & 0xffffffff
        k1 = (k1 * c2) & 0xffffffff
        h1 ^= k1
    h1 ^= length
    h1 ^= (h1 >> 16) & 0xffffffff
    h1 = (h1 * 0x85ebca6b) & 0xffffffff
    h1 ^= (h1 >> 13) & 0xffffffff
    h1 = (h1 * 0xc2b2ae35) & 0xffffffff
    h1 ^= (h1 >> 16) & 0xffffffff
    return h1

# Bloom Filter class
class BloomFilter:
    def __init__(self, size, num_funcs, tweak):
        self.size = size  # in bytes
        self.num_funcs = num_funcs
        self.tweak = tweak & 0xffffffff
        self.bit_field = bytearray([0] * size)

    def add(self, item):
        for i in range(self.num_funcs):
            seed = (i * 0xfba4c795 + self.tweak) & 0xffffffff
            h = murmur_hash3(item, seed)
            bit = h % (self.size * 8)
            self.bit_field[bit // 8] |= (1 << (bit % 8))

    def filter_bytes(self):
        return bytes(self.bit_field)

# Varint serialization
def serialize_varint(n):
    if n < 0xfd:
        return struct.pack("= len(flags):
                raise ValueError("Flags too short")
            flag = (flags[bit_pos // 8] & (1 << (bit_pos % 8))) != 0
            bit_pos += 1
            if height == 0 or not flag:
                if hash_pos >= len(hashes):
                    raise ValueError("Hashes too short")
                curr = hashes[hash_pos]
                hash_pos += 1
                if height == 0 and flag:
                    matches.append(curr)
                return curr
            left = traverse(height - 1, pos * 2)
            if pos * 2 + 1 >= (1 << height):
                right = left  # Duplicate leaf
            else:
                right = traverse(height - 1, pos * 2 + 1)
            return self.double_sha256(left + right)
        height = 0
        while (1 << height) < tx_count:
            height += 1
        root = traverse(height, 0)
        if hash_pos != len(hashes):
            raise ValueError("Extra hashes")
        if bit_pos != len(flags) * 8:
            raise ValueError("Extra bits")
        return matches, root

    def double_sha256(self, b):
        return hashlib.sha256(hashlib.sha256(b).digest()).digest()

if __name__ == '__main__':
    hosts = [
        '45.94.168.5',  # Known working node
        
    ]
    txid_hex = "0b446280724fdb10892d0f765b378023e41ddca48ca5cf6e9d08e23ccdcb65a9"
    block_hex = "00000000000000005c7ed697383655849a809350e1716100be6c57e190f89bba"

    # Internal byte order (reverse of displayed hex)
    txid_internal = bytes.fromhex(txid_hex)[::-1]
    block_internal = bytes.fromhex(block_hex)[::-1]

    # Create bloom filter for the TX
    bloom_size = 1  # Small size for single item
    num_funcs = 5
    tweak = 21
    bloom = BloomFilter(bloom_size, num_funcs, tweak)
    bloom.add(txid_internal)

    for host in hosts:
        try:
            print(f"Trying to connect to {host}...")
            node = SimpleNode(host, port=48333, testnet=True, logging=True)
            node.handshake()
            node.send_filterload(bloom)
            node.send_getdata(block_internal)
            node.wait_for_merkleblock(txid_internal)
            node.close()
            break  # Exit loop on success
        except socket.gaierror as e:
            print(f"Hostname resolution failed for {host}: {e}")
        except socket.error as e:
            print(f"Connection failed for {host}: {e}")
        except ValueError as e:
            print(f"Protocol error for {host}: {e}")
        except Exception as e:
            print(f"Other error for {host}: {e}")
    else:
        print("All hosts failed. Try finding an active Testnet4 node IP from Bitnodes or run a local node.")



Source link

Related articles

How do Bitcoin mining pools typically handle payout frequency versus thresholds?

script – OP_CAT + OP_CHECKSIGFROMSTACK: how to prevent cross-UTXO signature reuse?

March 22, 2026
Green Light for Fan Tokens: What the SEC/CFTC Ruling Means for Chiliz Crypto

Green Light for Fan Tokens: What the SEC/CFTC Ruling Means for Chiliz Crypto

March 22, 2026
Share76Tweet47

Related Posts

How do Bitcoin mining pools typically handle payout frequency versus thresholds?

script – OP_CAT + OP_CHECKSIGFROMSTACK: how to prevent cross-UTXO signature reuse?

by Moussa
March 22, 2026
0

Following up on #130598. I built a CAT + CSFS oracle-style script on signet (commit, reveal): OP_CAT OP_SHA256 OP_CHECKSIGFROMSTACK Witness:...

Green Light for Fan Tokens: What the SEC/CFTC Ruling Means for Chiliz Crypto

Green Light for Fan Tokens: What the SEC/CFTC Ruling Means for Chiliz Crypto

by Moussa
March 22, 2026
0

The US SEC and CFTC have ended regulatory uncertainty around sports crypto, issuing joint guidance on March 17, 2026, that...

Why Bitcoin Price Rallied From $65,000 To $74,000 — Analyst Gives ‘Real Reason’

Why Bitcoin Price Rallied From $65,000 To $74,000 — Analyst Gives ‘Real Reason’

by Moussa
March 21, 2026
0

Trusted Editorial content, reviewed by leading industry experts and seasoned editors. Ad Disclosure The price of Bitcoin has continued to...

Why The XRP Supply In The Billions Is Not A Problem

by Moussa
March 21, 2026
0

Crypto analyst X Finance Bull has laid out a detailed theory explaining why XRP’s large token supply, often criticized as...

Bitcoin’s Quantum Risk May Be Real, But The Network Is Preparing: Report

Bitcoin’s Quantum Risk May Be Real, But The Network Is Preparing: Report

by Moussa
March 21, 2026
0

Galaxy Digital’s latest report says the risk that quantum computing could compromise Bitcoin is real, but so is the work...

Load More

youssufi.com

sephina.com

[vc_row full_width="stretch_row" parallax="content-moving" vc_row_background="" background_repeat="no-repeat" background_position="center center" footer_scheme="dark" css=".vc_custom_1517813231908{padding-top: 60px !important;padding-bottom: 30px !important;background-color: #191818 !important;background-position: center;background-repeat: no-repeat !important;background-size: cover !important;}" footer_widget_title_color="#fcbf46" footer_button_bg="#fcb11e"][vc_column width="1/4"]

We bring you the latest in Crypto News

[/vc_column][vc_column width="1/4"][vc_wp_categories]
[/vc_column][vc_column width="1/4"][vc_wp_tagcloud taxonomy="post_tag"][/vc_column][vc_column width="1/4"]

Newsletter

[vc_raw_html]JTNDcCUzRSUzQ2RpdiUyMGNsYXNzJTNEJTIydG5wJTIwdG5wLXN1YnNjcmlwdGlvbiUyMiUzRSUwQSUzQ2Zvcm0lMjBtZXRob2QlM0QlMjJwb3N0JTIyJTIwYWN0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZhcHByb3gub3JnJTJGJTNGbmElM0RzJTIyJTNFJTBBJTBBJTNDaW5wdXQlMjB0eXBlJTNEJTIyaGlkZGVuJTIyJTIwbmFtZSUzRCUyMm5sYW5nJTIyJTIwdmFsdWUlM0QlMjIlMjIlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1maXJzdG5hbWUlMjIlM0UlM0NsYWJlbCUyMGZvciUzRCUyMnRucC0xJTIyJTNFRmlyc3QlMjBuYW1lJTIwb3IlMjBmdWxsJTIwbmFtZSUzQyUyRmxhYmVsJTNFJTBBJTNDaW5wdXQlMjBjbGFzcyUzRCUyMnRucC1uYW1lJTIyJTIwdHlwZSUzRCUyMnRleHQlMjIlMjBuYW1lJTNEJTIybm4lMjIlMjB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ages
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News