merge bitcoin#17775: Try case where txn has inputs first

This commit is contained in:
Kittywhiskers Van Gogh 2024-01-24 12:16:05 +00:00 committed by pasta
parent 07946c5558
commit e099f937e6
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
2 changed files with 16 additions and 10 deletions

View File

@ -24,7 +24,7 @@ struct CSpentIndexTxInfo;
// core_read.cpp
CScript ParseScript(const std::string& s);
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
[[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx);
[[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx);
[[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
/**

View File

@ -100,25 +100,31 @@ CScript ParseScript(const std::string& s)
return result;
}
bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx)
static bool DecodeTx(CMutableTransaction& tx, const std::vector<unsigned char>& tx_data)
{
if (!IsHex(strHexTx))
return false;
std::vector<unsigned char> txData(ParseHex(strHexTx));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
CDataStream ssData(tx_data, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> tx;
if (!ssData.empty())
if (!ssData.empty()) {
return false;
}
catch (const std::exception&) {
}
} catch (const std::exception&) {
return false;
}
return true;
}
bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx)
{
if (!IsHex(hex_tx)) {
return false;
}
std::vector<unsigned char> txData(ParseHex(hex_tx));
return DecodeTx(tx, txData);
}
bool DecodeHexBlockHeader(CBlockHeader& header, const std::string& hex_header)
{
if (!IsHex(hex_header)) return false;