common: Add PSBTError enum

Add separate PSBTError enum instead of reusing TransactionError enum for PSBT
operations, and drop unused error codes. The error codes returned by PSBT
operations and transaction broadcast functions mostly do not overlap, so using
an unified enum makes it harder to call any of these functions and know which
errors actually need to be handled.

Define PSBTError in the common library because PSBT functionality is
implemented in the common library and used by both the node (for rawtransaction
RPCs) and the wallet.
This commit is contained in:
Ryan Ofsky
2023-12-13 11:43:16 -05:00
parent 0d44c44ae3
commit 02e62c6c9a
25 changed files with 156 additions and 97 deletions

View File

@@ -30,9 +30,11 @@ class CFeeRate;
class CKey;
enum class FeeReason;
enum class OutputType;
enum class TransactionError;
struct PartiallySignedTransaction;
struct bilingual_str;
namespace common {
enum class PSBTError;
} // namespace common
namespace wallet {
class CCoinControl;
class CWallet;
@@ -202,7 +204,7 @@ public:
int& num_blocks) = 0;
//! Fill PSBT.
virtual TransactionError fillPSBT(int sighash_type,
virtual std::optional<common::PSBTError> fillPSBT(int sighash_type,
bool sign,
bool bip32derivs,
size_t* n_signed,