Multiple OP_RETURN outputs in a transaction are not standard and unlikely to be relayed, so avoid creating them.
Apart from that, the logic was broken in that it duplicated the same hex-data for each data output: Closes #14868.
Multiple OP_RETURN outputs in a transaction are not standard and unlikely to be relayed, so avoid creating them.
Apart from that, the logic was broken in that it duplicated the same hex-data for each data output: Closes #14868.
418 | + bool has_data{false}; 419 | + 420 | for (const std::string& name_ : outputs.getKeys()) { 421 | if (name_ == "data") { 422 | + if (has_data) { 423 | + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, duplicate data");
nit: "duplicate data" could be misleading, as it could refer to the key or the value.
They are key-value pairs and neither the data key, nor the data value are allowed to be duplicate?
True, but the error triggered is irrespective of the data itself, "Invalid parameter, duplicate key: data" would be more clear IMO. Def a nit, though.
Ok, fixed
utACK
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, 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.
rpcwallet.cpp also calls ConstructTransaction, has docs to update.
wouldn't be better to delegate to IsStandardTx function, in "src/ policy/policy.cpp", to check if the tx is standard or not? I made a test in https://github.com/isghe/bitcoin/commits/raise-error-createrawtransaction-multi-OP_RETURN and it looks is working good.
I just added on top of #14888
const CTransaction rawTxCopy (rawTx);
std::string error;
if (!IsStandardTx (rawTxCopy, error)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: " + error);
}
with this result:
$ ./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
without spreading the source code, on how to decide if a transaction is standard or not
utACK fa4c8679ed94f215ce895938f7c3c169a2ce101e
who decide if a transaction is standard or not? createrawtransaction or IsStandardTx?
In the first case, I think it will be a security problem.
utACK fa4c8679ed94f215ce895938f7c3c169a2ce101e
Milestone
0.17.2