• 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

Brazil Deploys Crypto Alerts System to Neutralize Cyber Threats

Brazil Deploys Crypto Alerts System to Neutralize Cyber Threats

August 28, 2026
Strategy Opens the Door to Bitcoin Sales—Michael Saylor Explains Why It Makes Sense

Bitcoin’s Price Has Stalled and Arthur Hayes Says Strategy Pays the Price

August 28, 2026
Share76Tweet47

Related Posts

Brazil Deploys Crypto Alerts System to Neutralize Cyber Threats

Brazil Deploys Crypto Alerts System to Neutralize Cyber Threats

by Moussa
August 28, 2026
0

Key TakeawaysBrazil’s central bank created a real-time alert system with Hypernative to prevent crypto cyberattacks.The tool responds to a July...

Strategy Opens the Door to Bitcoin Sales—Michael Saylor Explains Why It Makes Sense

Bitcoin’s Price Has Stalled and Arthur Hayes Says Strategy Pays the Price

by Moussa
August 28, 2026
0

Key TakeawaysArthur Hayes says Strategy’s mNAV premium sat near 0.74x on August 27, erasing its old edge.Strategy holds 840,447 BTC...

California Alone Is Holding $15 Billion in Money That Belongs to Its Residents

California Alone Is Holding $15 Billion in Money That Belongs to Its Residents

by Moussa
August 28, 2026
0

Key TakeawaysCalifornia holds $15.485B across 84M unclaimed properties for nearly 39M residents.Texas holds $10.5B as estimates show 1 in 10...

How to Sign a Musig with Bitcoin Core

by Moussa
August 28, 2026
0

I created a musig descriptor with Bitcoin Core: My addresses: tpubDCWbaTx1wFG3JHpT5sK7HD2yBDLdoonfz7SN5Jnk3UGXf3EAMNECcDrGQQXP6jccdgcczRnSDTBAXauK19EAbf3KvnHmRCsKk2gGdWP3Xke tpubDCis6zc7jL21KnV9Rz7zRz2AsFartHsdQx9uVdnd2kVuNpCNX5mhHaMwYrR7YvdT3GKqKVKNDRSz966Z9DjXqUvyz7gHkfh751GBJ68CYab The keys were master keys from other wallets....

SHRINCS Draft Targets Smaller Post-Quantum BTC Signatures: Is Bitcoin Now Quantum Proof?

by Moussa
August 28, 2026
0

In Bitcoin news today, a group of cryptography researchers has published a draft specification for SHRINCS, a post-quantum signature scheme...

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]JTNDcCUzRSUzQ2RpdiUyMGNsYXNzJTNEJTIydG5wJTIwdG5wLXN1YnNjcmlwdGlvbiUyMiUzRSUwQSUzQ2Zvcm0lMjBtZXRob2QlM0QlMjJwb3N0JTIyJTIwYWN0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZhcHByb3gub3JnJTJGJTNGbmElM0RzJTIyJTNFJTBBJTBBJTNDaW5wdXQlMjB0eXBlJTNEJTIyaGlkZGVuJTIyJTIwbmFtZSUzRCUyMm5sYW5nJTIyJTIwdmFsdWUlM0QlMjIlMjIlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1maXJzdG5hbWUlMjIlM0UlM0NsYWJlbCUyMGZvciUzRCUyMnRucC0xJTIyJTNFRmlyc3QlMjBuYW1lJTIwb3Il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zRSUwQSUzQyUyRmRpdiUzRSUwQSUzQyUyRmZvcm0lM0UlMEElM0MlMkZkaXYlM0UlM0NiciUyRiUzRSUzQyUyRnAlM0U=[/vc_raw_html][/vc_column][/vc_row]
No Result
View All Result
  • Contact Us
  • Homepages
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News