Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 3129160

Browse files
committed
update OP_RETURN functionality
1 parent 9044d0f commit 3129160

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

electrum/gui/qt/send_tab.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from electrum import lnutil
1818
from electrum.plugin import run_hook
1919
from electrum.i18n import _
20-
from electrum.ravencoin import COIN
20+
from electrum.ravencoin import COIN, make_op_return
2121
from electrum.util import (AssetAmountModified, UserFacingException, get_asyncio_loop, bh2u,
2222
InvalidBitcoinURI, maybe_extract_lightning_payment_identifier, NotEnoughFunds,
2323
NoDynamicFeeEstimates, InvoiceError, parse_max_spend, RavenValue)
@@ -340,21 +340,20 @@ def pay_onchain_dialog(
340340
op_return_raw: str = self.op_return_e.text()
341341
if len(op_return_raw) > 0:
342342
try:
343+
if len(op_return_raw) <= 1:
344+
raise ValueError()
343345
if len(op_return_raw) % 2 == 0:
344346
text_to_encode = op_return_raw
345347
else:
348+
self.show_warning(_('OP_RETURN predicted hex value has an odd number of characters; truncating by 1 to maintain a proper hex value.'))
346349
text_to_encode = op_return_raw[:-1]
347350
op_return_encoded = bytes.fromhex(text_to_encode)
348351
except ValueError:
349352
op_return_encoded = op_return_raw.encode('utf8')
350-
351353
outputs.append(
352354
PartialTxOutput(
353355
value=0,
354-
scriptpubkey=
355-
b'\x6a' +
356-
len(op_return_encoded).to_bytes(1, 'big', signed=False) +
357-
op_return_encoded
356+
scriptpubkey=make_op_return(op_return_encoded)
358357
))
359358

360359
make_tx = lambda fee_est: self.wallet.make_unsigned_transaction(

0 commit comments

Comments
 (0)