• 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

Bitcoin Drops to $107K, Triggers $714M in Liquidations

Bitcoin Drops to $107K, Triggers $714M in Liquidations

October 16, 2025
Ethereum Price Falls As StanChart Backs ETH Treasuries Vs BTC

Ethereum Up 3% As Bhutan Shifts National ID System To Ethereum

October 16, 2025
Share76Tweet47

Related Posts

Bitcoin Drops to $107K, Triggers $714M in Liquidations

Bitcoin Drops to $107K, Triggers $714M in Liquidations

by Moussa
October 16, 2025
0

On Oct. 16, the crypto market dropped below $3.8 trillion in value, led by bitcoin’s fall to $107,625—its lowest in...

Ethereum Price Falls As StanChart Backs ETH Treasuries Vs BTC

Ethereum Up 3% As Bhutan Shifts National ID System To Ethereum

by Moussa
October 16, 2025
0

Join Our Telegram channel to stay up to date on breaking news coverage The Ethereum price has surged 3% in...

Now That the Bull Run is Dead, Will Powell Do Further Rate Cuts? End of Fed Tightening Near as Job Market Softens

by Moussa
October 16, 2025
0

Now that the bull run is dead, will Fed Chair Jerome Powell do further rate cuts? This crash proved two...

Best Meme Coins to Buy as Elon Musk Might Send Dogecoin to $0.5 Rally

Best Meme Coins to Buy as Elon Musk Might Send Dogecoin to $0.5 Rally

by Moussa
October 16, 2025
0

Trusted Editorial content, reviewed by leading industry experts and seasoned editors. Ad Disclosure Quick Facts: 1️⃣ Elon Musk’s latest subtle...

Ethereum Sentiment Hits 1-year Low, Analyst Foresees 30% Run

Ethereum Ready For ‘Rapid Expansion’ As Price Holds $3,900

by Moussa
October 16, 2025
0

As the market volatility continues, Ethereum (ETH) has dropped 3.1% in the daily timeframe and is attempting to hold a...

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

© 2024 APPROX FOUNDATION - The Crypto Currency News