当前位置: 首页>>代码示例>>Python>>正文


Python tools.parse_path函数代码示例

本文整理汇总了Python中trezorlib.tools.parse_path函数的典型用法代码示例。如果您正苦于以下问题:Python parse_path函数的具体用法?Python parse_path怎么用?Python parse_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_timestamp_included

def test_timestamp_included(client):
    # tx: 3bf506c81ce84eda891679ddc797d162c17c60b15d6c0ac23be5e31369e7235f
    # input 0: 0.01 CPC
    # tx: f3a6e6411f1b2dffd76d2729bae8e056f8f9ecf8996d3f428e75a6f23f2c5e8c
    # input 0: 0.02 CPC

    inp1 = messages.TxInputType(
        address_n=parse_path("m/44'/289'/0'/0/0"), prev_hash=TXHASH_3bf506, prev_index=0
    )

    inp2 = messages.TxInputType(
        address_n=parse_path("m/44'/289'/0'/0/0"), prev_hash=TXHASH_f3a6e6, prev_index=1
    )

    out1 = messages.TxOutputType(
        address="CUGi8RGPWxbHM6FxF4eMEfqmQ6Bs5VjCdr",
        amount=3000000 - 20000,
        script_type=messages.OutputScriptType.PAYTOADDRESS,
    )

    with client:
        details = messages.SignTx(version=1, timestamp=0x5BCF5C66)
        _, timestamp_tx = btc.sign_tx(
            client,
            "Capricoin",
            [inp1, inp2],
            [out1],
            details=details,
            prev_txes=tx_cache("Capricoin"),
        )

    # Accepted by network https://insight.capricoin.org/tx/1bf227e6e24fe1f8ac98849fe06a2c5b77762e906fcf7e82787675f7f3a10bb8
    accepted_txhex = "01000000665ccf5b025f23e76913e3e53bc20a6c5db1607cc162d197c7dd791689da4ee81cc806f53b000000006b483045022100fce7ccbeb9524f36d118ebcfebcb133a05c236c4478e2051cfd5c9632920aee602206921b7be1a81f30cce3d8e7dba4597fc16a2761c42321c49d65eeacdfe3781250121021fcf98aee04939ec7df5762f426dc2d1db8026e3a73c3bbe44749dacfbb61230ffffffff8c5e2c3ff2a6758e423f6d99f8ecf9f856e0e8ba29276dd7ff2d1b1f41e6a6f3010000006a473044022015d967166fe9f89fbed8747328b1c4658aa1d7163e731c5fd5908feafe08e9a6022028af30801098418bd298cc60b143c52c48466f5791256721304b6eba4fdf0b3c0121021fcf98aee04939ec7df5762f426dc2d1db8026e3a73c3bbe44749dacfbb61230ffffffff01a0782d00000000001976a914818437acfd15780debd31f3fd21d4ca678bb36d188ac00000000"
    assert timestamp_tx.hex() == accepted_txhex
开发者ID:trezor,项目名称:python-trezor,代码行数:34,代码来源:test_msg_signtx_capricoin.py

