bitcoin-tx: Reject + sign in replaceable parsing

This commit is contained in:
MarcoFalke
2025-05-15 22:00:30 +02:00
parent faff25a558
commit fa8acaf0b9
2 changed files with 13 additions and 5 deletions

View File

@@ -229,16 +229,15 @@ static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx)
{
// parse requested index
int64_t inIdx = -1;
if (strInIdx != "" && (!ParseInt64(strInIdx, &inIdx) || inIdx < 0 || inIdx >= static_cast<int64_t>(tx.vin.size()))) {
const auto idx{ToIntegral<uint32_t>(strInIdx)};
if (strInIdx != "" && (!idx || *idx >= tx.vin.size())) {
throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
}
// set the nSequence to MAX_INT - 2 (= RBF opt in flag)
int cnt = 0;
uint32_t cnt{0};
for (CTxIn& txin : tx.vin) {
if (strInIdx == "" || cnt == inIdx) {
if (strInIdx == "" || cnt == *idx) {
if (txin.nSequence > MAX_BIP125_RBF_SEQUENCE) {
txin.nSequence = MAX_BIP125_RBF_SEQUENCE;
}

View File

@@ -177,6 +177,15 @@
"error_txt": "error: Invalid TX input index",
"description": "Tests the check for an invalid string input index with replaceable"
},
{ "exec": "./bitcoin-tx",
"args":
["-create",
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:0",
"replaceable=+0"],
"return_code": 1,
"error_txt": "error: Invalid TX input index",
"description": "Tests the check for an invalid string input index with replaceable"
},
{
"exec": "./bitcoin-tx",
"args":