mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge pull request #5499
7f71813
Bugfix: prioritisetransaction: Do some basic sanity checking on txid (Luke Dashjr)
This commit is contained in:
commit
a5eb61d9ef
@ -19,6 +19,7 @@ extern CScript ParseScript(std::string s);
|
|||||||
extern bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);
|
extern bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx);
|
||||||
extern bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
|
extern bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
|
||||||
extern uint256 ParseHashUV(const UniValue& v, const std::string& strName);
|
extern uint256 ParseHashUV(const UniValue& v, const std::string& strName);
|
||||||
|
extern uint256 ParseHashStr(const std::string&, const std::string& strName);
|
||||||
extern std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
|
extern std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
|
||||||
|
|
||||||
// core_write.cpp
|
// core_write.cpp
|
||||||
|
@ -131,6 +131,11 @@ uint256 ParseHashUV(const UniValue& v, const string& strName)
|
|||||||
string strHex;
|
string strHex;
|
||||||
if (v.isStr())
|
if (v.isStr())
|
||||||
strHex = v.getValStr();
|
strHex = v.getValStr();
|
||||||
|
return ParseHashStr(strHex, strName); // Note: ParseHashStr("") throws a runtime_error
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
|
||||||
|
{
|
||||||
if (!IsHex(strHex)) // Note: IsHex("") is false
|
if (!IsHex(strHex)) // Note: IsHex("") is false
|
||||||
throw runtime_error(strName+" must be hexadecimal string (not '"+strHex+"')");
|
throw runtime_error(strName+" must be hexadecimal string (not '"+strHex+"')");
|
||||||
|
|
||||||
|
@ -288,8 +288,7 @@ Value prioritisetransaction(const Array& params, bool fHelp)
|
|||||||
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")
|
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")
|
||||||
);
|
);
|
||||||
|
|
||||||
uint256 hash;
|
uint256 hash = ParseHashStr(params[0].get_str(), "txid");
|
||||||
hash.SetHex(params[0].get_str());
|
|
||||||
|
|
||||||
CAmount nAmount = params[2].get_int64();
|
CAmount nAmount = params[2].get_int64();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user