# Path: qa/rpc-tests/test_framework/util.py
# def hex_str_to_bytes(hex_str):
#     return unhexlify(hex_str.encode('ascii'))
# 
# def bytes_to_hex_str(byte_str):
#     return hexlify(byte_str).decode('ascii')


import struct
import socket
import asyncore
import time
import sys
import random
import hashlib
import logging
import copy
import bridgecoin_scrypt
from .util import hex_str_to_bytes, bytes_to_hex_str
from io import BytesIO
from codecs import encode
from threading import RLock
from threading import Thread
from test_framework.siphash import siphash256
        r += ser_compact_size(self.index)
        if with_witness:
            r += self.tx.serialize_with_witness()
        else:
            r += self.tx.serialize_without_witness()
        return r

    def serialize_with_witness(self):
        return self.serialize(with_witness=True)

    def __repr__(self):
        return "PrefilledTransaction(index=%d, tx=%s)" % (self.index, repr(self.tx))

# This is what we send on the wire, in a cmpctblock message.
class P2PHeaderAndShortIDs(object):
    def __init__(self):
        self.header = CBlockHeader()
        self.nonce = 0
        self.shortids_length = 0
        self.shortids = []
        self.prefilled_txn_length = 0
        self.prefilled_txn = []

    def deserialize(self, f):
        self.header.deserialize(f)
        self.nonce = struct.unpack("<Q", f.read(8))[0]
        self.shortids_length = deser_compact_size(f)
        for i in range(self.shortids_length):
            # shortids are defined to be 6 bytes in the spec, so append
            # two zero bytes and read it in as an 8-byte number

# Path: qa/rpc-tests/test_framework/util.py
# def hex_str_to_bytes(hex_str):
#     return unhexlify(hex_str.encode('ascii'))
# 
# def bytes_to_hex_str(byte_str):
#     return hexlify(byte_str).decode('ascii')


# Path: qa/rpc-tests/test_framework/mininode.py
import struct
import socket
import asyncore
import time
import sys
import random
import hashlib
import logging
import copy
import bridgecoin_scrypt
from .util import hex_str_to_bytes, bytes_to_hex_str
from io import BytesIO
from codecs import encode
from threading import RLock
from threading import Thread
from test_framework.siphash import siphash256

        r += ser_compact_size(self.index)
        if with_witness:
            r += self.tx.serialize_with_witness()
        else:
            r += self.tx.serialize_without_witness()
        return r

    def serialize_with_witness(self):
        return self.serialize(with_witness=True)

    def __repr__(self):
        return "PrefilledTransaction(index=%d, tx=%s)" % (self.index, repr(self.tx))

# This is what we send on the wire, in a cmpctblock message.
class P2PHeaderAndShortIDs(object):
    def __init__(self):
        self.header = CBlockHeader()
        self.nonce = 0
        self.shortids_length = 0
        self.shortids = []
        self.prefilled_txn_length = 0
        self.prefilled_txn = []

    def deserialize(self, f):
        self.header.deserialize(f)
        self.nonce = struct.unpack("<Q", f.read(8))[0]
        self.shortids_length = deser_compact_size(f)
        for i in range(self.shortids_length):
            # shortids are defined to be 6 bytes in the spec, so append
            # two zero bytes and read it in as an 8-byte number

            self.shortids.append(struct.unpack("<Q", f.read(6) + b'\x00\x00')[0])