Changeset View
Changeset View
Standalone View
Standalone View
src/core_read.cpp
Show First 20 Lines • Show All 224 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 DecodeBase64PSBT(PartiallySignedTransaction &psbt, | |||||
const std::string &base64_tx, std::string &error) { | |||||
bool invalid; | |||||
std::string tx_data = DecodeBase64(base64_tx, &invalid); | |||||
if (invalid) { | |||||
error = "invalid base64"; | |||||
return false; | |||||
} | |||||
return DecodeRawPSBT(psbt, tx_data, error); | |||||
} | |||||
bool DecodeRawPSBT(PartiallySignedTransaction &psbt, const std::string &tx_data, | |||||
std::string &error) { | |||||
CDataStream ss_data(tx_data.data(), tx_data.data() + tx_data.size(), | |||||
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; | |||||
} | |||||
bool ParseHashStr(const std::string &strHex, uint256 &result) { | bool ParseHashStr(const std::string &strHex, uint256 &result) { | ||||
if ((strHex.size() != 64) || !IsHex(strHex)) { | if ((strHex.size() != 64) || !IsHex(strHex)) { | ||||
return false; | return false; | ||||
} | } | ||||
result.SetHex(strHex); | result.SetHex(strHex); | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |