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


Python NewWallet.add_seed方法代码示例

本文整理汇总了Python中lib.wallet.NewWallet.add_seed方法的典型用法代码示例。如果您正苦于以下问题:Python NewWallet.add_seed方法的具体用法?Python NewWallet.add_seed怎么用?Python NewWallet.add_seed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.wallet.NewWallet的用法示例。


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

示例1: TestNewWallet

# 需要导入模块: from lib.wallet import NewWallet [as 别名]
# 或者: from lib.wallet.NewWallet import add_seed [as 别名]
class TestNewWallet(WalletTestCase):

    seed_text = "travel nowhere air position hill peace suffer parent beautiful rise blood power home crumble teach"
    password = "secret"

    first_account_name = "account1"

    import_private_key = "L52XzL2cMkHxqxBXRyEpnPQZGUs3uKiL3R11XbAdHigRzDozKZeW"
    import_key_address = "15mKKb2eos1hWa6tisdPwwDC1a5J1y9nma"

    def setUp(self):
        super(TestNewWallet, self).setUp()
        self.storage = WalletStorage(self.fake_config)
        self.wallet = NewWallet(self.storage)
        # This cannot be constructed by electrum at random, it should be safe
        # from eventual collisions.
        self.wallet.add_seed(self.seed_text, self.password)
        self.wallet.create_master_keys(self.password)
        self.wallet.create_main_account(self.password)

    def test_wallet_with_seed_is_not_watching_only(self):
        self.assertFalse(self.wallet.is_watching_only())

    def test_wallet_without_seed_is_watching_only(self):
        # We need a new storage , since the default storage was already seeded
        # in setUp()
        new_dir = tempfile.mkdtemp()
        config = FakeConfig(new_dir)
        storage = WalletStorage(config)
        wallet = NewWallet(storage)
        self.assertTrue(wallet.is_watching_only())
        shutil.rmtree(new_dir)  # Don't leave useless stuff in /tmp

    def test_new_wallet_is_deterministic(self):
        self.assertTrue(self.wallet.is_deterministic())

    def test_get_seed_returns_correct_seed(self):
        self.assertEqual(self.wallet.get_seed(self.password), self.seed_text)


    def test_key_import(self):
        # Wallets have no imported keys by default.
        self.assertFalse(self.wallet.has_imported_keys())

        # Importing a key works.
        self.wallet.import_key(self.import_private_key, "")
        self.assertIn(self.import_key_address, self.wallet.addresses())
        self.assertTrue(self.wallet.has_imported_keys())

        # Deleting the key works.
        self.wallet.delete_imported_key(self.import_key_address)
        self.assertFalse(self.wallet.has_imported_keys())
        self.assertNotIn(self.import_key_address, self.wallet.addresses())

    def test_update_password(self):
        new_password = "secret2"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
开发者ID:Kausheel,项目名称:electrum,代码行数:60,代码来源:test_wallet.py

示例2: TestNewWallet

# 需要导入模块: from lib.wallet import NewWallet [as 别名]
# 或者: from lib.wallet.NewWallet import add_seed [as 别名]
class TestNewWallet(WalletTestCase):

    seed_text = "travel nowhere air position hill peace suffer parent beautiful rise blood power home crumble teach"
    password = "secret"

    first_account_name = "account1"

    import_private_key = "TAroS5Knm8GZcnpPycBgzjwwDLWMyQjDrcuGPPoArgrbW7Ln22qp"
    import_key_address = "LPzGaoLUtXFkmNo3u1chDxGxDnSaBQTTxm"

    def setUp(self):
        super(TestNewWallet, self).setUp()
        self.storage = WalletStorage(self.wallet_path)
        self.wallet = NewWallet(self.storage)
        # This cannot be constructed by electrum at random, it should be safe
        # from eventual collisions.
        self.wallet.add_seed(self.seed_text, self.password)
        self.wallet.create_master_keys(self.password)
        self.wallet.create_main_account(self.password)

    def test_wallet_with_seed_is_not_watching_only(self):
        self.assertFalse(self.wallet.is_watching_only())

    def test_wallet_without_seed_is_watching_only(self):
        # We need a new storage , since the default storage was already seeded
        # in setUp()
        new_dir = tempfile.mkdtemp()
        storage = WalletStorage(os.path.join(new_dir, "somewallet"))
        wallet = NewWallet(storage)
        self.assertTrue(wallet.is_watching_only())
        shutil.rmtree(new_dir)  # Don't leave useless stuff in /tmp

    def test_new_wallet_is_deterministic(self):
        self.assertTrue(self.wallet.is_deterministic())

    def test_get_seed_returns_correct_seed(self):
        self.assertEqual(self.wallet.get_seed(self.password), self.seed_text)


    def test_key_import(self):
        # Wallets have no imported keys by default.
        self.assertFalse(self.wallet.has_imported_keys())

        # Importing a key works.
        self.wallet.import_key(self.import_private_key, "")
        self.assertIn(self.import_key_address, self.wallet.addresses())
        self.assertTrue(self.wallet.has_imported_keys())

        # Deleting the key works.
        self.wallet.delete_imported_key(self.import_key_address)
        self.assertFalse(self.wallet.has_imported_keys())
        self.assertNotIn(self.import_key_address, self.wallet.addresses())

    def test_update_password(self):
        new_password = "secret2"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
