Пример #1
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #2
0
class TestNewWallet(WalletTestCase):

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

    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.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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #3
0
class TestNewWallet(WalletTestCase):

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

    first_account_name = "account1"

    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)
        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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #9
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #10
0
class TestNewWallet(WalletTestCase):

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

    first_account_name = "account1"

    import_private_key = "aEvePg3TRfAjAAEAX1EpAMhNBtxVSz3aExVkiuQ29QwoRsnJiLHG"
    import_key_address = "MHZ7WJA5v7EaMqD5PtF2r9e4PvzEFk6Nju"

    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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #11
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        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()))
Пример #12
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        self.wallet.update_password(self.password, new_password)
        self.wallet.get_seed(new_password)
Пример #13
0
class TestNewWallet(WalletTestCase):

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

    master_xpub = "xpub661MyMwAqRbcGEop5Rnp68oX1ikeFNVMtx1utwXZGRKMmeXVxwBM5UzkwU9nGB1EofZekLDRfi1w5F9P7Vac3PEuWdWHr2gHLW8vp5YyKJ1"
    master_xpriv = "xprv9s21ZrQH143K3kjLyQFoizrnTgv9qumWXj6K6Z7wi5nNtrCMRPs6XggH6Bbgz9CUgPJnZnV74yUdRSr8qWVELr9QQTgU5aNL33ViMyD9nhs"

    first_account_name = "account1"
    first_account_first_address = "1Jv9pLCJ4Sqr7aDYLGX5QhET4ps5qRcB9V"
    first_account_second_address = "14n9EsZsgTTc4eC4TxeP1ccP8bXgwxPMmL"

    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)

    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 = "******"
        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()))
Пример #14
0
class TestNewWallet(WalletTestCase):

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

    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 = "******"
        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()))
Пример #15
0
class TestNewWallet(WalletTestCase):

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

    master_xpub = "xpub661MyMwAqRbcGEop5Rnp68oX1ikeFNVMtx1utwXZGRKMmeXVxwBM5UzkwU9nGB1EofZekLDRfi1w5F9P7Vac3PEuWdWHr2gHLW8vp5YyKJ1"
    master_xpriv = "xprv9s21ZrQH143K3kjLyQFoizrnTgv9qumWXj6K6Z7wi5nNtrCMRPs6XggH6Bbgz9CUgPJnZnV74yUdRSr8qWVELr9QQTgU5aNL33ViMyD9nhs"

    first_account_name = "account1"
    first_account_first_address = "1Jv9pLCJ4Sqr7aDYLGX5QhET4ps5qRcB9V"
    first_account_second_address = "14n9EsZsgTTc4eC4TxeP1ccP8bXgwxPMmL"

    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)

    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 = "******"
        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()))