From 46381f603ba4d8d109cbfd11006336b45004e080 Mon Sep 17 00:00:00 2001 From: Anthony Fieroni Date: Mon, 20 Aug 2018 17:44:11 +0300 Subject: [PATCH] Do not create transactions with incorrect claims Signed-off-by: Anthony Fieroni --- src/wallet/rpcwallet.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fb79af6fb..1e83adddc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -426,6 +426,10 @@ UniValue claimname(const UniValue& params, bool fHelp) ); string sName = params[0].get_str(); string sValue = params[1].get_str(); + + if (!IsHex(sValue)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "value must be hexadecimal"); + std::vector vchName (sName.begin(), sName.end()); std::vector vchValue(ParseHex(sValue)); @@ -513,6 +517,10 @@ UniValue updateclaim(const UniValue& params, bool fHelp) std::vector vchName; string sValue = params[1].get_str(); + + if (!IsHex(sValue)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "value must be hexadecimal"); + std::vector vchValue(ParseHex(sValue)); CAmount nAmount = AmountFromValue(params[2]); @@ -534,6 +542,9 @@ UniValue updateclaim(const UniValue& params, bool fHelp) { if (DecodeClaimScript(wtx.vout[i].scriptPubKey, op, vvchParams)) { + if (op == OP_SUPPORT_CLAIM) + continue; + vchName = vvchParams[0]; EnsureWalletIsUnlocked(); if (op == OP_CLAIM_NAME) @@ -848,6 +859,14 @@ UniValue supportclaim(const UniValue& params, bool fHelp) string sName = params[0].get_str(); string sClaimId = params[1].get_str(); + + const size_t claimLength = 40; + + if (!IsHex(sClaimId)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "claimid must be a 20-character hexadecimal string (not '" + sClaimId + "')"); + if (sClaimId.length() != claimLength) + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("claimid must be of length %d", claimLength)); + uint160 claimId; claimId.SetHex(sClaimId); std::vector vchName (sName.begin(), sName.end());