def test_nem_signtx_xem_as_mosaic(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 5000000,
                "fee": 1000000,
                "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x98 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 9000000,
                    }
                ],
            },
        )

        # trezor should display 45 XEM (multiplied by amount)
        assert (
            tx.data.hex()
            == "0101000002000098ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f5595042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a404b4c000000000000000000010000001a0000000e000000030000006e656d0300000078656d4054890000000000"
        )
        assert (
            tx.signature.hex()
            == "7b25a84b65adb489ea55739f1ca2d83a0ae069c3c58d0ea075fc30bfe8f649519199ad2324ca229c6c3214191469f95326e99712124592cae7cd3a092c93ac0c"
        )
Пример #2
0
    def test_nem_signtx_mosaic_creation(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_CREATION,
                "deadline": 74735615,
                "message": {},
                "mosaicDefinition": {
                    "id": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "levy": {},
                    "properties": {},
                    "description": "lorem",
                },
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex()
            == "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f7404c100000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000030160000000d000000696e697469616c537570706c7901000000301a0000000d000000737570706c794d757461626c650500000066616c7365190000000c0000007472616e7366657261626c650500000066616c7365000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
        )
        assert (
            tx.signature.hex()
            == "537adf4fd9bd5b46e204b2db0a435257a951ed26008305e0aa9e1201dafa4c306d7601a8dbacabf36b5137724386124958d53202015ab31fb3d0849dfed2df0e"
        )
    def test_nem_signtx_known_mosaic(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 3000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "dim", "name": "token"},
                        "quantity": 111000,
                    }
                ],
            },
        )

        # trezor should display 0 XEM and 0.333 DIMTOK
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c54c0c62d000000000000000000010000001c000000100000000300000064696d05000000746f6b656e98b1010000000000"
        )
        assert (
            tx.signature.hex()
            == "e7f14ef8c39727bfd257e109cd5acac31542f2e41f2e5deb258fc1db602b690eb1cabca41a627fe2adc51f3193db85c76b41c80bb60161eb8738ebf20b507104"
        )
    def test_nem_signtx_unknown_mosaic(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x98 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "xxx", "name": "aa"},
                        "quantity": 3500000,
                    }
                ],
            },
        )

        # trezor should display warning about unknown mosaic and then dialog for 7000000 raw units of xxx.aa and 0 XEM
        assert (
            tx.data.hex()
            == "0101000002000098ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f5595042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e00000000000000000001000000190000000d00000003000000787878020000006161e067350000000000"
        )
        assert (
            tx.signature.hex()
            == "2f0280420eceb41ef9e5d94fa44ddda9cdc70b8f423ae18af577f6d85df64bb4aaf40cf24fc6eef47c63b0963611f8682348cecdc49a9b64eafcbe7afcb49102"
        )
    def test_nem_signtx_known_mosaic_with_levy(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "dim", "name": "coin"},
                        "quantity": 222000,
                    }
                ],
            },
        )

        # trezor should display 0 XEM and 0.444 DIM and levy of 0.000444 DIM
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c5480841e000000000000000000010000001b0000000f0000000300000064696d04000000636f696e3063030000000000"
        )
        assert (
            tx.signature.hex()
            == "d3222dd7b83d66bda0539827ac6f909d06e40350b5e5e893d6fa762f954e9bf7da61022ef04950e7b6dfa88a2278f2f8a1b21df2bc3af22b388cb3a90bf76f07"
        )
    def test_nem_signtx_xem_as_mosaic(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 5000000,
                "fee": 1000000,
                "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x98 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 9000000,
                    }
                ],
            },
        )

        # trezor should display 45 XEM (multiplied by amount)
        assert (
            tx.data.hex()
            == "0101000002000098ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f5595042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a404b4c000000000000000000010000001a0000000e000000030000006e656d0300000078656d4054890000000000"
        )
        assert (
            tx.signature.hex()
            == "7b25a84b65adb489ea55739f1ca2d83a0ae069c3c58d0ea075fc30bfe8f649519199ad2324ca229c6c3214191469f95326e99712124592cae7cd3a092c93ac0c"
        )
    def test_nem_signtx_aggregate_modification(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_AGGREGATE_MODIFICATION,
                "deadline": 74735615,
                "message": {},
                "modifications": [
                    {
                        "modificationType": 1,  # Add
                        "cosignatoryAccount": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                    }
                ],
                "minCosignatories": {"relativeChange": 3},
                "version": (0x98 << 24),
            },
        )
        assert (
            tx.data.hex()
            == "01100000020000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f740401000000280000000100000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f878440400000003000000"
        )
        assert (
            tx.signature.hex()
            == "1200e552d8732ce3eae96719731194abfc5a09d98f61bb35684f4eeaeff15b1bdf326ee7b1bbbe89d3f68c8e07ad3daf72e4c7f031094ad2236b97918ad98601"
        )
    def test_nem_signtx_unknown_mosaic(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x98 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "xxx", "name": "aa"},
                        "quantity": 3500000,
                    }
                ],
            },
        )

        # trezor should display warning about unknown mosaic and then dialog for 7000000 raw units of xxx.aa and 0 XEM
        assert (
            tx.data.hex()
            == "0101000002000098ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f5595042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e00000000000000000001000000190000000d00000003000000787878020000006161e067350000000000"
        )
        assert (
            tx.signature.hex()
            == "2f0280420eceb41ef9e5d94fa44ddda9cdc70b8f423ae18af577f6d85df64bb4aaf40cf24fc6eef47c63b0963611f8682348cecdc49a9b64eafcbe7afcb49102"
        )
    def test_nem_signtx_mosaic_supply_change(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 74649215,
                    "fee": 2000000,
                    "type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
                    "deadline": 74735615,
                    "message": {},
                    "mosaicId": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "supplyType": 1,
                    "delta": 1,
                    "version": (0x98 << 24),
                    "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "creationFee": 1500,
                },
            )

            assert (
                tx.data.hex()
                == "02400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963010000000100000000000000"
            )
            assert (
                tx.signature.hex()
                == "928b03c4a69fff35ecf0912066ea705895b3028fad141197d7ea2b56f1eef2a2516455e6f35d318f6fa39e2bb40492ac4ae603260790f7ebc7ea69feb4ca4c0a"
            )
