aboutsummaryrefslogtreecommitdiff
path: root/src/node/transaction.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/transaction.h')
-rw-r--r--src/node/transaction.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/node/transaction.h b/src/node/transaction.h
index 1916c6db26..83354d9400 100644
--- a/src/node/transaction.h
+++ b/src/node/transaction.h
@@ -8,7 +8,35 @@
#include <primitives/transaction.h>
#include <uint256.h>
-/** Broadcast a transaction */
-uint256 BroadcastTransaction(CTransactionRef tx, bool allowhighfees = false);
+enum class TransactionError {
+ OK = 0,
+ UNKNOWN_ERROR,
+
+ MISSING_INPUTS,
+ ALREADY_IN_CHAIN,
+ P2P_DISABLED,
+ MEMPOOL_REJECTED,
+ MEMPOOL_ERROR,
+ INVALID_PSBT,
+ SIGHASH_MISMATCH,
+
+ ERROR_COUNT
+};
+
+#define TRANSACTION_ERR_LAST TransactionError::ERROR_COUNT
+
+const char* TransactionErrorString(const TransactionError error);
+
+/**
+ * Broadcast a transaction
+ *
+ * @param[in] tx the transaction to broadcast
+ * @param[out] &txid the txid of the transaction, if successfully broadcast
+ * @param[out] &error reference to UniValue to fill with error info on failure
+ * @param[out] &err_string reference to std::string to fill with error string if available
+ * @param[in] allowhighfees whether to allow fees exceeding maxTxFee
+ * return true on success, false on error (and fills in `error`)
+ */
+bool BroadcastTransaction(CTransactionRef tx, uint256& txid, TransactionError& error, std::string& err_string, bool allowhighfees = false);
#endif // BITCOIN_NODE_TRANSACTION_H