Esempio n. 1
0
def buildInventoryMessage(networkType, inventory):
    invHashes = []
    for item in inventory:
        invHashes.append(
            struct.pack("<L", item[0]) +
            hashlib.sha256(hashlib.sha256(item[1]).digest()).digest()[::-1])
    return buildMessage(networkType, "inv",
                        utils.varint(len(invHashes)) + "".join(invHashes))
Esempio n. 2
0
def getGetblockMsg():
    genesis = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
    genesis_str = genesis.decode('hex')[::-1] # reversed
    recent = "000000000000000592f4797aab7c1fd891a4cacd300d2115f25fa5afab547cdf"
    recent_str = recent.decode('hex')[::-1] # reversed

    hash_stop_str = '\0' * 32
    payload_getblocks = struct.pack('<L', version) + utils.varint(2) + recent_str + genesis_str + hash_stop_str
    return makeMessage(magic, 'getblocks', payload_getblocks)
Esempio n. 3
0
def getGetblockMsg():
    genesis = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
    genesis_str = genesis.decode('hex')[::-1]  # reversed
    recent = "000000000000000592f4797aab7c1fd891a4cacd300d2115f25fa5afab547cdf"
    recent_str = recent.decode('hex')[::-1]  # reversed

    hash_stop_str = '\0' * 32
    payload_getblocks = struct.pack(
        '<L',
        version) + utils.varint(2) + recent_str + genesis_str + hash_stop_str
    return makeMessage(magic, 'getblocks', payload_getblocks)
Esempio n. 4
0
def getInvMsg():
    inv_hash = "235402020007000592f4797a567c1fd89144cacd300d2115f12fa53fab547abc"
    payload_inv = utils.varint(1) + struct.pack(
        '<L', 2) + inv_hash.decode('hex')[::-1]
    return makeMessage(magic, 'inv', payload_inv)
Esempio n. 5
0
def getGetdataMsg():
    payload_getdata = utils.varint(1) + struct.pack('<L', 2) + recent_str
    return makeMessage(magic, 'getdata', payload_getdata)
Esempio n. 6
0
def addr(ip_addres,port):
    var_int_adress_number=utils.varint(1)
    # timestamp=struct.pack("q", int(time.time()))
    payload=var_int_adress_number+pack_addr(ip_addres,port)
    return make_header_message("addr",payload)
Esempio n. 7
0
def getInvMsg():
    inv_hash = "235402020007000592f4797a567c1fd89144cacd300d2115f12fa53fab547abc"
    payload_inv = utils.varint(1) + struct.pack('<L', 2) + inv_hash.decode('hex')[::-1]
    return makeMessage(magic, 'inv', payload_inv)
Esempio n. 8
0
def getGetdataMsg():
    payload_getdata = utils.varint(1) + struct.pack('<L', 2) + recent_str
    return makeMessage(magic, 'getdata', payload_getdata)
Esempio n. 9
0
def buildInventoryMessage(networkType, inventory):
    invHashes = []
    for item in inventory:
        invHashes.append(struct.pack("<L", item[0]) + 
            hashlib.sha256(hashlib.sha256(item[1]).digest()).digest()[::-1])
    return buildMessage(networkType, "inv", utils.varint(len(invHashes)) + "".join(invHashes))