def _parse_output(self, x): try: address = self._parse_address(x) self._show_cashaddr_warning(x) return address except: return Script.from_asm(x)
def _parse_output(self, text: str) -> Script: try: address = Address.from_string(text, Net.COIN) self._show_cashaddr_warning(text) return address.to_script() except ValueError: pass try: return string_to_bip276_script(text) except ValueError: pass return Script.from_asm(text)
def _parse_output(self, text: str) -> Script: # raises InvalidPayToError try: address = Address.from_string(text, Net.COIN) self._show_cashaddr_warning(text) return address.to_script() except ValueError: pass if text.startswith(PREFIX_BIP276_SCRIPT + ":"): try: return string_to_bip276_script(text) except ValueError as e: raise InvalidPayToError(e.args[0]) if text.startswith(PREFIX_ASM_SCRIPT): try: return Script.from_asm(text[len(PREFIX_ASM_SCRIPT):]) except ScriptError as e: raise InvalidPayToError(e.args[0]) raise InvalidPayToError( _("Unrecognized payment destination: {}").format(text))
def hex(self): return Script.from_asm(self.asm).to_hex()