diff options
author | MeshCollider <dobsonsa68@gmail.com> | 2017-08-28 18:00:21 +1200 |
---|---|---|
committer | MeshCollider <dobsonsa68@gmail.com> | 2017-09-06 11:24:59 +1200 |
commit | bbdbe805a25ae7c63e6237b3f30b8379ea29ac22 (patch) | |
tree | 938f2bb10a57b878566dc3f8020f2087b2d83234 /src/core_read.cpp | |
parent | 28485c783d826fa6ce14aaf215e82118c1af8db7 (diff) |
Add iswitness parameter to decode- and fundrawtransaction RPCs
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r-- | src/core_read.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp index 7018131a13..819fd1dd14 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -108,39 +108,39 @@ bool CheckTxScriptsSanity(const CMutableTransaction& tx) return true; } -bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx, bool fTryNoWitness) +bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness, bool try_witness) { - if (!IsHex(strHexTx)) { + if (!IsHex(hex_tx)) { return false; } - std::vector<unsigned char> txData(ParseHex(strHexTx)); + std::vector<unsigned char> txData(ParseHex(hex_tx)); - if (fTryNoWitness) { + if (try_no_witness) { CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); try { ssData >> tx; - if (ssData.eof() && CheckTxScriptsSanity(tx)) { + if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) { return true; } - } - catch (const std::exception&) { + } catch (const std::exception&) { // Fall through. } } - CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); - try { - ssData >> tx; - if (!ssData.empty()) { - return false; + if (try_witness) { + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + try { + ssData >> tx; + if (ssData.empty()) { + return true; + } + } catch (const std::exception&) { + // Fall through. } } - catch (const std::exception&) { - return false; - } - - return true; + + return false; } bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk) |