Пример #10
0
    def _nem_sign(self, num_of_swipes, test_suite):
        n = parse_path("m/44'/1'/0'/0'/0'")

        def input_flow():
            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            self.client.debug.press_yes()

            # Swipe and confirm
            time.sleep(1)
            for i in range(num_of_swipes):
                self.client.debug.swipe_down()
                time.sleep(1)
            self.client.debug.press_yes()

            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            self.client.debug.press_yes()

            # Sign Tx
            btn_code = yield
            assert btn_code == B.SignTx
            self.client.debug.press_yes()

        with self.client:
            self.client.set_expected_responses([
                proto.ButtonRequest(code=B.ConfirmOutput),
                proto.ButtonRequest(code=B.ConfirmOutput),
                proto.ButtonRequest(code=B.SignTx),
                proto.NEMSignedTx(),
            ])
            self.client.set_input_flow(input_flow)
            return nem.sign_tx(self.client, n, test_suite)
    def test_nem_signtx_known_mosaic(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 3000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "dim", "name": "token"},
                        "quantity": 111000,
                    }
                ],
            },
        )

        # trezor should display 0 XEM and 0.333 DIMTOK
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c54c0c62d000000000000000000010000001c000000100000000300000064696d05000000746f6b656e98b1010000000000"
        )
        assert (
            tx.signature.hex()
            == "e7f14ef8c39727bfd257e109cd5acac31542f2e41f2e5deb258fc1db602b690eb1cabca41a627fe2adc51f3193db85c76b41c80bb60161eb8738ebf20b507104"
        )
Пример #12
0
    def test_nem_signtx_mosaic_creation_levy(self, client):
        tx = nem.sign_tx(
            client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_CREATION,
                "deadline": 74735615,
                "message": {},
                "mosaicDefinition": {
                    "id": {
                        "namespaceId": "hellom",
                        "name": "Hello mosaic"
                    },
                    "properties": [
                        {
                            "name": "divisibility",
                            "value": "4"
                        },
                        {
                            "name": "initialSupply",
                            "value": "200"
                        },
                        {
                            "name": "supplyMutable",
                            "value": "false"
                        },
                        {
                            "name": "transferable",
                            "value": "true"
                        },
                    ],
                    "levy": {
                        "type": 1,
                        "fee": 2,
                        "recipient":
                        "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                        "mosaicId": {
                            "namespaceId": "hellom",
                            "name": "Hello mosaic"
                        },
                    },
                    "description":
                    "lorem",
                },
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex() ==
            "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041801000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000034180000000d000000696e697469616c537570706c79030000003230301a0000000d000000737570706c794d757461626c650500000066616c7365180000000c0000007472616e7366657261626c65040000007472756556000000010000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a1a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f7361696302000000000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
        )
        assert (
            tx.signature.hex() ==
            "b87aac1ddf146d35e6a7f3451f57e2fe504ac559031e010a51261257c37bd50fcfa7b2939dd7a3203b54c4807d458475182f5d3dc135ec0d1d4a9cd42159fd0a"
        )
