Example #1
0
class Transaction(Message):
    command = "tx"
    name = "transaction"

    properties = [
        ('version', format.FormatTypeNumber('I')),
        ('tx_in', format.FormatTypeArray(format.FormatTypeTxnIn(), 1)),
        ('tx_out', format.FormatTypeArray(format.FormatTypeTxnOut(), 1)),
        ('lock_time', format.FormatTypeNumber('I')),
    ]

    def _debug(self):
        return _debug(self, [('in', self.tx_in), ('out', self.tx_out)])
Example #2
0
class Block(Message):
    command = "block"

    properties = [
        ('version', format.FormatTypeNumber('I')),
        ('prev_block', format.FormatTypeBytes(32)),
        ('merkle_root', format.FormatTypeBytes(32)),
        ('timestamp', format.FormatTypeNumber('I', allow_float=True)),
        ('bits', format.FormatTypeNumber('I')),
        ('nonce', format.FormatTypeNumber('I')),
        ('txns', format.FormatTypeArray(format.FormatTypeTxn())),
    ]

    @staticmethod
    def from_block(block):
        return Block(block.version, block.previous_block_hash,
                     block.merkle_root, block.timestamp, block.bits,
                     block.nonce, block.transactions)

    def _debug(self):
        block_hash = util.get_block_header(self.version, self.prev_block,
                                           self.merkle_root, self.timestamp,
                                           self.bits, self.nonce)
        return _debug(self, [('h', block_hash.encode('hex')),
                             ('t', self.txns)])
Example #3
0
class MerkleBlock(Message):
    command = "merkleblock"
    name = "merkle_block"

    do_not_register = True

    properties = [
        ('version', format.FormatTypeNumber('I')),
        ('prev_block', format.FormatTypeBytes(32)),
        ('merkle_root', format.FormatTypeBytes(32)),
        ('timestamp', format.FormatTypeNumber('I', allow_float=True)),
        ('bits', format.FormatTypeNumber('I')),
        ('nonce', format.FormatTypeNumber('I')),
        ('total_transactions', format.FormatTypeNumber('I')),
        ('hashes', format.FormatTypeArray(format.FormatTypeBytes(32))),
        ('flags', format.FormatTypeArray(format.FormatTypeNumber('b'))),
    ]
Example #4
0
class Headers(Message):
    command = "headers"

    properties = [
        ('headers', format.FormatTypeArray(format.FormatTypeBlockHeader())),
    ]

    def _debug(self):
        return _debug(self, [('h', self.headers)])
Example #5
0
class FilterLoad(Message):
    command = "filterload"
    name = "filter_load"

    do_not_register = True

    properties = [
        ('filter', format.FormatTypeArray(format.FormatTypeNumber('B'))),
        ('n_hashes_func', format.FormatTypeNumber('I')),
        ('n_tweak', format.FormatTypeNumber('I')),
        ('n_flags', format.FormatTypeNumber('B')),
    ]
Example #6
0
class Inventory(Message):
    command = 'inv'
    name = "inventory"

    properties = [
        ('inventory',
         format.FormatTypeArray(format.FormatTypeInventoryVector(),
                                max_length=50000)),
    ]

    def _debug(self):
        return _debug(self, [('i', self.inventory)])
Example #7
0
class Address(Message):
    command = 'addr'
    name = "address"

    properties = [
        ('addr_list',
         format.FormatTypeArray(format.FormatTypeNetworkAddress(),
                                max_length=1000)),
    ]

    def _debug(self):
        return _debug(self, [('a', self.addr_list)])
Example #8
0
class GetBlocks(Message):
    command = "getblocks"
    name = "get_blocks"

    properties = [
        ('version', format.FormatTypeNumber('I')),
        ('block_locator_hashes',
         format.FormatTypeArray(format.FormatTypeBytes(32), 1)),
        ('hash_stop', format.FormatTypeBytes(32)),
    ]

    def _debug(self):
        return _debug(
            self,
            [('blh', [h.encode('hex') for h in self.block_locator_hashes])])