Decode utf8 in opreturn and convert to hex

This commit is contained in:
Duke
2025-05-29 02:39:58 -04:00
parent fb3eb56c8f
commit 48e0a989c1

View File

@@ -5157,9 +5157,14 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
if(params.size() == 5) {
opretValue = params[4].get_str();
// Support a prefix "utf8:" which allows giving utf8 text instead of hex
if(opretValue.get_str().substr(0,5) == "utf8:") {
// TODO: 1) remove the first 5 chars
// 2) convert remaining text to hex and store in opretValue
auto str = opretValue.get_str().substr(5);
if (utf8::is_valid(str)) {
opretValue = HexStr(str);
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid utf8 in opreturn");
}
}
}