Пример #13
0
    def test_nem_signtx_mosaic_supply_change(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
                "deadline": 74735615,
                "message": {},
                "mosaicId": {"namespaceId": "hellom", "name": "Hello mosaic"},
                "supplyType": 1,
                "delta": 1,
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex()
            == "02400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963010000000100000000000000"
        )
        assert (
            tx.signature.hex()
            == "928b03c4a69fff35ecf0912066ea705895b3028fad141197d7ea2b56f1eef2a2516455e6f35d318f6fa39e2bb40492ac4ae603260790f7ebc7ea69feb4ca4c0a"
        )
Пример #14
0
    def _nem_sign(self, client, num_of_swipes, test_suite):
        n = parse_path("m/44'/1'/0'/0'/0'")

        def input_flow():
            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            client.debug.press_yes()

            # Swipe and confirm
            yield
            for _ in range(num_of_swipes):
                client.debug.swipe_up()
            client.debug.press_yes()

            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            client.debug.press_yes()

            # Sign Tx
            btn_code = yield
            assert btn_code == B.SignTx
            client.debug.press_yes()

        with client:
            client.set_expected_responses([
                proto.ButtonRequest(code=B.ConfirmOutput),
                proto.ButtonRequest(code=B.ConfirmOutput),
                proto.ButtonRequest(code=B.ConfirmOutput),
                proto.ButtonRequest(code=B.SignTx),
                proto.NEMSignedTx,
            ])
            client.set_input_flow(input_flow)
            return nem.sign_tx(client, n, test_suite)
Пример #15
0
 def test_nem_signtx_aggregate_modification(self, client):
     tx = nem.sign_tx(
         client,
         parse_path("m/44'/1'/0'/0'/0'"),
         {
             "timeStamp":
             74649215,
             "fee":
             2000000,
             "type":
             nem.TYPE_AGGREGATE_MODIFICATION,
             "deadline":
             74735615,
             "message": {},
             "modifications": [{
                 "modificationType":
                 1,  # Add
                 "cosignatoryAccount":
                 "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
             }],
             "minCosignatories": {
                 "relativeChange": 3
             },
             "version": (0x98 << 24),
         },
     )
     assert (
         tx.data.hex() ==
         "01100000020000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f740401000000280000000100000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f878440400000003000000"
     )
     assert (
         tx.signature.hex() ==
         "1200e552d8732ce3eae96719731194abfc5a09d98f61bb35684f4eeaeff15b1bdf326ee7b1bbbe89d3f68c8e07ad3daf72e4c7f031094ad2236b97918ad98601"
     )
    def test_nem_signtx_provision_namespace(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_PROVISION_NAMESPACE,
                "deadline": 74735615,
                "message": {},
                "newPart": "ABCDE",
                "rentalFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "rentalFee": 1500,
                "parent": None,
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex()
            == "01200000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000050000004142434445ffffffff"
        )
        assert (
            tx.signature.hex()
            == "f047ae7987cd3a60c0d5ad123aba211185cb6266a7469dfb0491a0df6b5cd9c92b2e2b9f396cc2a3146ee185ba02df4f9e7fb238fe479917b3d274d97336640d"
        )
