Changeset View
Changeset View
Standalone View
Standalone View
src/core_read.cpp
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <core_io.h> | #include <core_io.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/sign.h> | |||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <version.h> | #include <version.h> | ||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/predicate.hpp> | #include <boost/algorithm/string/predicate.hpp> | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | try { | ||||
ssBlock >> block; | ssBlock >> block; | ||||
} catch (const std::exception &) { | } catch (const std::exception &) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool DecodePSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, | |||||
std::string &error) { | |||||
std::vector<uint8_t> tx_data = DecodeBase64(base64_tx.c_str()); | |||||
CDataStream ss_data(tx_data, SER_NETWORK, PROTOCOL_VERSION); | |||||
try { | |||||
ss_data >> psbt; | |||||
if (!ss_data.empty()) { | |||||
error = "extra data after PSBT"; | |||||
return false; | |||||
} | |||||
} catch (const std::exception &e) { | |||||
error = e.what(); | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
uint256 ParseHashStr(const std::string &strHex, const std::string &strName) { | uint256 ParseHashStr(const std::string &strHex, const std::string &strName) { | ||||
if (!IsHex(strHex)) { | if (!IsHex(strHex)) { | ||||
// Note: IsHex("") is false | // Note: IsHex("") is false | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
strName + " must be hexadecimal string (not '" + strHex + "')"); | strName + " must be hexadecimal string (not '" + strHex + "')"); | ||||
} | } | ||||
uint256 result; | uint256 result; | ||||
Show All 17 Lines |