From 522934703a7c23e39c064a04fd09586dbb146f12 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Tue, 29 Jan 2019 21:32:38 -0800 Subject: [PATCH] merge #14978: Factor out PSBT utilities from RPCs for use in GUI code; related refactoring --- src/Makefile.am | 4 + src/core_io.h | 6 +- src/core_read.cpp | 17 +- src/node/transaction.cpp | 60 ++- src/node/transaction.h | 33 +- src/psbt.cpp | 240 ++++++++++++ src/psbt.h | 506 ++++++++++++++++++++++++++ src/rpc/rawtransaction.cpp | 56 +-- src/rpc/util.cpp | 29 ++ src/rpc/util.h | 5 + src/script/sign.cpp | 177 --------- src/script/sign.h | 480 ------------------------ src/wallet/psbtwallet.cpp | 50 +++ src/wallet/psbtwallet.h | 36 ++ src/wallet/rpcwallet.cpp | 59 +-- src/wallet/rpcwallet.h | 1 - src/wallet/test/psbt_wallet_tests.cpp | 5 +- test/functional/rpc_psbt.py | 3 + 18 files changed, 1016 insertions(+), 751 deletions(-) create mode 100644 src/psbt.cpp create mode 100644 src/psbt.h create mode 100644 src/wallet/psbtwallet.cpp create mode 100644 src/wallet/psbtwallet.h diff --git a/src/Makefile.am b/src/Makefile.am index c356a985d3e91..b97e05c15a463 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -227,6 +227,7 @@ BITCOIN_CORE_H = \ policy/policy.h \ pow.h \ protocol.h \ + psbt.h \ random.h \ reverse_iterator.h \ reverselock.h \ @@ -291,6 +292,7 @@ BITCOIN_CORE_H = \ wallet/crypter.h \ wallet/db.h \ wallet/fees.h \ + wallet/psbtwallet.h \ wallet/rpcwallet.h \ wallet/wallet.h \ wallet/walletdb.h \ @@ -431,6 +433,7 @@ libdash_wallet_a_SOURCES = \ wallet/db.cpp \ wallet/fees.cpp \ wallet/init.cpp \ + wallet/psbtwallet.cpp \ wallet/rpcdump.cpp \ wallet/rpcwallet.cpp \ wallet/wallet.cpp \ @@ -577,6 +580,7 @@ libdash_common_a_SOURCES = \ netbase.cpp \ net_permissions.cpp \ policy/feerate.cpp \ + psbt.cpp \ protocol.cpp \ saltedhasher.cpp \ scheduler.cpp \ diff --git a/src/core_io.h b/src/core_io.h index 863b0b98c4f11..82a4cfe4fda14 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -28,9 +28,13 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk); uint256 ParseHashStr(const std::string&, const std::string& strName); std::vector ParseHexUV(const UniValue& v, const std::string& strName); -bool DecodePSBT(PartiallySignedTransaction& psbt, const std::string& base64_tx, std::string& error); int ParseSighashString(const UniValue& sighash); +//! 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); + // core_write.cpp UniValue ValueFromAmount(const CAmount& amount); std::string FormatScript(const CScript& script); diff --git a/src/core_read.cpp b/src/core_read.cpp index a98e9e046a3df..68d28d8654019 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include