| 111 | } |
| 112 | |
| 113 | bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness, bool try_witness) |
| 114 | { |
| 115 | if (!IsHex(hex_tx)) { |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | std::vector<unsigned char> txData(ParseHex(hex_tx)); |
| 120 | |
| 121 | if (try_no_witness) { |
| 122 | CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); |
| 123 | try { |
| 124 | ssData >> tx; |
| 125 | if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) { |
| 126 | return true; |
| 127 | } |
| 128 | } catch (const std::exception&) { |
| 129 | // Fall through. |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | if (try_witness) { |
| 134 | CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); |
| 135 | try { |
| 136 | ssData >> tx; |
| 137 | if (ssData.empty()) { |
| 138 | return true; |
| 139 | } |
| 140 | } catch (const std::exception&) { |
| 141 | // Fall through. |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk, bool fLegacyFormat) |
| 149 | { |
no test coverage detected