How to use the beem.exceptions.MissingKeyError function in beem

To help you get started, we’ve selected a few beem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holgern / beem / tests / beem / test_wallet.py View on Github external
self.wallet.steem = stm
        self.wallet.unlock(pwd="TestingOneTwoThree")
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            self.wallet.getOwnerKeyForAccount("test")
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            self.wallet.getMemoKeyForAccount("test")
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            self.wallet.getActiveKeyForAccount("test")
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            self.wallet.getPostingKeyForAccount("test")
github holgern / beem / tests / beem / test_hive.py View on Github external
def test_sign(self):
        bts = self.bts
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            bts.sign()
github holgern / beem / tests / beem / test_hive.py View on Github external
def test_broadcast(self):
        bts = self.bts
        bts.txbuffer.clear()
        tx = bts.comment_options({}, "@gtg/witness-gtg-log", account="test")
        # tx = bts.sign()
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            bts.broadcast(tx=tx)
github holgern / beem / tests / beem / test_steem.py View on Github external
def test_broadcast(self):
        bts = self.bts
        bts.txbuffer.clear()
        tx = bts.comment_options({}, "@gtg/witness-gtg-log", account="test")
        # tx = bts.sign()
        with self.assertRaises(
            exceptions.MissingKeyError
        ):
            bts.broadcast(tx=tx)
github holgern / beem / tests / beem / test_testnet.py View on Github external
def test_appendWif(self):
        nodelist = NodeList()
        stm = Steem(node=self.nodes,
                    nobroadcast=True,
                    expiration=120,
                    num_retries=10)
        tx = TransactionBuilder(use_condenser_api=True, steem_instance=stm)
        tx.appendOps(Transfer(**{"from": "beem",
                                 "to": "beem1",
                                 "amount": Amount("1 STEEM", steem_instance=stm),
                                 "memo": ""}))
        with self.assertRaises(
            MissingKeyError
        ):
            tx.sign()
        with self.assertRaises(
            InvalidWifError
        ):
            tx.appendWif("abcdefg")
        tx.appendWif(self.active_key)
        tx.sign()
        self.assertTrue(len(tx["signatures"]) > 0)
github holgern / beem / beem / wallet.py View on Github external
if key_type == "memo":
                key = self.getPrivateKeyForPublicKey(
                    account[0]["memo_key"])
                if key:
                    return key
            else:
                key = None
                for authority in account[0][key_type]["key_auths"]:
                    try:
                        key = self.getPrivateKeyForPublicKey(authority[0])
                        if key:
                            return key
                    except MissingKeyError:
                        key = None
                if key is None:
                    raise MissingKeyError("No private key for {} found".format(name))
            return
github holgern / beem / beem / wallet.py View on Github external
key = self.getPrivateKeyForPublicKey(
                    account[0]["memo_key"])
                if key:
                    return [key]
            else:
                keys = []
                key = None
                for authority in account[0][key_type]["key_auths"]:
                    try:
                        key = self.getPrivateKeyForPublicKey(authority[0])
                        if key:
                            keys.append(key)
                    except MissingKeyError:
                        key = None
                if key is None:
                    raise MissingKeyError("No private key for {} found".format(name))
                return keys
            return
github holgern / beem / beem / memo.py View on Github external
def encrypt(self, memo, bts_encrypt=False):
        """ Encrypt a memo

            :param str memo: clear text memo message
            :returns: encrypted memo
            :rtype: str
        """
        if not memo:
            return None

        nonce = str(random.getrandbits(64))
        memo_wif = self.steem.wallet.getPrivateKeyForPublicKey(
            self.from_account["memo_key"]
        )
        if not memo_wif:
            raise MissingKeyError("Memo key for %s missing!" % self.from_account["name"])

        if not hasattr(self, 'chain_prefix'):
            self.chain_prefix = self.steem.prefix

        if bts_encrypt:
            enc = BtsMemo.encode_memo_bts(
                PrivateKey(memo_wif),
                PublicKey(
                    self.to_account["memo_key"],
                    prefix=self.chain_prefix
                ),
                nonce,
                memo
            )

            return {
github holgern / beem / beem / wallet.py View on Github external
def getPrivateKeyForPublicKey(self, pub):
        """ Obtain the private key for a given public key

            :param str pub: Public Key
        """
        if(Wallet.keys):
            if pub in Wallet.keys:
                return Wallet.keys[pub]
            else:
                raise MissingKeyError("No private key for {} found".format(pub))
        else:
            # Test if wallet exists
            if not self.created():
                raise NoWalletException

            if not self.unlocked():
                raise WalletLocked

            encwif = self.keyStorage.getPrivateKeyForPublicKey(pub)
            if not encwif:
                raise MissingKeyError("No private key for {} found".format(pub))
            return self.decrypt_wif(encwif)