aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2019-12-19 10:32:44 -0500
committerGregory Sanders <gsanders87@gmail.com>2019-12-19 11:44:41 -0500
commit6020ce3c01fe5ee15a236c47da23342005b63055 (patch)
tree2db94d76e38531485c1f066342527736180a980e /src/core_read.cpp
parent988eaf2fcb71284c5fc57c7ef755bdafa4b929a0 (diff)
downloadbitcoin-6020ce3c01fe5ee15a236c47da23342005b63055.tar.xz
DecodeHexTx: Try case where txn has inputs first
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index a3c9cf0159..da76983708 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -117,11 +117,12 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no
std::vector<unsigned char> txData(ParseHex(hex_tx));
- if (try_no_witness) {
- CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
+ if (try_witness) {
+ CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
try {
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;
}
} catch (const std::exception&) {
@@ -129,8 +130,8 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no
}
}
- if (try_witness) {
- CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
+ if (try_no_witness) {
+ CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
try {
ssData >> tx;
if (ssData.empty()) {