Пример #17
0
    def test_nem_signtx_importance_transfer(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 12349215,
                    "fee": 9900,
                    "type": nem.TYPE_IMPORTANCE_TRANSFER,
                    "deadline": 99,
                    "message": {},
                    "importanceTransfer": {
                        "mode":
                        1,  # activate
                        "publicKey":
                        "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                tx.data.hex() ==
                "01080000010000981f6fbc0020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084ac26000000000000630000000100000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844"
            )
            assert (
                tx.signature.hex() ==
                "b6d9434ec5df80e65e6e45d7f0f3c579b4adfe8567c42d981b06e8ac368b1aad2b24eebecd5efd41f4497051fca8ea8a5e77636a79afc46ee1a8e0fe9e3ba90b"
            )
    def test_nem_signtx_importance_transfer(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 12349215,
                    "fee": 9900,
                    "type": nem.TYPE_IMPORTANCE_TRANSFER,
                    "deadline": 99,
                    "message": {},
                    "importanceTransfer": {
                        "mode": 1,  # activate
                        "publicKey": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                tx.data.hex()
                == "01080000010000981f6fbc0020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084ac26000000000000630000000100000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844"
            )
            assert (
                tx.signature.hex()
                == "b6d9434ec5df80e65e6e45d7f0f3c579b4adfe8567c42d981b06e8ac368b1aad2b24eebecd5efd41f4497051fca8ea8a5e77636a79afc46ee1a8e0fe9e3ba90b"
            )
Пример #19
0
    def test_nem_signtx_provision_namespace(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_PROVISION_NAMESPACE,
                "deadline": 74735615,
                "message": {},
                "newPart": "ABCDE",
                "rentalFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "rentalFee": 1500,
                "parent": None,
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "01200000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000050000004142434445ffffffff"
        )
        assert (
            tx.signature.hex() ==
            "f047ae7987cd3a60c0d5ad123aba211185cb6266a7469dfb0491a0df6b5cd9c92b2e2b9f396cc2a3146ee185ba02df4f9e7fb238fe479917b3d274d97336640d"
        )
    def test_nem_signtx_mosaic_creation(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_CREATION,
                "deadline": 74735615,
                "message": {},
                "mosaicDefinition": {
                    "id": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "levy": {},
                    "properties": {},
                    "description": "lorem",
                },
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex()
            == "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f7404c100000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000030160000000d000000696e697469616c537570706c7901000000301a0000000d000000737570706c794d757461626c650500000066616c7365190000000c0000007472616e7366657261626c650500000066616c7365000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
        )
        assert (
            tx.signature.hex()
            == "537adf4fd9bd5b46e204b2db0a435257a951ed26008305e0aa9e1201dafa4c306d7601a8dbacabf36b5137724386124958d53202015ab31fb3d0849dfed2df0e"
        )
Пример #21
0
def test_nem_signtx_mosaic_creation_properties(client):
    tx = nem.sign_tx(
        client,
        ADDRESS_N,
        {
            "timeStamp": 74649215,
            "fee": 2000000,
            "type": nem.TYPE_MOSAIC_CREATION,
            "deadline": 74735615,
            "message": {},
            "mosaicDefinition": {
                "id": {"namespaceId": "hellom", "name": "Hello mosaic"},
                "levy": {},
                "properties": [
                    {"name": "divisibility", "value": "4"},
                    {"name": "initialSupply", "value": "200"},
                    {"name": "supplyMutable", "value": "false"},
                    {"name": "transferable", "value": "true"},
                ],
                "description": "lorem",
            },
            "version": (0x98 << 24),
            "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
            "creationFee": 1500,
        },
    )

    assert (
        tx.data.hex()
        == "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f7404c200000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000034180000000d000000696e697469616c537570706c79030000003230301a0000000d000000737570706c794d757461626c650500000066616c7365180000000c0000007472616e7366657261626c650400000074727565000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
    )
    assert (
        tx.signature.hex()
        == "f17c859710060f2ea9a0ab740ef427431cf36bdc7d263570ca282bd66032e9f5737a921be9839429732e663be2bb74ccc16f34f5157ff2ef00a65796b54e800e"
    )
    def test_nem_signtx_known_mosaic_with_levy(self):

        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "dim", "name": "coin"},
                        "quantity": 222000,
                    }
                ],
            },
        )

        # trezor should display 0 XEM and 0.444 DIM and levy of 0.000444 DIM
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c5480841e000000000000000000010000001b0000000f0000000300000064696d04000000636f696e3063030000000000"
        )
        assert (
            tx.signature.hex()
            == "d3222dd7b83d66bda0539827ac6f909d06e40350b5e5e893d6fa762f954e9bf7da61022ef04950e7b6dfa88a2278f2f8a1b21df2bc3af22b388cb3a90bf76f07"
        )
    def test_nem_signtx_multiple_mosaics(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 3000000,
                    },
                    {
                        "mosaicId": {"namespaceId": "abc", "name": "mosaic"},
                        "quantity": 200,
                    },
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 30000,
                    },
                    {
                        "mosaicId": {"namespaceId": "abc", "name": "mosaic"},
                        "quantity": 2000000,
                    },
                    {
                        "mosaicId": {"namespaceId": "breeze", "name": "breeze-token"},
                        "quantity": 111000,
                    },
                ],
            },
        )

        # trezor should display warning, 6.06 XEM, 4000400 raw units of abc.mosaic (mosaics are merged)
        # and 222000 BREEZE
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c5480841e000000000000000000030000001d0000001100000003000000616263060000006d6f7361696348851e0000000000260000001a00000006000000627265657a650c000000627265657a652d746f6b656e98b10100000000001a0000000e000000030000006e656d0300000078656df03b2e0000000000"
        )
        assert (
            tx.signature.hex()
            == "b2b9319fca87a05bee17108edd9a8f78aeffef74bf6b4badc6da5d46e8ff4fe82e24bf69d8e6c4097d072adf39d0c753e7580f8afb21e3288ebfb7c4d84e470d"
        )
    def test_nem_signtx_multiple_mosaics(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 76809215,
                "amount": 2000000,
                "fee": 1000000,
                "recipient": "NDMYSLXI4L3FYUQWO4MJOVL6BSTJJXKDSZRMT4LT",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 76895615,
                "version": (0x68 << 24),
                "message": {},
                "mosaics": [
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 3000000,
                    },
                    {
                        "mosaicId": {"namespaceId": "abc", "name": "mosaic"},
                        "quantity": 200,
                    },
                    {
                        "mosaicId": {"namespaceId": "nem", "name": "xem"},
                        "quantity": 30000,
                    },
                    {
                        "mosaicId": {"namespaceId": "abc", "name": "mosaic"},
                        "quantity": 2000000,
                    },
                    {
                        "mosaicId": {"namespaceId": "breeze", "name": "breeze-token"},
                        "quantity": 111000,
                    },
                ],
            },
        )

        # trezor should display warning, 6.06 XEM, 4000400 raw units of abc.mosaic (mosaics are merged)
        # and 222000 BREEZE
        assert (
            tx.data.hex()
            == "0101000002000068ff03940420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208440420f00000000007f559504280000004e444d59534c5849344c3346595551574f344d4a4f564c364253544a4a584b44535a524d54344c5480841e000000000000000000030000001d0000001100000003000000616263060000006d6f7361696348851e0000000000260000001a00000006000000627265657a650c000000627265657a652d746f6b656e98b10100000000001a0000000e000000030000006e656d0300000078656df03b2e0000000000"
        )
        assert (
            tx.signature.hex()
            == "b2b9319fca87a05bee17108edd9a8f78aeffef74bf6b4badc6da5d46e8ff4fe82e24bf69d8e6c4097d072adf39d0c753e7580f8afb21e3288ebfb7c4d84e470d"
        )
