I am trying to create a transaction using this as my template here (I'm using Bitcoin Core 0.20.1 testnet)
The RPC "createrawtransaction" of Bitcoin Core 0.12 will be extended, and directly supports to create OP_RETURN transactions as follows:
bitcoin-cli "createrawtransaction" '[{"txid":"hash","vout":n}, ...] '{"data": "0123..."}'
When I create the raw transaction, my node is giving me an error about the data I want to include.
For example, I tried to convert "I am FractalEncrypt" to hex and I get this:
4920616d204672616374616c456e6372797074
When I try to insert this string into the data field below I get
Error: Error parsing JSON:
createrawtransaction \
'[{"txid": "txid1", "vout": vout1},
{"txid": "txid2", "vout": vout2}]' \
'{"address1": Amount1,
"address2": Amount2,
"address3": Amount3,
"data": 4920616d204672616374616c456e6372797074}'
If instead of 4920616d204672616374616c456e6372797074, I just use 49 (the first two digits)
Immediately, createrawtranstion works, and I get my raw tx hex.
I tested the same thing with "hello world"
68656c6c6f20776f726c64
This gives the JSON error, but if I only use the first 2 digits, 68, then it works.
So obviously I am converting from text to the hex strings incorrectly, I'm using "text to hexadecimal" converters online, I've tried 2, they give identical results...
Here's one -
https://www.rapidtables.com/convert/number/ascii-to-hex.htmlHere's the other -
https://www.online-toolz.com/tools/text-hex-convertor.phpEDIT: I tested a few more things, trying more characters, if I try 8 characters(4920616d, I get the same JSON Error, but if I only have 7 characters (4920616), the error tells me it's not in hex format...so maybe something else is going on.
ERROR: Data must be hexadecimal string (not '4920616') (code -8)
EDIT 2: I tried using 4 characters in the data field, that also worked, I get the transaction hx right away (using 4920)
6 characters ALSO works perfectly (characters are 492061)
Bitcoin Client Software and Version Number: Bitcoin Core QT Console Version 0.20.1 (testnet)
Operating System: Windows 10
System Hardware Specs: Desktop
Log Files from the Bitcoin Client: (not sure how to grab these...)