Beispiel #1
0
    def test_wallet_load_secrets(self):
        # Load wallet with only encrypted secrets
        # Passphrase not required
        wallet = Wallet.load(SECRETS_ENCRYPTED_WALLET_PATH)
        assert not wallet.wallet_key
        assert not wallet.secret_key

        assert isinstance(wallet.properties.seed, Secret)
        for account in wallet.accounts:
            assert isinstance(account.private_key, Secret)
Beispiel #2
0
    def test_wallet_load_encrypted_wallet(self):
        # Load wallet which has been encrypted entirely
        # Passphrase required
        with pytest.raises(WalletLocked) as exc:
            Wallet.load(BOTH_ENCRYPTED_WALLET_PATH)

        assert "Wallet is encrypted but passphrase was not provided" in str(
            exc.value)

        # Wrong passphrase
        with pytest.raises(InvalidEncryptionKey) as exc:
            Wallet.load(BOTH_ENCRYPTED_WALLET_PATH, passphrase="wrong")

        assert "Incorrect passphrase" in str(exc.value)

        # Correct passphrase
        wallet = Wallet.load(BOTH_ENCRYPTED_WALLET_PATH, passphrase="password")
        assert wallet.wallet_key
        assert not wallet.secret_key

        assert isinstance(wallet.properties.seed, Secret)

        for account in wallet.accounts:
            assert isinstance(account.private_key, Secret)
Beispiel #3
0
    def load_wallet(self, path, passphrase=None):
        """
        Load a wallet from the given path

        :raises WalletFileLocked: If the wallet file is already in use by
                                  another app instance

        """
        if self.wallet_lock:
            self.wallet_lock.release()

        self.wallet_lock = filelock.FileLock("{}.lock".format(path), timeout=0)

        try:
            self.wallet_lock.acquire()
        except filelock.Timeout:
            raise WalletFileLocked(
                "The wallet file is in use by another Siliqua instance"
            )

        wallet = Wallet.load(path, passphrase=passphrase)

        self.wallet = wallet
        self.wallet_path = path
Beispiel #4
0
    def load_wallet(path, passphrase=None):
        if is_encrypted_test:
            passphrase = "password"

        return Wallet.load(path, passphrase=passphrase)