bitcoin-tx: Reject + sign in vout parsing
This commit is contained in:
2 files changed
+12
-3
No files matched your search
+4
-3
@@ -275,9 +275,10 @@ static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInpu
|
|||||||
|
|
||||||
// extract and validate vout
|
// extract and validate vout
|
||||||
const std::string& strVout = vStrInputParts[1];
|
const std::string& strVout = vStrInputParts[1];
|
||||||
int64_t vout;
|
const auto vout{ToIntegral<uint32_t>(strVout)};
|
||||||
if (!ParseInt64(strVout, &vout) || vout < 0 || vout > static_cast<int64_t>(maxVout))
|
if (!vout || *vout > maxVout) {
|
||||||
throw std::runtime_error("invalid TX input vout '" + strVout + "'");
|
throw std::runtime_error("invalid TX input vout '" + strVout + "'");
|
||||||
|
}
|
||||||
|
|
||||||
// extract the optional sequence number
|
// extract the optional sequence number
|
||||||
uint32_t nSequenceIn = CTxIn::SEQUENCE_FINAL;
|
uint32_t nSequenceIn = CTxIn::SEQUENCE_FINAL;
|
||||||
@@ -286,7 +287,7 @@ static void MutateTxAddInput(CMutableTransaction& tx, const std::string& strInpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// append to transaction input list
|
// append to transaction input list
|
||||||
CTxIn txin(*txid, vout, CScript(), nSequenceIn);
|
CTxIn txin{*txid, *vout, CScript{}, nSequenceIn};
|
||||||
tx.vin.push_back(txin);
|
tx.vin.push_back(txin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,14 @@
|
|||||||
"error_txt": "error: invalid TX sequence id 'abcdef00'",
|
"error_txt": "error: invalid TX sequence id 'abcdef00'",
|
||||||
"description": "Try to make invalid input replaceable"
|
"description": "Try to make invalid input replaceable"
|
||||||
},
|
},
|
||||||
|
{ "exec": "./bitcoin-tx",
|
||||||
|
"args":
|
||||||
|
["-create",
|
||||||
|
"in=5897de6bd6027a475eadd57019d4e6872c396d0716c4875a5f1a6fcfdf385c1f:+0"],
|
||||||
|
"return_code": 1,
|
||||||
|
"error_txt": "error: invalid TX input vout",
|
||||||
|
"description": "Tests the check for an invalid vout value when adding an input"
|
||||||
|
},
|
||||||
{ "exec": "./bitcoin-tx",
|
{ "exec": "./bitcoin-tx",
|
||||||
"args":
|
"args":
|
||||||
["-create",
|
["-create",
|
||||||
|
|||||||
Reference in new issue
Block a user