mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Consolidate CTransaction hex encode/decode into core_io.h, core_{read,write}.cpp
This commit is contained in:
25
src/core_read.cpp
Normal file
25
src/core_read.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#include <vector>
|
||||
#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<unsigned char> txData(ParseHex(strHexTx));
|
||||
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
|
||||
try {
|
||||
ssData >> tx;
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user