bitcoin-tx: Reject + sign in replaceable parsing
This commit is contained in:
2 files changed
+13
-5
No files matched your search
+4
-5
@@ -229,16 +229,15 @@ static void MutateTxLocktime(CMutableTransaction& tx, const std::string& cmdVal)
|
|||||||
|
|
||||||
static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx)
|
static void MutateTxRBFOptIn(CMutableTransaction& tx, const std::string& strInIdx)
|
||||||
{
|
{
|
||||||
// parse requested index
|
const auto idx{ToIntegral<uint32_t>(strInIdx)};
|
||||||
int64_t inIdx = -1;
|
if (strInIdx != "" && (!idx || *idx >= tx.vin.size())) {
|
||||||
if (strInIdx != "" && (!ParseInt64(strInIdx, &inIdx) || inIdx < 0 || inIdx >= static_cast<int64_t>(tx.vin.size()))) {
|
|
||||||
throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
|
throw std::runtime_error("Invalid TX input index '" + strInIdx + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the nSequence to MAX_INT - 2 (= RBF opt in flag)
|
// set the nSequence to MAX_INT - 2 (= RBF opt in flag)
|
||||||
int cnt = 0;
|
uint32_t cnt{0};
|
||||||
for (CTxIn& txin : tx.vin) {
|
for (CTxIn& txin : tx.vin) {
|
||||||
if (strInIdx == "" || cnt == inIdx) {
|
if (strInIdx == "" || cnt == *idx) {
|
||||||
if (txin.nSequence > MAX_BIP125_RBF_SEQUENCE) {
|
if (txin.nSequence > MAX_BIP125_RBF_SEQUENCE) {
|
||||||
txin.nSequence = MAX_BIP125_RBF_SEQUENCE;
|
txin.nSequence = MAX_BIP125_RBF_SEQUENCE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,6 +177,15 @@
|
|||||||
"error_txt": "error: Invalid TX input index",
|
"error_txt": "error: Invalid TX input index",
|
||||||
"description": "Tests the check for an invalid string input index with replaceable"
|
"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",
|
"exec": "./bitcoin-tx",
|
||||||
"args":
|
"args":
|
||||||
|
|||||||
Reference in new issue
Block a user