Skip to content

Commit

Permalink
rpc: reject non-hex strings for claim_script
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs authored and jtimon committed Sep 26, 2018
1 parent 07c617b commit 35364b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3586,8 +3586,12 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef
CScript witnessProgScript;
unsigned int nOut = txBTC.vout.size();
if (request.params.size() > 2) {
const std::string claim_script = request.params[2].get_str();
if (!IsHex(claim_script)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Given claim_script is not hex.");
}
// If given manually, no need for it to be a witness script
std::vector<unsigned char> witnessBytes(ParseHex(request.params[2].get_str()));
std::vector<unsigned char> witnessBytes(ParseHex(claim_script));
witnessProgScript = CScript(witnessBytes.begin(), witnessBytes.end());
nOut = GetPeginTxnOutputIndex(txBTC, witnessProgScript);
if (nOut == txBTC.vout.size()) {
Expand Down

0 comments on commit 35364b6

Please sign in to comment.