Пример #25
0
    def test_nem_signtx_encrypted_payload(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            self.client.set_expected_responses([
                # Confirm transfer and network fee
                proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput
                                    ),
                # Ask for encryption
                proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput
                                    ),
                # Confirm recipient
                proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                proto.NEMSignedTx(),
            ])

            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 74649215,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 74735615,
                    "message": {
                        # plain text is 32B long => cipher text is 48B
                        # as per PKCS#7 another block containing padding is added
                        "payload":
                        hexlify(b"this message should be encrypted"),
                        "publicKey":
                        "5a5e14c633d7d269302849d739d80344ff14db51d7bcda86045723f05c4e4541",
                        "type": 2,
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                hexlify(tx.data[:124]) ==
                b"01010000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e0000000000680000000200000060000000"
            )
            # after 124th byte comes iv (16B) salt (32B) and encrypted payload (48B)
            assert len(tx.data[124:]) == 16 + 32 + 48
            # because IV and salt are random (therefore the encrypted payload as well) those data can't be asserted
            assert len(tx.signature) == 64
    def test_nem_signtx_encrypted_payload(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            self.client.set_expected_responses(
                [
                    # Confirm transfer and network fee
                    proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
                    # Ask for encryption
                    proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
                    # Confirm recipient
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.NEMSignedTx(),
                ]
            )

            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 74649215,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 74735615,
                    "message": {
                        # plain text is 32B long => cipher text is 48B
                        # as per PKCS#7 another block containing padding is added
                        "payload": b"this message should be encrypted".hex(),
                        "publicKey": "5a5e14c633d7d269302849d739d80344ff14db51d7bcda86045723f05c4e4541",
                        "type": 2,
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                tx.data[:124].hex()
                == "01010000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e0000000000680000000200000060000000"
            )
            # after 124th byte comes iv (16B) salt (32B) and encrypted payload (48B)
            assert len(tx.data[124:]) == 16 + 32 + 48
            # because IV and salt are random (therefore the encrypted payload as well) those data can't be asserted
            assert len(tx.signature) == 64
Пример #27
0
    def test_nem_signtx_simple(self):
        # tx hash: 209368053ac61969b6838ceb7e31badeb622ed6aa42d6c58365c42ad1a11e19d
        signature = unhexlify(
            "9cda2045324d05c791a4fc312ecceb62954e7740482f8df8928560d63cf273dea595023640179f112de755c79717757ef76962175378d6d87360ddb3f3e5f70f"
        )

        self.setup_mnemonic_nopin_nopassphrase()
        with self.client:
            self.client.set_expected_responses([
                # Confirm transfer and network fee
                proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput
                                    ),
                # Unencrypted message
                proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput
                                    ),
                # Confirm recipient
                proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                proto.NEMSignedTx(),
            ])

            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 74649215,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 74735615,
                    "message": {
                        "payload": hexlify(b"test_nem_transaction_transfer"),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                hexlify(tx.data) ==
                b"01010000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572"
            )
            assert tx.signature == signature
    def test_nem_signtx_mosaic_creation_levy(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_CREATION,
                "deadline": 74735615,
                "message": {},
                "mosaicDefinition": {
                    "id": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "properties": [
                        {"name": "divisibility", "value": "4"},
                        {"name": "initialSupply", "value": "200"},
                        {"name": "supplyMutable", "value": "false"},
                        {"name": "transferable", "value": "true"},
                    ],
                    "levy": {
                        "type": 1,
                        "fee": 2,
                        "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                        "mosaicId": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    },
                    "description": "lorem",
                },
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex()
            == "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74041801000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000034180000000d000000696e697469616c537570706c79030000003230301a0000000d000000737570706c794d757461626c650500000066616c7365180000000c0000007472616e7366657261626c65040000007472756556000000010000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a1a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f7361696302000000000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
        )
        assert (
            tx.signature.hex()
            == "b87aac1ddf146d35e6a7f3451f57e2fe504ac559031e010a51261257c37bd50fcfa7b2939dd7a3203b54c4807d458475182f5d3dc135ec0d1d4a9cd42159fd0a"
        )
    def test_nem_signtx_simple(self):
        # tx hash: 209368053ac61969b6838ceb7e31badeb622ed6aa42d6c58365c42ad1a11e19d
        self.setup_mnemonic_nopin_nopassphrase()
        with self.client:
            self.client.set_expected_responses(
                [
                    # Confirm transfer and network fee
                    proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
                    # Unencrypted message
                    proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
                    # Confirm recipient
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.NEMSignedTx(),
                ]
            )

            tx = nem.sign_tx(
                self.client,
                parse_path("m/44'/1'/0'/0'/0'"),
                {
                    "timeStamp": 74649215,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 74735615,
                    "message": {
                        "payload": b"test_nem_transaction_transfer".hex(),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                },
            )

            assert (
                tx.data.hex()
                == "01010000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572"
            )
            assert (
                tx.signature.hex()
                == "9cda2045324d05c791a4fc312ecceb62954e7740482f8df8928560d63cf273dea595023640179f112de755c79717757ef76962175378d6d87360ddb3f3e5f70f"
            )
def test_nem_signtx_simple(client):
    with client:
        client.set_expected_responses([
            # Confirm transfer and network fee
            messages.ButtonRequest(
                code=messages.ButtonRequestType.ConfirmOutput),
            # Unencrypted message
            messages.ButtonRequest(
                code=messages.ButtonRequestType.ConfirmOutput),
            # Confirm recipient
            messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
            messages.NEMSignedTx,
        ])

        tx = nem.sign_tx(
            client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "amount": 2000000,
                "fee": 2000000,
                "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "type": nem.TYPE_TRANSACTION_TRANSFER,
                "deadline": 74735615,
                "message": {
                    "payload": b"test_nem_transaction_transfer".hex(),
                    "type": 1,
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "01010000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f74042800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572"
        )
        assert (
            tx.signature.hex() ==
            "9cda2045324d05c791a4fc312ecceb62954e7740482f8df8928560d63cf273dea595023640179f112de755c79717757ef76962175378d6d87360ddb3f3e5f70f"
        )
    def test_nem_signtx_mosaic_creation_properties(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 2000000,
                "type": nem.TYPE_MOSAIC_CREATION,
                "deadline": 74735615,
                "message": {},
                "mosaicDefinition": {
                    "id": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "levy": {},
                    "properties": [
                        {"name": "divisibility", "value": "4"},
                        {"name": "initialSupply", "value": "200"},
                        {"name": "supplyMutable", "value": "false"},
                        {"name": "transferable", "value": "true"},
                    ],
                    "description": "lorem",
                },
                "version": (0x98 << 24),
                "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                "creationFee": 1500,
            },
        )

        assert (
            tx.data.hex()
            == "01400000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b406208480841e0000000000ff5f7404c200000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841a0000000600000068656c6c6f6d0c00000048656c6c6f206d6f73616963050000006c6f72656d04000000150000000c00000064697669736962696c6974790100000034180000000d000000696e697469616c537570706c79030000003230301a0000000d000000737570706c794d757461626c650500000066616c7365180000000c0000007472616e7366657261626c650400000074727565000000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000"
        )
        assert (
            tx.signature.hex()
            == "f17c859710060f2ea9a0ab740ef427431cf36bdc7d263570ca282bd66032e9f5737a921be9839429732e663be2bb74ccc16f34f5157ff2ef00a65796b54e800e"
        )
    def _nem_sign(self, num_of_swipes, test_suite):
        n = parse_path("m/44'/1'/0'/0'/0'")

        def input_flow():
            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            self.client.debug.press_yes()

            # Swipe and confirm
            time.sleep(1)
            for i in range(num_of_swipes):
                self.client.debug.swipe_down()
                time.sleep(1)
            self.client.debug.press_yes()

            # Confirm Action
            btn_code = yield
            assert btn_code == B.ConfirmOutput
            self.client.debug.press_yes()

            # Sign Tx
            btn_code = yield
            assert btn_code == B.SignTx
            self.client.debug.press_yes()

        with self.client:
            self.client.set_expected_responses(
                [
                    proto.ButtonRequest(code=B.ConfirmOutput),
                    proto.ButtonRequest(code=B.ConfirmOutput),
                    proto.ButtonRequest(code=B.SignTx),
                    proto.NEMSignedTx(),
                ]
            )
            self.client.set_input_flow(input_flow)
            return nem.sign_tx(self.client, n, test_suite)
    def test_nem_signtx_multisig(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 1,
                "fee": 10000,
                "type": nem.TYPE_MULTISIG,
                "deadline": 74735615,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 2,
                    "amount": 2000000,
                    "fee": 15000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 67890,
                    "message": {
                        "payload": b"test_nem_transaction_transfer".hex(),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "04100000010000980100000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841027000000000000ff5f74049900000001010000010000980200000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844983a000000000000320901002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572"
        )
        assert (
            tx.signature.hex() ==
            "0cab2fddf2f02b5d7201675b9a71869292fe25ed33a366c7d2cbea7676fed491faaa03310079b7e17884b6ba2e3ea21c4f728d1cca8f190b8288207f6514820a"
        )

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 150,
                "type": nem.TYPE_MULTISIG,
                "deadline": 789,
                "otherTrans": {
                    "timeStamp":
                    123456,
                    "fee":
                    2000,
                    "type":
                    nem.TYPE_PROVISION_NAMESPACE,
                    "deadline":
                    100,
                    "message": {},
                    "newPart":
                    "ABCDE",
                    "rentalFeeSink":
                    "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "rentalFee":
                    1500,
                    "parent":
                    None,
                    "version": (0x98 << 24),
                    "signer":
                    "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "04100000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620849600000000000000150300007d000000012000000100009840e2010020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844d007000000000000640000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000050000004142434445ffffffff"
        )
        assert (
            tx.signature.hex() ==
            "c915ca3332380925f4050301cdc62269cf29437ac5955321b18da34e570c7fdbb1aec2940a2a553a2a5c90950a4db3c8d3ef899c1a108582e0657f66fbbb0b04"
        )
    def test_nem_signtx_multisig_signer(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 333,
                "fee": 200,
                "type": nem.TYPE_MULTISIG_SIGNATURE,
                "deadline": 444,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 555,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 666,
                    "message": {
                        "payload": b"test_nem_transaction_transfer".hex(),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "02100000010000984d01000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084c800000000000000bc010000240000002000000087923cd4805f3babe6b5af9cbb2b08be4458e39531618aed73c911f160c8e38528000000544444324354364c514c49595135364b49584933454e544d36454b3344343450354b5a50464d4b32"
        )
        assert (
            tx.signature.hex() ==
            "286358a16ae545bff798feab93a713440c7c2f236d52ac0e995669d17a1915b0903667c97fa04418eccb42333cba95b19bccc8ac1faa8224dcfaeb41890ae807"
        )

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 900000,
                "fee": 200000,
                "type": nem.TYPE_MULTISIG_SIGNATURE,
                "deadline": 100,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 101111,
                    "fee": 1000,
                    "type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
                    "deadline": 13123,
                    "message": {},
                    "mosaicId": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "supplyType": 1,
                    "delta": 1,
                    "version": (0x98 << 24),
                    "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "creationFee": 1500,
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex() ==
            "0210000001000098a0bb0d0020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084400d030000000000640000002400000020000000c51395626a89a71c1ed785fb5974307a049b3b9e2165d56ed0302fe6b4f02a0128000000544444324354364c514c49595135364b49584933454e544d36454b3344343450354b5a50464d4b32"
        )
        assert (
            tx.signature.hex() ==
            "32b1fdf788c4a90c01eedf5972b7709745831d620c13e1e97b0de6481837e162ee551573f2409822754ae940731909ec4b79cf836487e898df476adb10467506"
        )
    def test_nem_signtx_multisig_signer(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 333,
                "fee": 200,
                "type": nem.TYPE_MULTISIG_SIGNATURE,
                "deadline": 444,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 555,
                    "amount": 2000000,
                    "fee": 2000000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 666,
                    "message": {
                        "payload": b"test_nem_transaction_transfer".hex(),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex()
            == "02100000010000984d01000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084c800000000000000bc010000240000002000000087923cd4805f3babe6b5af9cbb2b08be4458e39531618aed73c911f160c8e38528000000544444324354364c514c49595135364b49584933454e544d36454b3344343450354b5a50464d4b32"
        )
        assert (
            tx.signature.hex()
            == "286358a16ae545bff798feab93a713440c7c2f236d52ac0e995669d17a1915b0903667c97fa04418eccb42333cba95b19bccc8ac1faa8224dcfaeb41890ae807"
        )

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 900000,
                "fee": 200000,
                "type": nem.TYPE_MULTISIG_SIGNATURE,
                "deadline": 100,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 101111,
                    "fee": 1000,
                    "type": nem.TYPE_MOSAIC_SUPPLY_CHANGE,
                    "deadline": 13123,
                    "message": {},
                    "mosaicId": {"namespaceId": "hellom", "name": "Hello mosaic"},
                    "supplyType": 1,
                    "delta": 1,
                    "version": (0x98 << 24),
                    "creationFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "creationFee": 1500,
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex()
            == "0210000001000098a0bb0d0020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b4062084400d030000000000640000002400000020000000c51395626a89a71c1ed785fb5974307a049b3b9e2165d56ed0302fe6b4f02a0128000000544444324354364c514c49595135364b49584933454e544d36454b3344343450354b5a50464d4b32"
        )
        assert (
            tx.signature.hex()
            == "32b1fdf788c4a90c01eedf5972b7709745831d620c13e1e97b0de6481837e162ee551573f2409822754ae940731909ec4b79cf836487e898df476adb10467506"
        )
    def test_nem_signtx_multisig(self):
        self.setup_mnemonic_nopin_nopassphrase()

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 1,
                "fee": 10000,
                "type": nem.TYPE_MULTISIG,
                "deadline": 74735615,
                "otherTrans": {  # simple transaction transfer
                    "timeStamp": 2,
                    "amount": 2000000,
                    "fee": 15000,
                    "recipient": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "type": nem.TYPE_TRANSACTION_TRANSFER,
                    "deadline": 67890,
                    "message": {
                        "payload": b"test_nem_transaction_transfer".hex(),
                        "type": 1,
                    },
                    "version": (0x98 << 24),
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex()
            == "04100000010000980100000020000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620841027000000000000ff5f74049900000001010000010000980200000020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844983a000000000000320901002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324a80841e000000000025000000010000001d000000746573745f6e656d5f7472616e73616374696f6e5f7472616e73666572"
        )
        assert (
            tx.signature.hex()
            == "0cab2fddf2f02b5d7201675b9a71869292fe25ed33a366c7d2cbea7676fed491faaa03310079b7e17884b6ba2e3ea21c4f728d1cca8f190b8288207f6514820a"
        )

        tx = nem.sign_tx(
            self.client,
            parse_path("m/44'/1'/0'/0'/0'"),
            {
                "timeStamp": 74649215,
                "fee": 150,
                "type": nem.TYPE_MULTISIG,
                "deadline": 789,
                "otherTrans": {
                    "timeStamp": 123456,
                    "fee": 2000,
                    "type": nem.TYPE_PROVISION_NAMESPACE,
                    "deadline": 100,
                    "message": {},
                    "newPart": "ABCDE",
                    "rentalFeeSink": "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
                    "rentalFee": 1500,
                    "parent": None,
                    "version": (0x98 << 24),
                    "signer": "c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844",
                },
                "version": (0x98 << 24),
            },
        )

        assert (
            tx.data.hex()
            == "04100000010000987f0e730420000000edfd32f6e760648c032f9acb4b30d514265f6a5b5f8a7154f2618922b40620849600000000000000150300007d000000012000000100009840e2010020000000c5f54ba980fcbb657dbaaa42700539b207873e134d2375efeab5f1ab52f87844d007000000000000640000002800000054414c49434532474d4133344358484437584c4a513533364e4d35554e4b5148544f524e4e54324adc05000000000000050000004142434445ffffffff"
        )
        assert (
            tx.signature.hex()
            == "c915ca3332380925f4050301cdc62269cf29437ac5955321b18da34e570c7fdbb1aec2940a2a553a2a5c90950a4db3c8d3ef899c1a108582e0657f66fbbb0b04"
        )