Skip to content

Commit

Permalink
DecodeHexTx: Try case where txn has inputs first
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Dec 19, 2019
1 parent 988eaf2 commit 6020ce3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,21 @@ 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&) {
// Fall through.
}
}

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()) {
Expand Down

0 comments on commit 6020ce3

Please sign in to comment.