开发者ID:Geopay,项目名称:electrum-pkb,代码行数:59,代码来源:test_wallet.py

示例3: TestNewWallet

# 需要导入模块: from lib.wallet import NewWallet [as 别名]
# 或者: from lib.wallet.NewWallet import add_seed [as 别名]
class TestNewWallet(WalletTestCase):

    seed_text = "travel nowhere air position hill peace suffer parent beautiful rise blood power home crumble teach"
    password = "secret"

    first_account_name = "account1"

    import_private_key = "QRwLhKqSLtgZgFb5T4Q429fvjAGtxKZuJcGq58rPBdxqjuUMdur6"
    import_key_address = "DEFFnPZbz7oksAuoGXyer8p5MkEzsUEMw9"

    def setUp(self):
        super(TestNewWallet, self).setUp()
        self.storage = WalletStorage(self.fake_config)
        self.wallet = NewWallet(self.storage)
        # This cannot be constructed by electrum at random, it should be safe
        # from eventual collisions.
        self.wallet.add_seed(self.seed_text, self.password)
        self.wallet.create_master_keys(self.password)
        self.wallet.create_main_account(self.password)

    def test_wallet_with_seed_is_not_watching_only(self):
        self.assertFalse(self.wallet.is_watching_only())

    def test_wallet_without_seed_is_watching_only(self):
        # We need a new storage , since the default storage was already seeded
        # in setUp()
        new_dir = tempfile.mkdtemp()
        config = FakeConfig(new_dir)
        storage = WalletStorage(config)
        wallet = NewWallet(storage)
        self.assertTrue(wallet.is_watching_only())
        shutil.rmtree(new_dir)  # Don't leave useless stuff in /tmp

    def test_new_wallet_is_deterministic(self):
        self.assertTrue(self.wallet.is_deterministic())

    def test_get_seed_returns_correct_seed(self):
        self.assertEqual(self.wallet.get_seed(self.password), self.seed_text)


    def test_key_import(self):
        # Wallets have no imported keys by default.
        self.assertFalse(self.wallet.has_imported_keys())

        # Importing a key works.
        self.wallet.import_key(self.import_private_key, "")
        self.assertEqual(2, len(self.wallet.addresses()))
        self.assertIn(self.import_key_address, self.wallet.addresses())

        self.assertTrue(self.wallet.has_imported_keys())

        # Deleting the key works.
        self.wallet.delete_imported_key(self.import_key_address)
        self.assertFalse(self.wallet.has_imported_keys())
        self.assertEqual(1, len(self.wallet.addresses()))
        self.assertNotIn(self.import_key_address, self.wallet.addresses())

    def test_update_password(self):
        new_password = "secret2"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
开发者ID:Geopay,项目名称:electrum-gridcoin,代码行数:63,代码来源:test_wallet.py

示例4: TestNewWallet

