bitcoin-tx: Reject + sign in locktime

This commit is contained in:
MarcoFalke 2025-05-15 21:48:23 +02:00
parent dddd9e5fe3
commit faff25a558
No known key found for this signature in database
2 changed files with 10 additions and 4 deletions

View File

@ -220,11 +220,11 @@ static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newLocktime;
if (!ParseInt64(cmdVal, &newLocktime) || newLocktime < 0LL || newLocktime > 0xffffffffLL)
const auto locktime{ToIntegral<uint32_t>(cmdVal)};
if (!locktime) {
throw std::runtime_error("Invalid TX locktime requested: '" + cmdVal + "'");
tx.nLockTime = (unsigned int) newLocktime;
}
tx.nLockTime = *locktime;
}
static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx)

View File

@ -132,6 +132,12 @@
"output_cmp": "tt-locktime317000-out.json",
"description": "Adds an nlocktime to a transaction (output in json)"
},
{ "exec": "./bitcoin-tx",
"args": ["-create", "locktime=+317"],
"return_code": 1,
"error_txt": "error: Invalid TX locktime requested",
"description": "Tests the check for invalid locktime value"
},
{ "exec": "./bitcoin-tx",
"args": ["-create", "locktime=317000foo"],
"return_code": 1,