From 026a09268531a6ae4877ebc10f250a1bd0d13c0f Mon Sep 17 00:00:00 2001 From: Seungwon Eugene Jeong Date: Sun, 10 Mar 2019 23:02:42 +0000 Subject: [PATCH] one-time use private key Close #280 Instead of MissingKeyError when the key can't be found in the wallet, users have the second chance to enter the private key for a one-time use. --- steem/transactionbuilder.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/steem/transactionbuilder.py b/steem/transactionbuilder.py index fe6493f..07130c1 100644 --- a/steem/transactionbuilder.py +++ b/steem/transactionbuilder.py @@ -11,6 +11,7 @@ from .account import Account from .instance import shared_steemd_instance +import getpass log = logging.getLogger(__name__) @@ -118,7 +119,13 @@ def sign(self): raise e if not any(self.wifs): - raise MissingKeyError + # if no key found in the wallet, give a chance to enter it manually for a one-time use + print("The required private key can't be found in the wallet.") + wif = getpass.getpass("Private key to sign: ") + if wif == '': + raise MissingKeyError + else: + self.wifs.add(wif) signedtx.sign(self.wifs, chain=self.steemd.chain_params) self["signatures"].extend(signedtx.json().get("signatures"))