# 需要导入模块: from lib.wallet import NewWallet [as 别名]
# 或者: from lib.wallet.NewWallet import add_seed [as 别名]
class TestNewWallet(WalletTestCase):

    seed_text = "The seed will sprout and grow up tall."
    password = "secret"

    master_xpub = "xpub661MyMwAqRbcGEop5Rnp68oX1ikeFNVMtx1utwXZGRKMmeXVxwBM5UzkwU9nGB1EofZekLDRfi1w5F9P7Vac3PEuWdWHr2gHLW8vp5YyKJ1"
    master_xpriv = "xprv9s21ZrQH143K3kjLyQFoizrnTgv9qumWXj6K6Z7wi5nNtrCMRPs6XggH6Bbgz9CUgPJnZnV74yUdRSr8qWVELr9QQTgU5aNL33ViMyD9nhs"

    first_account_name = "account1"
    first_account_first_address = "Ld975YW8975uNNuhWQWNgiJDH3EMtGacza"
    first_account_second_address = "LP16W5shm7hfKStDe6dgHdg9Loty5FcukH"

    import_private_key = "TAroS5Knm8GZcnpPycBgzjwwDLWMyQjDrcuGPPoArgrbW7Ln22qp"
    import_key_address = "LPzGaoLUtXFkmNo3u1chDxGxDnSaBQTTxm"

    def setUp(self):
        super(TestNewWallet, self).setUp()
        self.storage = WalletStorage(self.fake_config)
        self.wallet = NewWallet(self.storage)
        # This cannot be constructed by electrum at random, it should be safe
        # from eventual collisions.
        self.wallet.add_seed(self.seed_text, self.password)

    def test_wallet_with_seed_is_not_watching_only(self):
        self.assertFalse(self.wallet.is_watching_only())

    def test_wallet_without_seed_is_watching_only(self):
        # We need a new storage , since the default storage was already seeded
        # in setUp()
        new_dir = tempfile.mkdtemp()
        config = FakeConfig(new_dir)
        wallet = NewWallet(config)
        self.assertTrue(wallet.is_watching_only())
        shutil.rmtree(new_dir)  # Don't leave useless stuff in /tmp

    def test_new_wallet_is_deterministic(self):
        self.assertTrue(self.wallet.is_deterministic())

    def test_get_seed_returns_correct_seed(self):
        self.assertEqual(self.wallet.get_seed(self.password), self.seed_text)
        self.assertEqual(0, len(self.wallet.addresses()))

    def test_add_account(self):
        self.wallet.create_account(self.first_account_name, self.password)
        self.assertEqual(1, len(self.wallet.addresses()))
        self.assertIn(self.first_account_first_address,
                         self.wallet.addresses())

    def test_add_account_add_address(self):
        self.wallet.create_account(self.first_account_name, self.password)
        self.wallet.synchronizer = FakeSynchronizer()

        self.wallet.create_new_address()
        self.assertEqual(2, len(self.wallet.addresses()))
        self.assertIn(self.first_account_first_address,
                         self.wallet.addresses())
        self.assertIn(self.first_account_second_address,
                      self.wallet.addresses())

    def test_key_import(self):
        # Wallets have no imported keys by default.
        self.wallet.create_account(self.first_account_name, self.password)
        self.assertFalse(self.wallet.has_imported_keys())

        # Importing a key works.
        self.wallet.import_key(self.import_private_key, "")
        self.assertEqual(2, len(self.wallet.addresses()))
        self.assertIn(self.import_key_address, self.wallet.addresses())

        self.assertTrue(self.wallet.has_imported_keys())

        # Deleting the key works.
        self.wallet.delete_imported_key(self.import_key_address)
        self.assertFalse(self.wallet.has_imported_keys())
        self.assertEqual(1, len(self.wallet.addresses()))
        self.assertNotIn(self.import_key_address, self.wallet.addresses())

    def test_update_password(self):
        new_password = "secret2"
        self.wallet.update_password(self.password, new_password)
        self.wallet.create_account(self.first_account_name, new_password)
        self.assertEqual(1, len(self.wallet.addresses()))
开发者ID:9cat,项目名称:electrum-tpc,代码行数:84,代码来源:test_wallet.py

示例5: TestNewWallet

