Skip to content

Commit 4d05d3f

Browse files
committed
util: add TransactionError includes and namespace declarations
Add TransactionError to node namespace and include it directly instead of relying on indirect include through common/messages.h This is a followup to a previous commit which moved the TransactionError enum. These changes were done in a separate followup just to keep the previous commit more minimal and easy to review.
1 parent 680eafd commit 4d05d3f

26 files changed

+48
-8
lines changed

src/common/messages.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <common/types.h>
99
#include <policy/fees.h>
10+
#include <node/types.h>
1011
#include <tinyformat.h>
1112
#include <util/strencodings.h>
1213
#include <util/string.h>
@@ -18,6 +19,8 @@
1819
#include <utility>
1920
#include <vector>
2021

22+
using node::TransactionError;
23+
2124
namespace common {
2225
std::string StringForFeeReason(FeeReason reason)
2326
{

src/common/messages.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
#ifndef BITCOIN_COMMON_MESSAGES_H
1212
#define BITCOIN_COMMON_MESSAGES_H
1313

14-
#include <node/types.h>
1514
#include <string>
1615

1716
struct bilingual_str;
1817

1918
enum class FeeEstimateMode;
2019
enum class FeeReason;
20+
namespace node {
21+
enum class TransactionError;
22+
} // namespace node
2123

2224
namespace common {
2325
enum class PSBTError;
@@ -26,7 +28,7 @@ std::string StringForFeeReason(FeeReason reason);
2628
std::string FeeModes(const std::string& delimiter);
2729
std::string InvalidEstimateModeErrorMessage();
2830
bilingual_str PSBTErrorString(PSBTError error);
29-
bilingual_str TransactionErrorString(const TransactionError error);
31+
bilingual_str TransactionErrorString(const node::TransactionError error);
3032
bilingual_str ResolveErrMsg(const std::string& optname, const std::string& strBind);
3133
bilingual_str InvalidPortErrMsg(const std::string& optname, const std::string& strPort);
3234
bilingual_str AmountHighWarn(const std::string& optname);

src/interfaces/node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ class RPCTimerInterface;
3030
class UniValue;
3131
class Proxy;
3232
enum class SynchronizationState;
33-
enum class TransactionError;
3433
struct CNodeStateStats;
3534
struct bilingual_str;
3635
namespace node {
36+
enum class TransactionError;
3737
struct NodeContext;
3838
} // namespace node
3939
namespace wallet {
@@ -208,7 +208,7 @@ class Node
208208
virtual std::optional<Coin> getUnspentOutput(const COutPoint& output) = 0;
209209

210210
//! Broadcast transaction.
211-
virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;
211+
virtual node::TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string& err_string) = 0;
212212

213213
//! Get wallet loader.
214214
virtual WalletLoader& walletLoader() = 0;

src/interfaces/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct bilingual_str;
3535
namespace common {
3636
enum class PSBTError;
3737
} // namespace common
38+
namespace node {
39+
enum class TransactionError;
40+
} // namespace node
3841
namespace wallet {
3942
class CCoinControl;
4043
class CWallet;

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <node/interface_ui.h>
3232
#include <node/mini_miner.h>
3333
#include <node/transaction.h>
34+
#include <node/types.h>
3435
#include <policy/feerate.h>
3536
#include <policy/fees.h>
3637
#include <policy/policy.h>

src/node/transaction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <net_processing.h>
1010
#include <node/blockstorage.h>
1111
#include <node/context.h>
12+
#include <node/types.h>
1213
#include <txmempool.h>
1314
#include <validation.h>
1415
#include <validationinterface.h>

src/node/types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef BITCOIN_NODE_TYPES_H
1414
#define BITCOIN_NODE_TYPES_H
1515

16+
namespace node {
1617
enum class TransactionError {
1718
OK, //!< No error
1819
MISSING_INPUTS,
@@ -23,5 +24,6 @@ enum class TransactionError {
2324
MAX_BURN_EXCEEDED,
2425
INVALID_PACKAGE,
2526
};
27+
} // namespace node
2628

2729
#endif // BITCOIN_NODE_TYPES_H

src/psbt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
#include <psbt.h>
66

7+
#include <node/types.h>
78
#include <policy/policy.h>
89
#include <script/signingprovider.h>
910
#include <util/check.h>
1011
#include <util/strencodings.h>
1112

12-
1313
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
1414
{
1515
inputs.resize(tx.vin.size());

src/psbt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
#include <optional>
1919

20+
namespace node {
21+
enum class TransactionError;
22+
} // namespace node
23+
2024
// Magic bytes
2125
static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
2226

src/qt/psbtoperationsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <interfaces/node.h>
1010
#include <key_io.h>
1111
#include <node/psbt.h>
12+
#include <node/types.h>
1213
#include <policy/policy.h>
1314
#include <qt/bitcoinunits.h>
1415
#include <qt/forms/ui_psbtoperationsdialog.h>
@@ -25,6 +26,7 @@ using common::TransactionErrorString;
2526
using node::AnalyzePSBT;
2627
using node::DEFAULT_MAX_RAW_TX_FEE_RATE;
2728
using node::PSBTAnalysis;
29+
using node::TransactionError;
2830

2931
PSBTOperationsDialog::PSBTOperationsDialog(
3032
QWidget* parent, WalletModel* wallet_model, ClientModel* client_model) : QDialog(parent, GUIUtil::dialog_flags),

src/qt/sendcoinsdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <interfaces/node.h>
2121
#include <key_io.h>
2222
#include <node/interface_ui.h>
23+
#include <node/types.h>
2324
#include <policy/fees.h>
2425
#include <txmempool.h>
2526
#include <validation.h>

src/qt/walletmodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <interfaces/node.h>
2020
#include <key_io.h>
2121
#include <node/interface_ui.h>
22+
#include <node/types.h>
2223
#include <psbt.h>
2324
#include <util/translation.h>
2425
#include <wallet/coincontrol.h>

src/rpc/mempool.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <core_io.h>
1212
#include <kernel/mempool_entry.h>
1313
#include <node/mempool_persist_args.h>
14+
#include <node/types.h>
1415
#include <policy/rbf.h>
1516
#include <policy/settings.h>
1617
#include <primitives/transaction.h>
@@ -32,6 +33,7 @@ using node::DEFAULT_MAX_BURN_AMOUNT;
3233
using node::DEFAULT_MAX_RAW_TX_FEE_RATE;
3334
using node::MempoolPath;
3435
using node::NodeContext;
36+
using node::TransactionError;
3537

3638
static RPCHelpMan sendrawtransaction()
3739
{

src/rpc/rawtransaction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <node/context.h>
1717
#include <node/psbt.h>
1818
#include <node/transaction.h>
19+
#include <node/types.h>
1920
#include <policy/packages.h>
2021
#include <policy/policy.h>
2122
#include <policy/rbf.h>

src/rpc/util.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <consensus/amount.h>
1313
#include <script/interpreter.h>
1414
#include <key_io.h>
15+
#include <node/types.h>
1516
#include <outputtype.h>
1617
#include <rpc/util.h>
1718
#include <script/descriptor.h>
@@ -35,6 +36,7 @@
3536
using common::PSBTError;
3637
using common::PSBTErrorString;
3738
using common::TransactionErrorString;
39+
using node::TransactionError;
3840

3941
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
4042
const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};

src/rpc/util.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
class JSONRPCRequest;
3535
enum ServiceFlags : uint64_t;
3636
enum class OutputType;
37-
enum class TransactionError;
3837
struct FlatSigningProvider;
3938
struct bilingual_str;
4039
namespace common {
4140
enum class PSBTError;
4241
} // namespace common
42+
namespace node {
43+
enum class TransactionError;
44+
} // namespace node
4345

4446
static constexpr bool DEFAULT_RPC_DOC_CHECK{
4547
#ifdef RPC_DOC_CHECK
@@ -130,9 +132,9 @@ int ParseSighashString(const UniValue& sighash);
130132
//! Parse a confirm target option and raise an RPC error if it is invalid.
131133
unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target);
132134

133-
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr);
135+
RPCErrorCode RPCErrorFromTransactionError(node::TransactionError terr);
134136
UniValue JSONRPCPSBTError(common::PSBTError err);
135-
UniValue JSONRPCTransactionError(TransactionError terr, const std::string& err_string = "");
137+
UniValue JSONRPCTransactionError(node::TransactionError terr, const std::string& err_string = "");
136138

137139
//! Parse a JSON range specified as int64, or [int64, int64]
138140
std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);

src/test/fuzz/kitchen_sink.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <common/messages.h>
66
#include <merkleblock.h>
7+
#include <node/types.h>
78
#include <policy/fees.h>
89
#include <rpc/util.h>
910
#include <test/fuzz/FuzzedDataProvider.h>
@@ -17,6 +18,7 @@
1718
#include <vector>
1819

1920
using common::TransactionErrorString;
21+
using node::TransactionError;
2022

2123
namespace {
2224
constexpr TransactionError ALL_TRANSACTION_ERROR[] = {

src/wallet/external_signer_scriptpubkeyman.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <common/args.h>
77
#include <common/system.h>
88
#include <external_signer.h>
9+
#include <node/types.h>
910
#include <wallet/external_signer_scriptpubkeyman.h>
1011

1112
#include <iostream>

src/wallet/feebumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <common/system.h>
66
#include <consensus/validation.h>
77
#include <interfaces/chain.h>
8+
#include <node/types.h>
89
#include <policy/fees.h>
910
#include <policy/policy.h>
1011
#include <util/moneystr.h>

src/wallet/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <consensus/amount.h>
99
#include <interfaces/chain.h>
1010
#include <interfaces/handler.h>
11+
#include <node/types.h>
1112
#include <policy/fees.h>
1213
#include <primitives/transaction.h>
1314
#include <rpc/server.h>

src/wallet/rpc/spend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <consensus/validation.h>
77
#include <core_io.h>
88
#include <key_io.h>
9+
#include <node/types.h>
910
#include <policy/policy.h>
1011
#include <rpc/rawtransaction_util.h>
1112
#include <rpc/util.h>
@@ -27,6 +28,7 @@ using common::FeeModes;
2728
using common::InvalidEstimateModeErrorMessage;
2829
using common::StringForFeeReason;
2930
using common::TransactionErrorString;
31+
using node::TransactionError;
3032

3133
namespace wallet {
3234
std::vector<CRecipient> CreateRecipients(const std::vector<std::pair<CTxDestination, CAmount>>& outputs, const std::set<int>& subtract_fee_outputs)

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <hash.h>
66
#include <key_io.h>
77
#include <logging.h>
8+
#include <node/types.h>
89
#include <outputtype.h>
910
#include <script/descriptor.h>
1011
#include <script/script.h>

src/wallet/scriptpubkeyman.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <common/signmessage.h>
1111
#include <common/types.h>
1212
#include <logging.h>
13+
#include <node/types.h>
1314
#include <psbt.h>
1415
#include <script/descriptor.h>
1516
#include <script/script.h>

src/wallet/spend.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <consensus/amount.h>
1010
#include <consensus/validation.h>
1111
#include <interfaces/chain.h>
12+
#include <node/types.h>
1213
#include <numeric>
1314
#include <policy/policy.h>
1415
#include <primitives/transaction.h>
@@ -32,6 +33,7 @@
3233
using common::StringForFeeReason;
3334
using common::TransactionErrorString;
3435
using interfaces::FoundBlock;
36+
using node::TransactionError;
3537

3638
namespace wallet {
3739
static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100};

src/wallet/test/psbt_wallet_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <key_io.h>
6+
#include <node/types.h>
67
#include <util/bip32.h>
78
#include <util/strencodings.h>
89
#include <wallet/wallet.h>

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <key.h>
2828
#include <key_io.h>
2929
#include <logging.h>
30+
#include <node/types.h>
3031
#include <outputtype.h>
3132
#include <policy/feerate.h>
3233
#include <primitives/block.h>

0 commit comments

Comments
 (0)