mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Remove unused TransactionError constants
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
const char* TransactionErrorString(const TransactionError err)
|
||||
std::string TransactionErrorString(const TransactionError err)
|
||||
{
|
||||
switch (err) {
|
||||
case TransactionError::OK:
|
||||
@@ -33,22 +33,16 @@ const char* TransactionErrorString(const TransactionError err)
|
||||
return "PSBTs not compatible (different transactions)";
|
||||
case TransactionError::SIGHASH_MISMATCH:
|
||||
return "Specified sighash value does not match existing value";
|
||||
|
||||
case TransactionError::UNKNOWN_ERROR:
|
||||
default: break;
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
return "Unknown error";
|
||||
assert(false);
|
||||
}
|
||||
|
||||
bool BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, TransactionError& error, std::string& err_string, const bool allowhighfees)
|
||||
TransactionError BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, std::string& err_string, const CAmount& highfee)
|
||||
{
|
||||
std::promise<void> promise;
|
||||
hashTx = tx->GetHash();
|
||||
|
||||
CAmount nMaxRawTxFee = maxTxFee;
|
||||
if (allowhighfees)
|
||||
nMaxRawTxFee = 0;
|
||||
|
||||
{ // cs_main scope
|
||||
LOCK(cs_main);
|
||||
CCoinsViewCache &view = *pcoinsTip;
|
||||
@@ -63,19 +57,16 @@ bool BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, Transaction
|
||||
CValidationState state;
|
||||
bool fMissingInputs;
|
||||
if (!AcceptToMemoryPool(mempool, state, std::move(tx), &fMissingInputs,
|
||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, nMaxRawTxFee)) {
|
||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, highfee)) {
|
||||
if (state.IsInvalid()) {
|
||||
err_string = FormatStateMessage(state);
|
||||
error = TransactionError::MEMPOOL_REJECTED;
|
||||
return false;
|
||||
return TransactionError::MEMPOOL_REJECTED;
|
||||
} else {
|
||||
if (fMissingInputs) {
|
||||
error = TransactionError::MISSING_INPUTS;
|
||||
return false;
|
||||
return TransactionError::MISSING_INPUTS;
|
||||
}
|
||||
err_string = FormatStateMessage(state);
|
||||
error = TransactionError::MEMPOOL_ERROR;
|
||||
return false;
|
||||
return TransactionError::MEMPOOL_ERROR;
|
||||
}
|
||||
} else {
|
||||
// If wallet is enabled, ensure that the wallet has been made aware
|
||||
@@ -88,8 +79,7 @@ bool BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, Transaction
|
||||
});
|
||||
}
|
||||
} else if (fHaveChain) {
|
||||
error = TransactionError::ALREADY_IN_CHAIN;
|
||||
return false;
|
||||
return TransactionError::ALREADY_IN_CHAIN;
|
||||
} else {
|
||||
// Make sure we don't block forever if re-sending
|
||||
// a transaction already in mempool.
|
||||
@@ -100,16 +90,14 @@ bool BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, Transaction
|
||||
|
||||
promise.get_future().wait();
|
||||
|
||||
if(!g_connman) {
|
||||
error = TransactionError::P2P_DISABLED;
|
||||
return false;
|
||||
if (!g_connman) {
|
||||
return TransactionError::P2P_DISABLED;
|
||||
}
|
||||
|
||||
CInv inv(MSG_TX, hashTx);
|
||||
g_connman->ForEachNode([&inv](CNode* pnode)
|
||||
{
|
||||
g_connman->ForEachNode([&inv](CNode* pnode) {
|
||||
pnode->PushInventory(inv);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return TransactionError::OK;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Copyright (c) 2017-2018 The Bitcoin Core developers
|
||||
// Copyright (c) 2017-2019 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_NODE_TRANSACTION_H
|
||||
#define BITCOIN_NODE_TRANSACTION_H
|
||||
|
||||
#include <attributes.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <uint256.h>
|
||||
|
||||
enum class TransactionError {
|
||||
OK = 0,
|
||||
UNKNOWN_ERROR,
|
||||
|
||||
OK, //!< No error
|
||||
MISSING_INPUTS,
|
||||
ALREADY_IN_CHAIN,
|
||||
P2P_DISABLED,
|
||||
@@ -20,24 +19,19 @@ enum class TransactionError {
|
||||
INVALID_PSBT,
|
||||
PSBT_MISMATCH,
|
||||
SIGHASH_MISMATCH,
|
||||
|
||||
ERROR_COUNT
|
||||
};
|
||||
|
||||
#define TRANSACTION_ERR_LAST TransactionError::ERROR_COUNT
|
||||
|
||||
const char* TransactionErrorString(const TransactionError error);
|
||||
std::string 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`)
|
||||
* @param[in] highfee Reject txs with fees higher than this (if 0, accept any fee)
|
||||
* return error
|
||||
*/
|
||||
bool BroadcastTransaction(CTransactionRef tx, uint256& txid, TransactionError& error, std::string& err_string, bool allowhighfees = false);
|
||||
NODISCARD TransactionError BroadcastTransaction(CTransactionRef tx, uint256& txid, std::string& err_string, const CAmount& highfee);
|
||||
|
||||
#endif // BITCOIN_NODE_TRANSACTION_H
|
||||
|
||||
Reference in New Issue
Block a user