Bitcoin Forum
October 18, 2021, 03:50:10 AM *
News: Latest Bitcoin Core release: 22.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Specifying OP_RETURN when creating a raw transaction  (Read 2408 times)
loquitus_of_borg
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
February 18, 2014, 01:29:00 AM
 #1

Is this something that can't be done yet (unless using a 0.9 release candidate)?

I know that people have already sent out TX's that specify OP_RETURN in the output scripts, but I can't seem to see how to do this. I apologize if I should have put this in a different forum -- not sure.

Thanks.
1634529010
Hero Member
*
Offline Offline

Posts: 1634529010

View Profile Personal Message (Offline)

Ignore
1634529010
Reply with quote  #2

1634529010
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1634529010
Hero Member
*
Offline Offline

Posts: 1634529010

View Profile Personal Message (Offline)

Ignore
1634529010
Reply with quote  #2

1634529010
Report to moderator
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 3556
Merit: 5704



View Profile
February 18, 2014, 01:31:49 AM
 #2

There isn't currently a direct facility for it— because it's not generally something you're supposed to use.

OP_RETURN is like giving out clean needles to heroin addicts.  It's there as harm mitigation, but it isn't something thats generally good for the system.

When there is an actual application for using them in the software then that will be exposed— but just using it to cram data into transactions and externalize your storage costs onto the network? No.
loquitus_of_borg
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
February 18, 2014, 01:43:50 AM
 #3

My understanding is are being considered because people are resorting to creating unspendable UXTO's to "embed" data. This would pollute the blockchain and is not something that can be stopped, so since we can't stop it, let's at least provide a cleaner way to do it, albeit we would prefer it not be done at all.

Is this sort of the point and why this won't be a feature that will be easily provided?

Problem is, it is still way easier to do the former than it is to use OP_RETURN, from how I understand things, so unless you make it at least reasonably as easy/hard to use OP_RETURN as it is to do the former, it is sort of pointless.

But more generally, how do you even specify your own output scripts? What if you want to something fancier than just sending BTC to one or more recipients using the already-supported script operarations. How would you even do that? Is the reference bitcoin client not meant to support this?
maaku
Legendary
*
expert
Offline Offline

Activity: 905
Merit: 1006


View Profile
February 18, 2014, 01:53:46 AM
 #4

You have to do something custom to put data on the blockchain anyway. And using OP_RETURN is easy: put the opcode (0x6a) in the front of the script, and increment the length prefix.

I'm an independent developer working on bitcoin-core, making my living off community donations.
If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
loquitus_of_borg
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
February 18, 2014, 02:18:26 AM
 #5

I probably don't understand this as well as you do (obviously), so pardon some of the obviousness of my question.

I realize opcode 0x6a is what refers to OP_RETURN. I noticed this in the HEX for some of the TX's already on the blockchain that have OP_RETURN output scripts. It seems (if I get it right) that it is something like 0x6a<Length in Hex><Data in Hex>

Not too sure what you meant when you said to put the opcode 0x6a in front of the script followed by the length prefix.

Since the bitcoind client does not let you specify output scripts (per my knowledge) when creating a raw transaction, I am going with the idea that I have to take the output of createrawtransaction, and modify it to additionally include OP_RETURN somehow.

What approach were you referring to?
nederhoed
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile WWW
May 06, 2014, 01:30:01 PM
 #6

In python you could specify the OP_RETURN value as follows:

Code:
from binascii import unhexlify

msg = 'your message of max 40 chars'
# convert msg to OP_RETURN script in hexadecimal
hexed = "6a%x%s" % (len(msg), msg.encode('hex'))
# convert to binary encoding
script = unhexlify(hexed)
Set the value of the output to 0.0, replace the transaction script with the binary part above.

Do not forget to add enough fee and send the remainder to your change address.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!