mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
Merge #14978: Factor out PSBT utilities from RPCs for use in GUI code; related refactoring.
102faad81Factor out combine / finalize / extract PSBT helpers (Glenn Willen)78b9893d0Remove op== on PSBTs; check compatibility in Merge (Glenn Willen)bd0dbe876Switch away from exceptions in refactored tx code (Glenn Willen)c6c3d42a7Move PSBT definitions and code to separate files (Glenn Willen)81cd95884Factor BroadcastTransaction out of sendrawtransaction (Glenn Willen)c734aaa15Split DecodePSBT into Base64 and Raw versions (Glenn Willen)162ffefd2Add pf_invalid arg to std::string DecodeBase{32,64} (Glenn Willen) Pull request description: * Move most PSBT definitions into psbt.h. * Move most PSBT RPC utilities into psbt.{h,cpp}. * Move wallet-touching PSBT RPC utilities (FillPSBT) into wallet/psbtwallet.{h,cpp}. * Switch exceptions from JSONRPCError() to new PSBTException class. * Split DecodePSBT into DecodeBase64PSBT (old behavior) and DecodeRawPSBT. * Add one new version of DecodeBase64 utility in strencodings.h (and corresponding DecodeBase32 for completeness). * Factor BroadcastTransaction utility function out of sendrawtransaction RPC handler in rpc/rawtransaction.cpp Note: For those keeping score at home wondering why refactor, this is in anticipation of (and developed in parallel with) a change to actually introduce GUI use of all this stuff, which is already under development and working-ish. Tree-SHA512: 2197c448e657421f430943025357597e7b06c4c377d5d4b2622b9edea52a7193c48843dd731abb3a88ac4023a9c88d211991e0a9b740c22f2e1cbe72adefe390
This commit is contained in:
@@ -141,7 +141,7 @@ std::string EncodeBase64(const std::string& str)
|
||||
return EncodeBase64((const unsigned char*)str.c_str(), str.size());
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
|
||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid)
|
||||
{
|
||||
static const int decode64_table[256] =
|
||||
{
|
||||
@@ -183,14 +183,14 @@ std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
|
||||
++p;
|
||||
}
|
||||
valid = valid && (p - e) % 4 == 0 && p - q < 4;
|
||||
if (pfInvalid) *pfInvalid = !valid;
|
||||
if (pf_invalid) *pf_invalid = !valid;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string DecodeBase64(const std::string& str)
|
||||
std::string DecodeBase64(const std::string& str, bool* pf_invalid)
|
||||
{
|
||||
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str());
|
||||
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str(), pf_invalid);
|
||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ std::string EncodeBase32(const std::string& str)
|
||||
return EncodeBase32((const unsigned char*)str.c_str(), str.size());
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
|
||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid)
|
||||
{
|
||||
static const int decode32_table[256] =
|
||||
{
|
||||
@@ -252,14 +252,14 @@ std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
|
||||
++p;
|
||||
}
|
||||
valid = valid && (p - e) % 8 == 0 && p - q < 8;
|
||||
if (pfInvalid) *pfInvalid = !valid;
|
||||
if (pf_invalid) *pf_invalid = !valid;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string DecodeBase32(const std::string& str)
|
||||
std::string DecodeBase32(const std::string& str, bool* pf_invalid)
|
||||
{
|
||||
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str());
|
||||
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str(), pf_invalid);
|
||||
return std::string((const char*)vchRet.data(), vchRet.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ bool IsHex(const std::string& str);
|
||||
* Return true if the string is a hex number, optionally prefixed with "0x"
|
||||
*/
|
||||
bool IsHexNumber(const std::string& str);
|
||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid = nullptr);
|
||||
std::string DecodeBase64(const std::string& str);
|
||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pf_invalid = nullptr);
|
||||
std::string DecodeBase64(const std::string& str, bool* pf_invalid = nullptr);
|
||||
std::string EncodeBase64(const unsigned char* pch, size_t len);
|
||||
std::string EncodeBase64(const std::string& str);
|
||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid = nullptr);
|
||||
std::string DecodeBase32(const std::string& str);
|
||||
std::vector<unsigned char> DecodeBase32(const char* p, bool* pf_invalid = nullptr);
|
||||
std::string DecodeBase32(const std::string& str, bool* pf_invalid = nullptr);
|
||||
std::string EncodeBase32(const unsigned char* pch, size_t len);
|
||||
std::string EncodeBase32(const std::string& str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user