From ae775b5b311982a3d932a9e34ddc94ce597dcaaf Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 23 Jun 2014 23:10:24 -0400 Subject: Consolidate CTransaction hex encode/decode into core_io.h, core_{read,write}.cpp --- src/core_read.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/core_read.cpp (limited to 'src/core_read.cpp') diff --git a/src/core_read.cpp b/src/core_read.cpp new file mode 100644 index 0000000000..937dcd9c12 --- /dev/null +++ b/src/core_read.cpp @@ -0,0 +1,25 @@ + +#include +#include "core_io.h" +#include "core.h" +#include "serialize.h" + +using namespace std; + +bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx) +{ + if (!IsHex(strHexTx)) + return false; + + vector txData(ParseHex(strHexTx)); + CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); + try { + ssData >> tx; + } + catch (std::exception &e) { + return false; + } + + return true; +} + -- cgit v1.2.3