aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index d39bc9a780..42e2f8d200 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -4,6 +4,7 @@
#include "core_io.h"
+#include "core/block.h"
#include "core/transaction.h"
#include "script/script.h"
#include "serialize.h"
@@ -108,6 +109,23 @@ bool DecodeHexTx(CTransaction& tx, const std::string& strHexTx)
return true;
}
+bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)
+{
+ if (!IsHex(strHexBlk))
+ return false;
+
+ std::vector<unsigned char> blockData(ParseHex(strHexBlk));
+ CDataStream ssBlock(blockData, SER_NETWORK, PROTOCOL_VERSION);
+ try {
+ ssBlock >> block;
+ }
+ catch (const std::exception &) {
+ return false;
+ }
+
+ return true;
+}
+
uint256 ParseHashUV(const UniValue& v, const string& strName)
{
string strHex;