mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
bitcoin-tx: Reject + sign in replaceable parsing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user