Skip to content

Commit 6020ce3

Browse files
committed
DecodeHexTx: Try case where txn has inputs first
1 parent 988eaf2 commit 6020ce3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/core_read.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,21 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no
117117

118118
std::vector<unsigned char> txData(ParseHex(hex_tx));
119119

120-
if (try_no_witness) {
121-
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
120+
if (try_witness) {
121+
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
122122
try {
123123
ssData >> tx;
124-
if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) {
124+
// If transaction looks sane, we don't try other mode even if requested
125+
if (ssData.empty() && (!try_no_witness || CheckTxScriptsSanity(tx))) {
125126
return true;
126127
}
127128
} catch (const std::exception&) {
128129
// Fall through.
129130
}
130131
}
131132

132-
if (try_witness) {
133-
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
133+
if (try_no_witness) {
134+
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
134135
try {
135136
ssData >> tx;
136137
if (ssData.empty()) {

0 commit comments

Comments
 (0)