-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Fix createrawtransaction multi op return - issue #14868 #14888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix createrawtransaction multi op return - issue #14868 #14888
Conversation
``` $ ./src/bitcoin-cli createrawtransaction "[]" "{\"data\":\"ee\", \"data\":\"ff\"}" 0200000000020000000000000000036a01ee0000000000000000036a01ff00000000 ``` ``` $ ./src/bitcoin-cli createrawtransaction "[]" "[{\"data\":\"ee\"}, {\"data\":\"ff\"}]" 0200000000020000000000000000036a01ee0000000000000000036a01ff00000000 ``` bitcoin#14868
NAK. Network IsStandard rules prohibit multiple op_returns (https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp#L135), additional bloat on the blockchain is also not desired. The inputs to this RPC are also an array, so duplicating inputs is also pretty broken. |
@gmaxwell so maybe we should raise an error? Because actually it's producing a strange thing
|
@isghe you can help review by making your PR minimal:
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
build on top of bitcoin#14888 to fix bitcoin#14868 generates an error if the tx is not standard, using the `IsStandardTx` policy function, without spreading the source code, on how to decide if a transaction is standard or not. ``` $ ./src/bitcoin-cli createrawtransaction "[]" "[{\"mguLQ6eGCHpnmRrDwAjbPpYAHjxY6GneeQ\":\"0.1\"}, {\"data\":\"ee\"}, {\"muLYgM1L3gCzLs1bPX5cVzx3ax1f4vBcpN\":\"0.2\"},{\"data\":\"ff\"}]" | xargs ./src/bitcoin-cli decoderawtransaction error code: -8 error message: Invalid parameter combination: multi-op-return ```
https://github.com/isghe/bitcoin/commits/raise-error-createrawtransaction-multi-OP_RETURN const CTransaction rawTxCopy (rawTx);
std::string error;
if (!IsStandardTx (rawTxCopy, error)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: " + error);
} obtaining:
|
5987b7c makes sense to me, independent of this issue. Calls for another PR IMO. |
@Empact my idea, is that |
anyway, |
@isghe to get this done safely and most easily, I recommend approaching this incrementally, e.g.:
|
Rejecting duplicate data fields instead of mangling them is the right thing to do regardless of standardness rules: as I pointed out, the input is a dictionary... and also even if standardness permitted multiple op_returns we probably would not support it. IsStandard probably shouldn't be run on non-final/signed transactions so it isn't a solution here. (It might actually work, but if so that's largely an accident.) The standardness behaviour of the wallet and the network are disjoint in any case: lets imagine that the network standardness rule changed, we still wouldn't want the wallet creating things the old behaviour would reject until the new behaviour were widely deployed. Sometimes code/behavior that looks the same isn't really the same and isn't a duplicate due to how the code needs to be maintained or modified. |
NACK, this changes nothing. |
Needs rebase |
@gmaxwell thanks for the explanation. I think we can close this PR. |
fix issue #14868