From 3129160631842eb7baa603b54a98af6a2b315b24 Mon Sep 17 00:00:00 2001 From: kralverde <2b2tminecrafter2@gmail.com> Date: Sun, 7 Aug 2022 14:14:10 -0400 Subject: [PATCH] update OP_RETURN functionality --- electrum/gui/qt/send_tab.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/electrum/gui/qt/send_tab.py b/electrum/gui/qt/send_tab.py index 12dadf1c2cc7..194cf379b048 100644 --- a/electrum/gui/qt/send_tab.py +++ b/electrum/gui/qt/send_tab.py @@ -17,7 +17,7 @@ from electrum import lnutil from electrum.plugin import run_hook from electrum.i18n import _ -from electrum.ravencoin import COIN +from electrum.ravencoin import COIN, make_op_return from electrum.util import (AssetAmountModified, UserFacingException, get_asyncio_loop, bh2u, InvalidBitcoinURI, maybe_extract_lightning_payment_identifier, NotEnoughFunds, NoDynamicFeeEstimates, InvoiceError, parse_max_spend, RavenValue) @@ -340,21 +340,20 @@ def pay_onchain_dialog( op_return_raw: str = self.op_return_e.text() if len(op_return_raw) > 0: try: + if len(op_return_raw) <= 1: + raise ValueError() if len(op_return_raw) % 2 == 0: text_to_encode = op_return_raw else: + self.show_warning(_('OP_RETURN predicted hex value has an odd number of characters; truncating by 1 to maintain a proper hex value.')) text_to_encode = op_return_raw[:-1] op_return_encoded = bytes.fromhex(text_to_encode) except ValueError: op_return_encoded = op_return_raw.encode('utf8') - outputs.append( PartialTxOutput( value=0, - scriptpubkey= - b'\x6a' + - len(op_return_encoded).to_bytes(1, 'big', signed=False) + - op_return_encoded + scriptpubkey=make_op_return(op_return_encoded) )) make_tx = lambda fee_est: self.wallet.make_unsigned_transaction(