aboutsummaryrefslogtreecommitdiff
path: root/src/util/error.h
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2019-04-02 17:03:37 -0400
committerJohn Newbery <john@johnnewbery.com>2019-04-09 17:53:08 -0400
commit91a25d1e711bfc0617027eee18b9777ff368d6b9 (patch)
treeaf7b5dbb366b9f9aac68ecf668f330d180bc31f4 /src/util/error.h
parent99517866b62c261f990e1f897502855afc12f2a7 (diff)
downloadbitcoin-91a25d1e711bfc0617027eee18b9777ff368d6b9.tar.xz
[build] Add several util units
Adds the following util units and adds them to libbitcoin_util: - `util/url.cpp` takes `urlDecode` from `httpserver.cpp` - `util/error.cpp` takes `TransactionErrorString` from `node/transaction.cpp` and `AmountHighWarn` and `AmountErrMsg` from `ui_interface.cpp` - `util/fees.cpp` takes `StringForFeeReason` and `FeeModeFromString` from `policy/fees.cpp` - `util/rbf.cpp` takes `SignalsOptInRBF` from `policy/rbf.cpp` - 'util/validation.cpp` takes `FormatStateMessage` and `strMessageMagic` from 'validation.cpp`
Diffstat (limited to 'src/util/error.h')
-rw-r--r--src/util/error.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/util/error.h b/src/util/error.h
new file mode 100644
index 0000000000..d93309551b
--- /dev/null
+++ b/src/util/error.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2010-2018 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_UTIL_ERROR_H
+#define BITCOIN_UTIL_ERROR_H
+
+/**
+ * util/error.h is a common place for definitions of simple error types and
+ * string functions. Types and functions defined here should not require any
+ * outside dependencies.
+ *
+ * Error types defined here can be used in different parts of the bitcoin
+ * codebase, to avoid the need to write boilerplate code catching and
+ * translating errors passed across wallet/node/rpc/gui code boundaries.
+ */
+
+#include <string>
+
+enum class TransactionError {
+ OK, //!< No error
+ MISSING_INPUTS,
+ ALREADY_IN_CHAIN,
+ P2P_DISABLED,
+ MEMPOOL_REJECTED,
+ MEMPOOL_ERROR,
+ INVALID_PSBT,
+ PSBT_MISMATCH,
+ SIGHASH_MISMATCH,
+};
+
+std::string TransactionErrorString(const TransactionError error);
+
+std::string AmountHighWarn(const std::string& optname);
+
+std::string AmountErrMsg(const char* const optname, const std::string& strValue);
+
+#endif // BITCOIN_UTIL_ERROR_H