scripted diff: Improve invalid vout value rpc error message

-BEGIN VERIFY SCRIPT-
r() { sed -i 's/vout must be positive/vout cannot be negative/g' $1 }
r $(git grep -l 'vout must be positive')
-END VERIFY SCRIPT-
This commit is contained in:
Nima Yazdanmehr 2020-09-30 20:43:05 +03:30
parent 1b313cacc9
commit f471a3be00
No known key found for this signature in database
GPG key ID: 26339CEEF3CDF9ED
4 changed files with 5 additions and 5 deletions

View file

@ -594,7 +594,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
const int nOut = prevOut["vout"].get_int(); const int nOut = prevOut["vout"].get_int();
if (nOut < 0) if (nOut < 0)
throw std::runtime_error("vout must be positive"); throw std::runtime_error("vout cannot be negative");
COutPoint out(txid, nOut); COutPoint out(txid, nOut);
std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey")); std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));

View file

@ -53,7 +53,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
int nOutput = vout_v.get_int(); int nOutput = vout_v.get_int();
if (nOutput < 0) if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
uint32_t nSequence; uint32_t nSequence;
if (rbf) { if (rbf) {
@ -175,7 +175,7 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
int nOut = find_value(prevOut, "vout").get_int(); int nOut = find_value(prevOut, "vout").get_int();
if (nOut < 0) { if (nOut < 0) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive"); throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout cannot be negative");
} }
COutPoint out(txid, nOut); COutPoint out(txid, nOut);

View file

@ -2173,7 +2173,7 @@ static RPCHelpMan lockunspent()
const uint256 txid(ParseHashO(o, "txid")); const uint256 txid(ParseHashO(o, "txid"));
const int nOutput = find_value(o, "vout").get_int(); const int nOutput = find_value(o, "vout").get_int();
if (nOutput < 0) { if (nOutput < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
} }
const COutPoint outpt(txid, nOutput); const COutPoint outpt(txid, nOutput);

View file

@ -96,7 +96,7 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "txid must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", self.nodes[0].createrawtransaction, [{'txid': 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844'}], {}) assert_raises_rpc_error(-8, "txid must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", self.nodes[0].createrawtransaction, [{'txid': 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844'}], {})
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid}], {}) assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid}], {})
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 'foo'}], {}) assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 'foo'}], {})
assert_raises_rpc_error(-8, "Invalid parameter, vout must be positive", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': -1}], {}) assert_raises_rpc_error(-8, "Invalid parameter, vout cannot be negative", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': -1}], {})
assert_raises_rpc_error(-8, "Invalid parameter, sequence number is out of range", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 0, 'sequence': -1}], {}) assert_raises_rpc_error(-8, "Invalid parameter, sequence number is out of range", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 0, 'sequence': -1}], {})
# Test `createrawtransaction` invalid `outputs` # Test `createrawtransaction` invalid `outputs`