| 81 | } |
| 82 | |
| 83 | bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx, bool fTryNoWitness) |
| 84 | { |
| 85 | if (!IsHex(strHexTx)) |
| 86 | return false; |
| 87 | |
| 88 | vector<unsigned char> txData(ParseHex(strHexTx)); |
| 89 | |
| 90 | if (fTryNoWitness) { |
| 91 | CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); |
| 92 | try { |
| 93 | ssData >> tx; |
| 94 | if (ssData.eof()) { |
| 95 | return true; |
| 96 | } |
| 97 | } |
| 98 | catch (const std::exception&) { |
| 99 | // Fall through. |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); |
| 104 | try { |
| 105 | ssData >> tx; |
| 106 | } catch (const std::exception&) { |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk) |
| 114 | { |
no test coverage detected