Skip to content

Commit f471a3b

Browse files
committed
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-
1 parent 1b313ca commit f471a3b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/bitcoin-tx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
594594

595595
const int nOut = prevOut["vout"].get_int();
596596
if (nOut < 0)
597-
throw std::runtime_error("vout must be positive");
597+
throw std::runtime_error("vout cannot be negative");
598598

599599
COutPoint out(txid, nOut);
600600
std::vector<unsigned char> pkData(ParseHexUV(prevOut["scriptPubKey"], "scriptPubKey"));

src/rpc/rawtransaction_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
5353
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout key");
5454
int nOutput = vout_v.get_int();
5555
if (nOutput < 0)
56-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
56+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
5757

5858
uint32_t nSequence;
5959
if (rbf) {
@@ -175,7 +175,7 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
175175

176176
int nOut = find_value(prevOut, "vout").get_int();
177177
if (nOut < 0) {
178-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout must be positive");
178+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "vout cannot be negative");
179179
}
180180

181181
COutPoint out(txid, nOut);

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,7 @@ static RPCHelpMan lockunspent()
21732173
const uint256 txid(ParseHashO(o, "txid"));
21742174
const int nOutput = find_value(o, "vout").get_int();
21752175
if (nOutput < 0) {
2176-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive");
2176+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
21772177
}
21782178

21792179
const COutPoint outpt(txid, nOutput);

test/functional/rpc_rawtransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def run_test(self):
9696
assert_raises_rpc_error(-8, "txid must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", self.nodes[0].createrawtransaction, [{'txid': 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844'}], {})
9797
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid}], {})
9898
assert_raises_rpc_error(-8, "Invalid parameter, missing vout key", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 'foo'}], {})
99-
assert_raises_rpc_error(-8, "Invalid parameter, vout must be positive", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': -1}], {})
99+
assert_raises_rpc_error(-8, "Invalid parameter, vout cannot be negative", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': -1}], {})
100100
assert_raises_rpc_error(-8, "Invalid parameter, sequence number is out of range", self.nodes[0].createrawtransaction, [{'txid': txid, 'vout': 0, 'sequence': -1}], {})
101101

102102
# Test `createrawtransaction` invalid `outputs`

0 commit comments

Comments
 (0)