Make error messages distinct at each failure location.

This commit is contained in:
Glenn Willen 2020-07-23 02:39:13 -07:00
parent a4c279e29a
commit 3386cae45b
2 changed files with 5 additions and 5 deletions

View file

@ -2964,11 +2964,11 @@ UniValue rawissueasset(const JSONRPCRequest& request)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have at least one output.");
}
if (!mtx.vout[mtx.vout.size() - 1].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Last transaction output must be fee.");
}
for (size_t i = 0; i < mtx.vout.size() - 1; i++) {
if (mtx.vout[i].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction can only have one fee output.");
}
}
@ -3092,11 +3092,11 @@ UniValue rawreissueasset(const JSONRPCRequest& request)
// Validate fee output location, required by the implementation of reissueasset_base
if (!mtx.vout[mtx.vout.size() - 1].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Last transaction output must be fee.");
}
for (size_t i = 0; i < mtx.vout.size() - 1; i++) {
if (mtx.vout[i].IsFee()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction must have exactly one fee output, which must be last");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Transaction can only have one fee output.");
}
}

View file

@ -297,7 +297,7 @@ class IssuanceTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "Transaction must have at least one output.",
self.nodes[0].rawissueasset, raw_tx, [{"asset_amount": 1, "asset_address": valid_addr}])
raw_tx = self.nodes[0].createrawtransaction([], {valid_addr: Decimal("1")})
assert_raises_rpc_error(-8, "Transaction must have exactly one fee output, which must be last",
assert_raises_rpc_error(-8, "Last transaction output must be fee.",
self.nodes[0].rawissueasset, raw_tx, [{"asset_amount": 1, "asset_address": valid_addr}])
# Make sure that invalid addresses are rejected.