mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-16 15:43:05 +01:00
DecodeHexTx: Try case where txn has inputs first
This commit is contained in:
@@ -117,11 +117,12 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no
|
|||||||
|
|
||||||
std::vector<unsigned char> txData(ParseHex(hex_tx));
|
std::vector<unsigned char> txData(ParseHex(hex_tx));
|
||||||
|
|
||||||
if (try_no_witness) {
|
if (try_witness) {
|
||||||
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
|
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
try {
|
try {
|
||||||
ssData >> tx;
|
ssData >> tx;
|
||||||
if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) {
|
// If transaction looks sane, we don't try other mode even if requested
|
||||||
|
if (ssData.empty() && (!try_no_witness || CheckTxScriptsSanity(tx))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
@@ -129,8 +130,8 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_witness) {
|
if (try_no_witness) {
|
||||||
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
|
||||||
try {
|
try {
|
||||||
ssData >> tx;
|
ssData >> tx;
|
||||||
if (ssData.empty()) {
|
if (ssData.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user