def parse_transaction(b64_tx, success_callback=None, error_callback=None): # we will go to main afterwards show_main() try: raw = a2b_base64(b64_tx) tx = psbt.PSBT.parse(raw) except: gui.error("Failed at transaction parsing") if error_callback is not None: error_callback("invalid argument") return # blue wallet trick - if the fingerprint is 0 we use our fingerprint for scope in [tx.inputs, tx.outputs]: for el in scope: for der in el.bip32_derivations: if el.bip32_derivations[der].fingerprint == b'\x00\x00\x00\x00': el.bip32_derivations[der].fingerprint = keystore.fingerprint try: data = keystore.check_psbt(tx) except Exception as e: gui.error("Problem with the transaction: %r" % e) if error_callback is not None: error_callback("invalid argument") return title = "Spending %u\nfrom %s" % (data["spending"], data["wallet"].name) message = "" for out in data["send_outputs"]: message += "%u sat to %s\n" % (out["value"], out["address"]) message += "\nFee: %u satoshi" % data["fee"] popups.prompt(title, message, ok=cb_with_args(sign_psbt, wallet=data["wallet"], tx=tx, success_callback=success_callback), cancel=cb_with_args(error_callback, "user cancel"))
def confirm_new_wallet(s): show_main() gui.update(30) # wallet format: # name&descriptor arr = s.split("&") if len(arr) != 2: gui.error("Invalid wallet format") return try: keystore.check_new_wallet(*arr) except Exception as e: gui.error("%r" % e) return popups.prompt("Add wallet \"%s\"?" % arr[0], arr[1], ok=cb_with_args(new_wallet_confirm, name=arr[0], descriptor=arr[1]))
def parse_new_wallet(s): show_main() gui.update(30) # wallet format: # name&descriptor arr = s.split("&") if len(arr) != 2: gui.error("Invalid wallet format") return w = keystore.check_new_wallet(*arr) keys_str = [] for key in w.keys: k = ("%r" % key).replace("]", "]\n") if keystore.owns_key(key): keys_str.append("#7ED321 My key: # %s" % k) else: keys_str.append("#F5A623 External key: # %s" % k) keys = "\n\n".join(keys_str) if w.script_type not in SUPPORTED_SCRIPTS.keys(): raise ValueError("Script type \"%s\" is not supported" % w.script_type) sc = w.script_type msg = "Policy: %s\nScript: %s\n%s\n\n%s" % (w.policy, SUPPORTED_SCRIPTS[w.script_type], sc, keys) scr = popups.prompt("Add wallet \"%s\"?" % arr[0], msg, ok=cb_with_args(new_wallet_confirm, name=arr[0], descriptor=arr[1])) scr.message.set_recolor(True)