示例2: test_change_on_main_chain_allowed

    def test_change_on_main_chain_allowed(self):
        self.setup_mnemonic_allallall()
        # see 87be0736f202f7c2bff0781b42bad3e0cdcb54761939da69ea793a3735552c56

        # tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
        # input 0: 0.31 BTC
        inp1 = proto.TxInputType(
            address_n=parse_path("44'/1'/0'/0/0"),
            # amount=31000000,
            prev_hash=TXHASH_e5040e,
            prev_index=0,
        )

        out1 = proto.TxOutputType(
            address="msj42CCGruhRsFrGATiUuh25dtxYtnpbTx",
            amount=30090000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        # change on main chain is allowed => treated as a change
        out_change = proto.TxOutputType(
            address_n=parse_path("44'/1'/0'/0/0"),
            amount=900000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        check_sign_tx(self.client, "Testnet", [inp1], [out1, out_change])
开发者ID:trezor,项目名称:python-trezor,代码行数:27,代码来源:test_msg_signtx.py

示例3: test_bch_multisig

    def test_bch_multisig(self):
        self.setup_mnemonic_allallall()
        xpubs = []
        for n in range(1, 4):
            node = btc.get_public_node(self.client, parse_path("44'/145'/%d'" % n))
            xpubs.append(node.xpub)

        for nr in range(1, 4):
            assert (
                btc.get_address(
                    self.client,
                    "Bcash",
                    parse_path("44'/145'/%d'/0/0" % nr),
                    show_display=(nr == 1),
                    multisig=getmultisig(0, 0, xpubs=xpubs),
                )
                == "bitcoincash:pqguz4nqq64jhr5v3kvpq4dsjrkda75hwy86gq0qzw"
            )
            assert (
                btc.get_address(
                    self.client,
                    "Bcash",
                    parse_path("44'/145'/%d'/1/0" % nr),
                    show_display=(nr == 1),
                    multisig=getmultisig(1, 0, xpubs=xpubs),
                )
                == "bitcoincash:pp6kcpkhua7789g2vyj0qfkcux3yvje7euhyhltn0a"
            )
开发者ID:trezor,项目名称:python-trezor,代码行数:28,代码来源:test_msg_getaddress.py

示例4: test_show_multisig_3

 def test_show_multisig_3(self):
     self.setup_mnemonic_allallall()
     nodes = map(
         lambda index: btc.get_public_node(
             self.client, parse_path("999'/1'/%d'" % index)
         ),
         range(1, 4),
     )
     multisig1 = proto.MultisigRedeemScriptType(
         nodes=[bip32.deserialize(n.xpub) for n in nodes],
         address_n=[2, 0],
         signatures=[b"", b"", b""],
         m=2,
     )
     # multisig2 = proto.MultisigRedeemScriptType(
     #     pubkeys=map(lambda n: proto.HDNodePathType(node=bip32.deserialize(n.xpub), address_n=[2, 1]), nodes),
     #     signatures=[b'', b'', b''],
     #     m=2,
     # )
     for i in [1, 2, 3]:
         assert (
             btc.get_address(
                 self.client,
                 "Testnet",
                 parse_path("999'/1'/%d'/2/0" % i),
                 False,
                 multisig1,
                 script_type=proto.InputScriptType.SPENDP2SHWITNESS,
             )
             == "2N2MxyAfifVhb3AMagisxaj3uij8bfXqf4Y"
         )
开发者ID:trezor,项目名称:python-trezor,代码行数:31,代码来源:test_msg_getaddress_segwit.py

示例5: test_monero_getwatchkey

 def test_monero_getwatchkey(self):
     self.setup_mnemonic_nopin_nopassphrase()
     res = monero.get_watch_key(self.client, parse_path("m/44h/128h/0h"))
     assert (
         res.address
         == b"4Ahp23WfMrMFK3wYL2hLWQFGt87ZTeRkufS6JoQZu6MEFDokAQeGWmu9MA3GFq1yVLSJQbKJqVAn9F9DLYGpRzRAEXqAXKM"
     )
     assert (
         res.watch_key.hex()
         == "8722520a581e2a50cc1adab4a1692401effd37b0d63b9d9b60fd7f34ea2b950e"
     )
     res = monero.get_watch_key(self.client, parse_path("m/44h/128h/1h"))
     assert (
         res.address
         == b"44iAazhoAkv5a5RqLNVyh82a1n3ceNggmN4Ho7bUBJ14WkEVR8uFTe9f7v5rNnJ2kEbVXxfXiRzsD5Jtc6NvBi4D6WNHPie"
     )
     assert (
         res.watch_key.hex()
         == "1f70b7d9e86c11b7a5bee883b75c43d6be189c8f812726ea1ecd94b06bb7db04"
     )
     res = monero.get_watch_key(self.client, parse_path("m/44h/128h/2h"))
     assert (
         res.address
         == b"47ejhmbZ4wHUhXaqA4b7PN667oPMkokf4ZkNdWrMSPy9TNaLVr7vLqVUQHh2MnmaAEiyrvLsX8xUf99q3j1iAeMV8YvSFcH"
     )
     assert (
         res.watch_key.hex()
         == "e0671fbed2c9231fe4f286962862813a4a4d153c793bf5d0e3742119723f3000"
     )
开发者ID:trezor,项目名称:python-trezor,代码行数:29,代码来源:test_msg_monero_getwatchkey.py

示例6: test_one_two_fee

    def test_one_two_fee(self):
        self.setup_mnemonic_allallall()

        # tx: c275c333fd1b36bef4af316226c66a8b3693fbfcc081a5e16a2ae5fcb09e92bf

        inp1 = proto.TxInputType(
            address_n=parse_path(
                "m/44'/0'/0'/0/5"
            ),  # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
            # amount=50000,
            prev_hash=TXHASH_50f6f1,
            prev_index=1,
        )

        out1 = proto.TxOutputType(
            address_n=parse_path(
                "m/44'/0'/0'/1/3"
            ),  # 1EcL6AyfQTyWKGvXwNSfsWoYnD3whzVFdu
            amount=30000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        out2 = proto.TxOutputType(
            address="1Up15Msx4sbvUCGm8Xgo2Zp5FQim3wE59",
            amount=10000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        _, serialized_tx = check_sign_tx(self.client, "Bitcoin", [inp1], [out1, out2])

        assert (
            serialized_tx.hex()
            == "01000000016d20f69067ad1ffd50ee7c0f377dde2c932ccb03e84b5659732da99c20f1f650010000006a47304402203429bd3ce7b38c5c1e8a15340edd79ced41a2939aae62e259d2e3d18e0c5ee7602201b83b10ebc4d6dcee3f9eb42ba8f1ef8a059a05397e0c1b9223d1565a3e6ec01012102a7a079c1ef9916b289c2ff21a992c808d0de3dfcf8a9f163205c5c9e21f55d5cffffffff0230750000000000001976a914954820f1de627a703596ac0396f986d958e3de4c88ac10270000000000001976a91405427736705cfbfaff76b1cff48283707fb1037088ac00000000"
        )
开发者ID:trezor,项目名称:python-trezor,代码行数:34,代码来源:test_msg_signtx.py

示例7: test_testnet_one_two_fee

    def test_testnet_one_two_fee(self):
        self.setup_mnemonic_allallall()
        # see 87be0736f202f7c2bff0781b42bad3e0cdcb54761939da69ea793a3735552c56

        # tx: e5040e1bc1ae7667ffb9e5248e90b2fb93cd9150234151ce90e14ab2f5933bcd
        # input 0: 0.31 BTC
        inp1 = proto.TxInputType(
            address_n=parse_path("44'/1'/0'/0/0"),
            # amount=31000000,
            prev_hash=TXHASH_e5040e,
            prev_index=0,
        )

        out1 = proto.TxOutputType(
            address="msj42CCGruhRsFrGATiUuh25dtxYtnpbTx",
            amount=30090000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        out2 = proto.TxOutputType(
            address_n=parse_path("44'/1'/0'/1/0"),
            amount=900000,
            script_type=proto.OutputScriptType.PAYTOADDRESS,
        )

        _, serialized_tx = check_sign_tx(self.client, "Testnet", [inp1], [out1, out2])

        assert (
            serialized_tx.hex()
            == "0100000001cd3b93f5b24ae190ce5141235091cd93fbb2908e24e5b9ff6776aec11b0e04e5000000006b483045022100eba3bbcbb82ab1ebac88a394e8fb53b0263dadbb3e8072f0a21ee62818c911060220686a9b7f306d028b54a228b5c47cc6c27b1d01a3b0770440bcc64d55d8bace2c0121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0ffffffff021023cb01000000001976a91485eb47fe98f349065d6f044e27a4ac541af79ee288aca0bb0d00000000001976a9143d3cca567e00a04819742b21a696a67da796498b88ac00000000"
        )
开发者ID:trezor,项目名称:python-trezor,代码行数:31,代码来源:test_msg_signtx.py

示例8: test_multisig

    def test_multisig(self):
        self.setup_mnemonic_allallall()
        xpubs = []
        for n in range(1, 4):
            node = btc.get_public_node(self.client, parse_path("44'/0'/%d'" % n))
            xpubs.append(node.xpub)

        for nr in range(1, 4):
            assert (
                btc.get_address(
                    self.client,
                    "Bitcoin",
                    parse_path("44'/0'/%d'/0/0" % nr),
                    show_display=(nr == 1),
                    multisig=getmultisig(0, 0, xpubs=xpubs),
                )
                == "3Pdz86KtfJBuHLcSv4DysJo4aQfanTqCzG"
            )
            assert (
                btc.get_address(
                    self.client,
                    "Bitcoin",
                    parse_path("44'/0'/%d'/1/0" % nr),
                    show_display=(nr == 1),
                    multisig=getmultisig(1, 0, xpubs=xpubs),
                )
                == "36gP3KVx1ooStZ9quZDXbAF3GCr42b2zzd"
            )
开发者ID:trezor,项目名称:python-trezor,代码行数:28,代码来源:test_msg_getaddress.py

示例9: test_multisig_missing

 def test_multisig_missing(self):
     self.setup_mnemonic_allallall()
     xpubs = []
     for n in range(1, 4):
         # shift account numbers by 10 to create valid multisig,
         # but not containing the keys used below
         n = n + 10
         node = btc.get_public_node(self.client, parse_path("44'/0'/%d'" % n))
         xpubs.append(node.xpub)
     for nr in range(1, 4):
         with pytest.raises(CallException):
             btc.get_address(
                 self.client,
                 "Bitcoin",
                 parse_path("44'/0'/%d'/0/0" % nr),
                 show_display=(nr == 1),
                 multisig=getmultisig(0, 0, xpubs=xpubs),
             )
         with pytest.raises(CallException):
             btc.get_address(
                 self.client,
                 "Bitcoin",
                 parse_path("44'/0'/%d'/1/0" % nr),
                 show_display=(nr == 1),
                 multisig=getmultisig(1, 0, xpubs=xpubs),
             )
开发者ID:trezor,项目名称:python-trezor,代码行数:26,代码来源:test_msg_getaddress.py

示例10: test_ethereum_signtx_nodata

    def test_ethereum_signtx_nodata(self):
        self.setup_mnemonic_nopin_nopassphrase()

        with self.client:
            self.client.set_expected_responses(
                [
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.EthereumTxRequest(data_length=None),  # v,r,s checked later
                ]
            )

            sig_v, sig_r, sig_s = ethereum.sign_tx(
                self.client,
                n=parse_path("44'/60'/0'/0/100"),
                nonce=0,
                gas_price=20,
                gas_limit=20,
                to=TO_ADDR,
                value=10,
            )

        assert sig_v == 27
        assert (
            sig_r.hex()
            == "2f548f63ddb4cf19b6b9f922da58ff71833b967d590f3b4dcc2a70810338a982"
        )
        assert (
            sig_s.hex()
            == "428d35f0dca963b5196b63e7aa5e0405d8bff77d6aee1202183f1f68dacb4483"
        )

        with self.client:
            self.client.set_expected_responses(
                [
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
                    proto.EthereumTxRequest(data_length=None),
                ]
            )

            sig_v, sig_r, sig_s = ethereum.sign_tx(
                self.client,
                n=parse_path("44'/60'/0'/0/100"),
                nonce=123456,
                gas_price=20000,
                gas_limit=20000,
                to=TO_ADDR,
                value=12345678901234567890,
            )
        assert sig_v == 27
        assert (
            sig_r.hex()
            == "3bf0470cd7f5ad8d82613199f73deadc55c3c9f32f91b1a21b5ef644144ebd58"
        )
        assert (
            sig_s.hex()
            == "48b3ef1b2502febdf35e9ff4df0ba1fda62f042fad639eb4852a297fc9872ebd"
        )
开发者ID:trezor,项目名称:python-trezor,代码行数:59,代码来源:test_msg_ethereum_signtx.py

示例11: test_show_segwit

 def test_show_segwit(self):
     self.setup_mnemonic_allallall()
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("49'/1'/0'/0/0"),
             True,
             None,
             script_type=proto.InputScriptType.SPENDWITNESS,
         )
         == "tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("49'/1'/0'/1/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDWITNESS,
         )
         == "tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("44'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDWITNESS,
         )
         == "tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("44'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDADDRESS,
         )
         == "mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q"
     )
     assert (
         btc.get_address(
             self.client,
             "Groestlcoin",
             parse_path("84'/17'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDWITNESS,
         )
         == "grs1qw4teyraux2s77nhjdwh9ar8rl9dt7zww8r6lne"
     )
开发者ID:trezor,项目名称:python-trezor,代码行数:57,代码来源:test_msg_getaddress_segwit_native.py

示例12: test_show_segwit

 def test_show_segwit(self):
     self.setup_mnemonic_allallall()
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("49'/1'/0'/1/0"),
             True,
             None,
             script_type=proto.InputScriptType.SPENDP2SHWITNESS,
         )
         == "2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("49'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDP2SHWITNESS,
         )
         == "2N4Q5FhU2497BryFfUgbqkAJE87aKHUhXMp"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("44'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDP2SHWITNESS,
         )
         == "2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc"
     )
     assert (
         btc.get_address(
             self.client,
             "Testnet",
             parse_path("44'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDADDRESS,
         )
         == "mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q"
     )
     assert (
         btc.get_address(
             self.client,
             "Groestlcoin Testnet",
             parse_path("49'/1'/0'/0/0"),
             False,
             None,
             script_type=proto.InputScriptType.SPENDP2SHWITNESS,
         )
         == "2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e"
     )
开发者ID:trezor,项目名称:python-trezor,代码行数:57,代码来源:test_msg_getaddress_segwit.py

示例13: test_tezos_get_address

    def test_tezos_get_address(self):
        self.setup_mnemonic_allallall()

        path = parse_path("m/44'/1729'/0'")
        address = get_address(self.client, path, show_display=True)
        assert address == "tz1Kef7BSg6fo75jk37WkKRYSnJDs69KVqt9"

        path = parse_path("m/44'/1729'/1'")
        address = get_address(self.client, path, show_display=True)
        assert address == "tz1ekQapZCX4AXxTJhJZhroDKDYLHDHegvm1"
开发者ID:trezor,项目名称:python-trezor,代码行数:10,代码来源:test_msg_tezos_getaddress.py

示例14: test_nem_getaddress

 def test_nem_getaddress(self):
     self.setup_mnemonic_nopin_nopassphrase()
     assert (
         nem.get_address(self.client, parse_path("m/44'/1'/0'/0'/0'"), 0x68)
         == "NB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQGHUBWQN"
     )
     assert (
         nem.get_address(self.client, parse_path("m/44'/1'/0'/0'/0'"), 0x98)
         == "TB3JCHVARQNGDS3UVGAJPTFE22UQFGMCQHSBNBMF"
     )
开发者ID:trezor,项目名称:python-trezor,代码行数:10,代码来源:test_msg_nem_getaddress.py

示例15: test_tezos_get_public_key

    def test_tezos_get_public_key(self):
        self.setup_mnemonic_allallall()

        path = parse_path("m/44'/1729'/0'")
        pk = get_public_key(self.client, path)
        assert pk == "edpkttLhEbVfMC3DhyVVFzdwh8ncRnEWiLD1x8TAuPU7vSJak7RtBX"

        path = parse_path("m/44'/1729'/1'")
        pk = get_public_key(self.client, path)
        assert pk == "edpkuTPqWjcApwyD3VdJhviKM5C13zGk8c4m87crgFarQboF3Mp56f"
开发者ID:trezor,项目名称:python-trezor,代码行数:10,代码来源:test_msg_tezos_getpublickey.py


注:本文中的trezorlib.tools.parse_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。