diff --git a/src/core_io.h b/src/core_io.h --- a/src/core_io.h +++ b/src/core_io.h @@ -17,7 +17,6 @@ class CMutableTransaction; class CScript; class CTransaction; -struct PartiallySignedTransaction; class uint256; class UniValue; @@ -40,13 +39,6 @@ */ bool ParseHashStr(const std::string &strHex, uint256 &result); std::vector ParseHexUV(const UniValue &v, const std::string &strName); -//! Decode a base64ed PSBT into a PartiallySignedTransaction -NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, - const std::string &base64_psbt, - std::string &error); -//! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction -NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, - const std::string &raw_psbt, std::string &error); SigHashType ParseSighashString(const UniValue &sighash); // core_write.cpp diff --git a/src/core_read.cpp b/src/core_read.cpp --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -230,34 +230,6 @@ 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) { if ((strHex.size() != 64) || !IsHex(strHex)) { return false; diff --git a/src/psbt.h b/src/psbt.h --- a/src/psbt.h +++ b/src/psbt.h @@ -527,4 +527,12 @@ CombinePSBTs(PartiallySignedTransaction &out, const std::vector &psbtxs); +//! Decode a base64ed PSBT into a PartiallySignedTransaction +NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, + const std::string &base64_psbt, + std::string &error); +//! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction +NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, + const std::string &raw_psbt, std::string &error); + #endif // BITCOIN_PSBT_H diff --git a/src/psbt.cpp b/src/psbt.cpp --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -272,3 +272,31 @@ return TransactionError::OK; } + +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; +} diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -39,7 +39,6 @@ "script/scriptcache -> validation -> script/scriptcache" "seeder/bitcoin -> seeder/db -> seeder/bitcoin" "chainparams -> protocol -> config -> chainparams" - "core_io -> psbt -> node/transaction -> validation -> core_io" ) EXIT_CODE=0