mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-08 06:00:33 +02:00
bitcoin-tx: Reject + sign in nversion parsing
It would be confusing to specify the sign for an unsigned value here, so reject it.
This commit is contained in:
parent
fab06ac037
commit
dddd9e5fe3
@ -211,12 +211,11 @@ static CAmount ExtractAndValidateValue(const std::string& strValue)
|
|||||||
|
|
||||||
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
|
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
|
||||||
{
|
{
|
||||||
uint32_t newVersion;
|
const auto ver{ToIntegral<uint32_t>(cmdVal)};
|
||||||
if (!ParseUInt32(cmdVal, &newVersion) || newVersion < 1 || newVersion > TX_MAX_STANDARD_VERSION) {
|
if (!ver || *ver < 1 || *ver > TX_MAX_STANDARD_VERSION) {
|
||||||
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
|
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
|
||||||
}
|
}
|
||||||
|
tx.version = *ver;
|
||||||
tx.version = newVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
|
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
|
||||||
|
@ -56,6 +56,12 @@
|
|||||||
"output_cmp": "blanktxv2.json",
|
"output_cmp": "blanktxv2.json",
|
||||||
"description": "Creates a blank transaction when nothing is piped into bitcoin-tx (output in json)"
|
"description": "Creates a blank transaction when nothing is piped into bitcoin-tx (output in json)"
|
||||||
},
|
},
|
||||||
|
{ "exec": "./bitcoin-tx",
|
||||||
|
"args": ["-create", "nversion=+1"],
|
||||||
|
"return_code": 1,
|
||||||
|
"error_txt": "error: Invalid TX version requested",
|
||||||
|
"description": "Tests the check for invalid nversion value"
|
||||||
|
},
|
||||||
{ "exec": "./bitcoin-tx",
|
{ "exec": "./bitcoin-tx",
|
||||||
"args": ["-create", "nversion=1foo"],
|
"args": ["-create", "nversion=1foo"],
|
||||||
"return_code": 1,
|
"return_code": 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user