From e981bc58dce3fa24a6d8d6776c6fa9639595a944 Mon Sep 17 00:00:00 2001 From: ms Date: Wed, 8 Dec 2021 19:17:25 +0100 Subject: taler-local: offer QR-code option --- bin/WIP/taler-local | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/bin/WIP/taler-local b/bin/WIP/taler-local index 6a19ea4..d54e847 100755 --- a/bin/WIP/taler-local +++ b/bin/WIP/taler-local @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with GNU Taler. If not, see . +import qrcode import signal import socket import shutil @@ -1714,7 +1715,14 @@ def stop(): help="Protocol accepred by the bank, defaults to 'http'", default="http" ) -def withdraw(bank_host, bank_proto): +@click.option( + "--with-qr-code", is_flag=True, + help="""When specified, it prints the QR code on screen, +and waits the user's input before confirming the operation +at the bank.""", + default=False +) +def withdraw(bank_host, bank_proto, with_qr_code): print_nn("Create withdrawal operation...") bank_base_url = bank_proto + "://" + bank_host resp = requests.post(bank_base_url + @@ -1733,7 +1741,14 @@ def withdraw(bank_host, bank_proto): print(" OK") print("Let wallet specify the reserve public key at the bank...") # Let wallet give the reserve public key to the bank. - subprocess.run(["taler-wallet-cli", "handle-uri", withdraw_uri], check=True) + if with_qr_code: + withdraw_QR_code = qrcode.QRCode() + withdraw_QR_code.add_data(withdraw_uri) + withdraw_QR_code.print_ascii() + print(withdraw_uri) + input("After scanning the code, press ENTER to wire funds to the Exchange: ") + else: + subprocess.run(["taler-wallet-cli", "handle-uri", withdraw_uri], check=True) # Let the user confirm the withdrawal operation and # get the bank wire the funds. print_nn("Confirm withdrawal operation at the bank...") @@ -1748,9 +1763,11 @@ def withdraw(bank_host, bank_proto): print(error) exit(1) print(" OK") - print("Let wallet complete all pending operations") - subprocess.run(["taler-wallet-cli", "handle-uri", withdraw_uri], check=True) - subprocess.run(["taler-wallet-cli", "run-until-done"], check=True) + if not with_qr_code: + print("Let wallet complete all pending operations") + # FIXME: Why the following operation twice? + subprocess.run(["taler-wallet-cli", "handle-uri", withdraw_uri], check=True) + subprocess.run(["taler-wallet-cli", "run-until-done"], check=True) if __name__ == "__main__": cli() -- cgit v1.2.3