How to use the electrumx.lib.tx_dash.DeserializerDash function in electrumX

To help you get started, we’ve selected a few electrumX examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_wrong_spec_tx():
    test = bfh(WRONG_SPEC_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 12255234
    assert tx.tx_type == 0
    extra = tx.extra_payload
    assert extra == b''
    ser = tx.serialize()
    assert ser == test
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_v2_tx():
    test = bfh(V2_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 2
    assert tx.tx_type == 0
    assert tx.extra_payload == b''
    ser = tx.serialize()
    assert ser == test
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_unknown_spec_tx():
    test = bfh(UNKNOWN_SPEC_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 187
    extra = tx.extra_payload
    assert extra == bfh(
        '0100d384e42374e8abfeffffff01570b000000a40100b67ffbbd095de31e'
        'a3844675af3e98e9601210293360bf2a2e810673412bc6e8e0e358f3fb7b'
        'dbe9a12bc6e8e0e358f3fb7bdbe9a62bc6e8e0e358f3fb7bdbe9a667b3d0'
        '103f761caf3e98e9601210293360bf2a2e810673412bc6e8e0e358f3fb7b'
        'dbe9a667b3d0103f761caf3e98e9601210293360bf2a2e810673412bc6e8'
        'e0e358f3fb7bdbe9a667b3d0103f761cabcdefab')
    ser = tx.serialize()
    assert ser == test
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_sub_tx_register_tx():
    test = bfh(SUB_TX_REGISTER)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 8
    extra = tx.extra_payload
    assert extra.version == 1
    assert extra.userName == b'abc'
    assert len(extra.pubKey) == 48
    assert extra.pubKey == bfh(
        '8e7042ec88acefcfe3d578914bb48c6bd71b3459d384e42374e8abfeffff'
        'ff01570b0000000000001976a91490c5ce9d')
    assert len(extra.payloadSig) == 96
    assert extra.payloadSig == bfh(
        '8bc992a88ac00000000a40100b67ffbbd095de31ea38446754e8abfeffff'
        'ff01570b0000000000001976a91490c5ce9d8bc992a88ac00000000a4010'
        '0b67ffbbd095de31ea38446754e8abfeffffff01570b0000000000001976'
        'a91490c5ce9d')
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_pro_reg_tx():
    test = bfh(PRO_REG_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 1
    extra = tx.extra_payload
    assert extra.version == 1
    assert extra.type == 0
    assert extra.mode == 0
    assert len(extra.collateralOutpoint.hash) == 32
    assert extra.collateralOutpoint.hash == bfh(
        '4de1afa0a321bc88c34978d4eeba739256b86f8d8cdf47651b6f60e451f0a3de')
    assert extra.collateralOutpoint.index == 1
    assert len(extra.ipAddress) == 16
    assert extra.ipAddress == bfh('00000000000000000000ffff12ca34aa')
    assert extra.port == 29999
    assert len(extra.KeyIdOwner) == 20
    assert extra.KeyIdOwner == bfh(
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_sub_tx_reset_key_tx():
    test = bfh(SUB_TX_RESET_KEY)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 10
    extra = tx.extra_payload
    assert extra.version == 1
    assert len(extra.regTxHash) == 32
    assert extra.regTxHash == bfh(
        'd384e42374e8abfeffffff01570b000000a40100b67ffbbd095de31ea3844675')
    assert len(extra.hashPrevSubTx) == 32
    assert extra.hashPrevSubTx == bfh(
        'af3e98e9601210293360bf2a2e810673412bc6e8e0e358f3fb7bdbe9a667b3d0')
    assert extra.creditFee == 1000
    assert len(extra.newPubKey) == 48
    assert extra.newPubKey == bfh(
        '601210293360bf2a2e810673412bc6e8e0e358f3fb7bdbe9a667b3d0103f7'
        '61caf3e98e9601210293360bf2a2e810673')
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_sub_tx_topup_tx():
    test = bfh(SUB_TX_TOPUP)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 9
    extra = tx.extra_payload
    assert extra.version == 1
    assert len(extra.regTxHash) == 32
    assert extra.regTxHash == bfh(
        'd384e42374e8abfeffffff01570b000000a40100b67ffbbd095de31ea3844675')
    ser = tx.serialize()
    assert ser == test
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_pro_up_rev_tx():
    test = bfh(PRO_UP_REV_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 4
    extra = tx.extra_payload
    assert extra.version == 1
    assert len(extra.proTxHash) == 32
    assert extra.proTxHash == bfh(
        'b67ffbbd095de31ea38446754b6bf251287936d2881d58b7c4efae0b54c75e9f')
    assert extra.reason == 0
    assert len(extra.inputsHash) == 32
    assert extra.inputsHash == bfh(
        'eb073521b60306717f1d4feb3e9022f886b97bf981137684716a7d3d7e45b7fe')
    assert len(extra.payloadSig) == 96
    assert extra.payloadSig == bfh(
        '83f4bb5530f7c5954e8b1ad50a74a9e1d65dcdcbe4acb8cbe3671abc7911'
        'e8c3954856c4da7e5fd242f2e4f5546f08d90849245bc593d1605654e1a9'
github kyuupichan / electrumx / tests / lib / test_tx_dash.py View on Github external
def test_dash_tx_cb_tx():
    test = bfh(CB_TX)
    deser = lib_tx_dash.DeserializerDash(test)
    tx = deser.read_tx()
    assert tx.version == 3
    assert tx.tx_type == 5
    extra = tx.extra_payload
    assert extra.version == 1
    assert extra.height == 264132
    assert len(extra.merkleRootMNList) == 32
    assert extra.merkleRootMNList == bfh(
        '76629a6e42fb519188f65889fd3ac0201be87aa227462b5643e8bb2ec1d7a82a')
    ser = tx.serialize()
    assert ser == test
github kyuupichan / electrumx / electrumx / lib / tx_dash.py View on Github external
def _serialize_extra_payload(self):
        extra = self.extra_payload
        spec_tx_class = DeserializerDash.SPEC_TX_HANDLERS.get(self.tx_type)
        if not spec_tx_class:
            assert isinstance(extra, (bytes, bytearray))
            return pack_varbytes(extra)

        if not isinstance(extra, spec_tx_class):
            raise ValueError('Dash tx_type does not conform with extra'
                             ' payload class: %s, %s' % (self.tx_type, extra))
        return pack_varbytes(extra.serialize())