Add OP_RETURN support in createrawtransaction RPC call, add tests.#6346
Add OP_RETURN support in createrawtransaction RPC call, add tests.#6346laanwj merged 2 commits intobitcoin:masterfrom
Conversation
|
|
|
OP_RETURN transactions are relayed in order to minimize harm to the network. Do you think this change will convert people from UTXO spam to the less-bad OP_RETURN spam, or will it just make it easier for non-spammers to start spamming? I have a feeling it's the latter unfortunately. |
src/rpcrawtransaction.cpp
Outdated
There was a problem hiding this comment.
Key probably should be named "commitment" or "data", not "OP_RETURN" (which is just a technical implementation detail).
There was a problem hiding this comment.
Don't forget to update docs here.
|
To address @lapp0 's concern, I'd recommend instead focussing on doing this in bitcoin-tx, or even more ideal, beginning work on a tx utility library (that bitcoin-tx would wrap). |
|
Nice work! |
|
The above @luke-jr I have to sort in my head first why we should allow to create transaction with two OP_RETURN txouts and mainnet inputs/outputs when the resulting TX is unusable there. The same applies to the size of the data. @lapp0 No opinion on your concern (I do not care enough - there are zillions of other ways to create OP_RETURN outputs and people already use them anyway). I also do not understand @luke-jr 's answer to your concern 8) Did it addressed your concern at all? |
|
@paveljanik Users should not be doing anything with OP_RETURN in the first place. Policy is node-specific and cannot be expected to be consistent. Nothing should be designed around specific policies. |
|
@luke-jr There are several types of users... :-) Ad policy: got it. I'll delete every policy rules checks (even |
|
mostly ACK. Comments:
|
|
Travis builds fail on some systems - can't find the file txcreatedata1.hex. Strange. Any ideas? |
|
I'll keep both |
src/bitcoin-tx.cpp
Outdated
There was a problem hiding this comment.
Is there a use case for burning a value?
There was a problem hiding this comment.
It is easy to make the "VALUE:" piece optional, in the colon search/parsing code.
That way the most common use case is outdata=DATA.
However, it is technically possible to put a value in the OP_RETURN output. This is a raw transaction interface, so setting that as an option seems reasonable, even if the use cases are rare.
There was a problem hiding this comment.
This is the best solution, yes.
|
@luke-jr I commented on non-zero output value above. I prefer to be able to construct the transaction with non-zero output value/burning the value. I do not personally have a use case for it though. I only want to be more generic. Yes, I still have to rewrite the docs of |
|
Implemented @jgarzik 's solution - the value is now optional, default is 0. |
|
Help text updated. I do not want to use []/{} notation for optional or required parts of input because it can't be combined with JSON text in an elegant way. |
|
ut ACK |
|
@paveljanik You need to list the .hex files in Makefile.test.in, otherwise they're missing from the source tarball. |
|
@theuni Thanks! But what is the reason for the first and the last Travis builds to be OK and only the rest of builds failing? |
|
@paveljanik Those two just compile, they don't run the tests. The others failed to open the files for tests, but those two never tried to open them at all. |
|
Slightly tested. But i was assuming that this steps should work: I was expecting it would add a vin and a vout for paying the estimated transaction fee. The decoded bitcoin-tx transaction looks like: I'm not sure, but does it make sense to support a non 0.0 value for the OP_RETURN vout? |
|
Tested ACK (nits see previous comment). |
|
@jonasschnelli Current master (without OP_RETURN changes): What else can you expect from a Your last question is answered above by jgarzik. We are creating raw transactions. Maybe there is a use case for it. E.g. burning bitcoin value provably instead of sending it to some random addresses.
|
|
@paveljanik: Yes. This makes sense. |
It's not strictly because there is no output to fund, but because |
|
@dexX7 Yes. And this applies to address outputs as well (not specific to this particular OP_RETURN/data transaction). Hmm, this looks like applying policy checks at the wrong place. Funded dust transaction can be delivered to friendly miner to be mined. |
470841e to
a6e78da
Compare
|
Squashed, separated both changes and their tests. |
|
Have you given any thought to integrating contracthashtool so people don't misuse this unnecessarily? |
|
While testing i was stumbled over this issue... This fails because the fee is around 49.99 BTC. The Not directly related to this PR. |
|
Concept ACK. Especially the bitcoin-tx part. |
|
@jonasschnelli Yes, this is #5913. Almost ready. |
|
This is why I separated both commits. I also think that the first one can be omitted... |
|
I think this is useful to have in the RPC |
|
Tested ACK. |
|
Concept ACK |
|
More reviews please, thank you. |
|
Tested, works as expected. @jonasschnelli: $ ./src/bitcoin-cli createrawtransaction '[]' '{"data":"74657374"}'
0100000000010000000000000000066a047465737400000000
$ ./src/bitcoin-cli fundrawtransaction '0100000000010000000000000000066a047465737400000000'
{
"hex": "0100000001197c6aafa1edb66059ca6adc21e441c3aef90cddede30f903298a919b6e4b8a70000000000feffffff020000000000000000066a047465737453f1052a010000001976a914a7abbb3caf9ad0632a61a2a0c8c52cd6f680a55688ac00000000",
"changepos": 1,
"fee": 0.00000173
} |
|
needs rebase |
a6e78da to
627468d
Compare
|
Rebased (to accomodate #6504 changes). |
| if (name_ == "data") { | ||
| std::vector<unsigned char> data = ParseHexV(sendTo[name_].getValStr(),"Data"); | ||
|
|
||
| CTxOut out(0, CScript() << OP_RETURN << data); |
There was a problem hiding this comment.
FIX Why did this OP_RETURN got here?
There was a problem hiding this comment.
Because it is part of the "data" transaction?
This change adds support for specifying OP_RETURN transaction output in
createrawtransactionRPC call and automatic tests of this functionality to the testsuite.Usage:
createrawtransactionwith it:The resulting transaction can be seen here: https://www.blocktrail.com/tBTC/tx/519cb9ac3541a2589c909750b7749048ed52df3e8345bb22510c76d14145cca6
~~This modification follows the current rules, i.e.:
As OP_RETURN outputs are not spendable and can be pruned from UTXO sets, we should encourage its usage. This PR adds this possibility to more Bitcoin Core users.
TODO/need help: rewrite
createrawtransactionhelp. I only did a minimal modification of its help text.