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 // core_read.cpp
CScript ParseScript(const std::string& s); CScript ParseScript(const std::string& s);
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false); 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); [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header); bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
/** /**

View File

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