Bitcoin Forum

Bitcoin => Electrum => Topic started by: milan2sky on June 17, 2021, 01:48:50 PM



Title: How can I create an OP_RETURN TX with the Electrum console?
Post by: milan2sky on June 17, 2021, 01:48:50 PM
I can created some OP_RETURN TX by entering "OP_RETURN hereTheHexOfMyMessage" in the "pay to" GUI from electrum.

Now I want to do this with the Electrum Console


My Code Idea (however it does not work):

paytomany(outputs=[["OP_RETURN 6a1a3120746869732069732061206f7052657475726e205465730174", 0], ["tb1qez4ecr6wz0guvd8s2w3d8dlwyf7g7susctgrdp", 0.01880212]])


(I use electrum in the bitcoin-testchain mode, for testing)


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: ranochigo on June 17, 2021, 02:21:55 PM
Neither payto nor paytomany accepts OP_return as a parameter. You can only do so in the GUI, not the RPC or console.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: milan2sky on June 17, 2021, 02:45:06 PM
Ok Thank you!


why does this not work? Why does it work in the GUI?
Do you know a good alternative?


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: ranochigo on June 17, 2021, 03:10:47 PM
why does this not work? Why does it work in the GUI?
The two commands expects an address and does not parse scripts (OP_return)[1], while the GUI does[2].
Do you know a good alternative?
Bitcoin Core, using their CLI.

[1] https://github.com/spesmilo/electrum/blob/master/electrum/commands.py#L640

[2] https://github.com/spesmilo/electrum/blob/master/electrum/gui/qt/paytoedit.py#L119


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: milan2sky on June 17, 2021, 03:42:38 PM
Ok its really sad that the electrum console does not support OP_RETURN TX...

is their an other Python alternative? I can't set up bitcoin core (I don't have enough storage)

Thank you for your help!


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: BitMaxz on June 17, 2021, 04:09:04 PM
I already tried it before looking for a way to make OP_return works on the console when creating transactions in Electrum but no success. It seems they don't support it but works on payto in the GUI.

What actually do you want to achieve?

Alternatively, you can make a transaction on https://coinb.in/#newTransaction with an advanced option to enable OP_return and sign and broadcast the transaction through Electrum.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: milan2sky on June 17, 2021, 05:04:01 PM
I am trying to make a script to write some Data in the blockchain.
(I want to automate the whole process with Python)


If <this happens>
    write <this> in the Blockchain

thats my plan...


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: pooya87 on June 18, 2021, 04:03:03 AM
The two commands expects an address and does not parse scripts (OP_return)[1], while the GUI does[2].
Could you not call the same method as is called through the GUI? I have seen other methods that are not GUI commands be called this way and I'm not familiar with python.

I am trying to make a script to write some Data in the blockchain.
I hope you know that bitcoin blockchain is not a message storage database.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: hugeblack on June 18, 2021, 06:25:13 AM
I am trying to make a script to write some Data in the blockchain.
(I want to automate the whole process with Python)


If <this happens>
    write <this> in the Blockchain

thats my plan...
use bitcoinCore console with

Code:
createrawtransaction '[]' '{"your hex-encoded data":"deadbeef"}'

AFAIK, Coinb.in and Trezor support OP_RETURN but I don't know if bout console and not GUI.

Generally why do you need to do this automatically? Writing is expensive and space is 80 byte?


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: khaled0111 on June 18, 2021, 03:29:09 PM
is their an other Python alternative? I can't set up bitcoin core (I don't have enough storage)
Bitcoin core is better suited for what you are trying to achieve and if storage space is your only concern, you can install it and run it in pruned mode. It won't take much space (only few Gbs).
Otherwise, you can use Coinb.in (as suggested above) or any other tool to construct the raw transaction then you can sign and broadcast it from the Electrum console. I didn't try it, tbh, but I believe it will work.

Note: Storing message in the blockchain is considered spamming even on the testnet network. Other nodes will have to download this extra data so I hope you consider this.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: DireWolfM14 on June 18, 2021, 07:58:34 PM
The two commands expects an address and does not parse scripts (OP_return)[1], while the GUI does[2].
Could you not call the same method as is called through the GUI? I have seen other methods that are not GUI commands be called this way and I'm not familiar with python.

That was my initial thought.  I would assume that gui functions are a set of predefined commands that can by manually configured in the console or or cli.  As for requiring an address, wouldn't OP_RETURN require one as well?  I'll admit I've never used it (see below,) but I was under the impression that it required a fee, and some bitcoin to burn.


I hope you know that bitcoin blockchain is not a message storage database.

Yeah, I really don't want to upgrade all my node hard drives any sooner than I have to.  Use ETH for that kind of stupid shit.  It's blockchain is a clusterfuck already.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: ranochigo on June 19, 2021, 12:44:25 AM
Could you not call the same method as is called through the GUI? I have seen other methods that are not GUI commands be called this way and I'm not familiar with python.
Not AFAIK, or perhaps I haven't delved into it enough. I'm aware of certain GUI methods to be called through the console, QR codes etc. The creation of the transaction itself calls the transaction module, while the parsing of the output is done with paytoedit.

As for requiring an address, wouldn't OP_RETURN require one as well?  I'll admit I've never used it (see below,) but I was under the impression that it required a fee, and some bitcoin to burn.
Outputs are scripts, addresses are scripts as well.

They're not treated differently in terms of the fees required, it is always dependent on the size of the transaction. OP_Return is a special kind of output that allows for 0 value output.


Title: Re: How can I create an OP_RETURN TX with the Electrum console?
Post by: DireWolfM14 on June 20, 2021, 08:22:53 PM
Outputs are scripts, addresses are scripts as well.

Thanks for the clarification, makes perfect sense.  Nevertheless, I don't think that the blockchain should be used as someone's personal notepad.  Seems like a dick-move...

Or perhaps a bit more accurately, a cunt-move (https://bitcointalk.org/index.php?topic=5282911.msg56567378#msg56567378).