# 需要导入模块: from lib.wallet import NewWallet [as 别名]
# 或者: from lib.wallet.NewWallet import add_seed [as 别名]
class TestNewWallet(WalletTestCase):

    seed_text = "travel nowhere air position hill peace suffer parent beautiful rise blood power home crumble teach"
    password = "secret"

    # mnemonic_to_seed should be this
    actual_root_privkey = "xprv9s21ZrQH143K3cU1yF5gBUQqHw8QBnH5Cgym3XqSRZmfSJ3J2NYzjd7UcdHwjwBjKXD3ZvwoMLo88F4oaVhYgZZ5SdmZ9RA9Wdf93U8iZB3"

    def setUp(self):
        super(TestNewWallet, self).setUp()
        self.storage = WalletStorage(self.fake_config)
        self.wallet = NewWallet(self.storage)
        # This cannot be constructed by electrum at random, it should be safe
        # from eventual collisions.
        self.wallet.add_seed(self.seed_text, self.password)
        self.wallet.create_master_keys(self.password)
        self.wallet.create_main_account(self.password)

    def _switch_chain(self, chaincode):
        self.wallet.set_chain(chaincode)
        action = self.wallet.get_action()
        while action is not None:
            if action == "add_chain":
                self.wallet.create_master_keys(self.password)
            elif action == "create_accounts":
                self.wallet.create_main_account(self.password)
            action = self.wallet.get_action()

    def test_wallet_seed(self):
        self.assertEqual(self.wallet.get_seed(self.password), self.seed_text)

    def test_wallet_root_derivation(self):
        self.wallet.set_chain("BTC")
        self.assertEqual(bip32_root(self.wallet.mnemonic_to_seed(self.seed_text, ""))[0], self.actual_root_privkey)

    def test_wallet_key_derivation(self):
        self._switch_chain("BTC")
        # master key for Bitcoin (m/44'/0')
        self.assertEqual(
            "xprv9wrjoAEFgZU867r47BZXNvdM6y3w4DHnRnWiRq95DHV2u6SQ19LJ3NVe3vjhz5BQdPrZTTdQo7iGhVXLsVz1ysDBa9K94tXJFkNif39ESue",
            self.wallet.get_master_private_key("x/", self.password),
        )

        # key for Bitcoin account 0 (m/44'/0'/0')
        self.assertEqual(
            "xprv9yARpU9jbs62FabfqwhqH4ZhsaMEeyuzvNc97nBDk54TTxbkuwqkiEYy8wrYFQcwZUDzKD3RaFdbJYVYWLBiXyELgiWBRw4cdvGQ2CPK3FD",
            self.wallet.get_master_private_key("x/0'", self.password),
        )

        self._switch_chain("MZC")
        # master key for Mazacoin (m/44'/13')
        self.assertEqual(
            "xprv9wrjoAEFgZU8dr6gc32HuUXAGwfULLtaFHZGy5L5MQfXSRK3cGyUKhnDtejWKxyPk15PWt3SRR68v6TBZog6jj1yvJTssVb7NyM1zZrPBsp",
            self.wallet.get_master_private_key("x/", self.password),
        )

        # key for Mazacoin account 0 (m/44'/13'/0')
        self.assertEqual(
            "xprv9zT9DPHrjeZS4gUXt9dwZfrTzWAyBsBAHatw3vthKUbqAMo8Z15NQq7zBU6tWrEp6Wk6Tk4o9NNaRz9dNbSRHkP1TcrKotKRk2TcZF1647w",
            self.wallet.get_master_private_key("x/0'", self.password),
        )

    def test_update_password(self):
        # Switch to Mazacoin and verify that the other chain is also updated with a new password
        new_password = "secret2"
        self._switch_chain("BTC")
        self._switch_chain("MZC")
        self.wallet.update_password(self.password, new_password)

        # master key for Mazacoin (m/44'/13')
        self.assertEqual(
            "xprv9wrjoAEFgZU8dr6gc32HuUXAGwfULLtaFHZGy5L5MQfXSRK3cGyUKhnDtejWKxyPk15PWt3SRR68v6TBZog6jj1yvJTssVb7NyM1zZrPBsp",
            self.wallet.get_master_private_key("x/", new_password),
        )

        self._switch_chain("BTC")
        # master key for Bitcoin (m/44'/0')
        self.assertEqual(
            "xprv9wrjoAEFgZU867r47BZXNvdM6y3w4DHnRnWiRq95DHV2u6SQ19LJ3NVe3vjhz5BQdPrZTTdQo7iGhVXLsVz1ysDBa9K94tXJFkNif39ESue",
            self.wallet.get_master_private_key("x/", new_password),
        )
开发者ID:martexcoin,项目名称:encompass,代码行数:83,代码来源:test_chains.py


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