There can be only one OP_RETURN in a tx

This commit is contained in:
Duke
2025-05-20 11:47:22 -04:00
parent 604d77fcd9
commit 97878fa065

View File

@@ -5021,6 +5021,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
"3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n"
"4. fee (numeric, optional, default="
+ strprintf("%s", FormatMoney(ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE)) + ") The fee amount to attach to this transaction.\n"
"5. opreturn (string, optional) Hex encoded data for OP_RETURN.\n"
"\nResult:\n"
"\"operationid\" (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n"
"\nExamples:\n"
@@ -5152,8 +5153,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
CAmount nTotalOut = 0;
// Optional OP_RETURN data
CScript opret;
// TODO: enforce that only a single opreturn exists
UniValue opretValue;
UniValue opretValue = params.size() >= 4 ? params[4].get_str() : "";
bool containsSaplingOutput = false;
@@ -5164,7 +5164,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
// sanity check, report error if unknown key-value pairs
for (const string& name_ : o.getKeys()) {
std::string s = name_;
if (s != "address" && s != "amount" && s!="memo" && s!="opreturn") {
if (s != "address" && s != "amount" && s!="memo") {
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown key: ")+s);
}
}