refactor: move CreatedTransactionResult to types.h
What changed, and why it matters
This commit is a simple code reorganization: it moves a data structure called CreatedTransactionResult from one internal header file to another so other parts of the codebase can use it without pulling in the entire wallet header. There is no change to behavior, no bug fix, and no security-related content.
No security action needed. Treat as ordinary refactoring during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch relocates the CreatedTransactionResult struct from src/wallet/spend.h to src/wallet/types.h, placing it inside the wallet namespace. spend.h now includes types.h instead of defining the struct locally. types.h gains an include for block_policy_estimator.h (needed for FeeCalculation) and drops the unused
Changed components
src/wallet/spend.hsrc/wallet/types.hInspect captured patch +14 / −12
diff --git a/src/wallet/spend.h b/src/wallet/spend.h
index 75090b30..925111dc 100644
--- a/src/wallet/spend.h
+++ b/src/wallet/spend.h
@@ -10,6 +10,7 @@
#include <util/result.h>
#include <wallet/coinselection.h>
#include <wallet/transaction.h>
+#include <wallet/types.h>
#include <wallet/wallet.h>
#include <map>
@@ -186,17 +187,6 @@ util::Result<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& av
const CAmount& nTargetValue, const CCoinControl& coin_control,
const CoinSelectionParams& coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
-struct CreatedTransactionResult
-{
- CTransactionRef tx;
- CAmount fee;
- FeeCalculation fee_calc;
- std::optional<unsigned int> change_pos;
-
- CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional<unsigned int> _change_pos, const FeeCalculation& _fee_calc)
- : tx(_tx), fee(_fee), fee_calc(_fee_calc), change_pos(_change_pos) {}
-};
-
/**
* Set a height-based locktime for new transactions (uses the height of the
* current chain tip unless we are not synced with the current chain
diff --git a/src/wallet/types.h b/src/wallet/types.h
index 97c18d4f..09ad4a0a 100644
--- a/src/wallet/types.h
+++ b/src/wallet/types.h
@@ -14,7 +14,7 @@
#ifndef BITCOIN_WALLET_TYPES_H
#define BITCOIN_WALLET_TYPES_H
-#include <type_traits>
+#include <policy/fees/block_policy_estimator.h>
namespace wallet {
/**
@@ -30,6 +30,18 @@ enum class AddressPurpose {
SEND,
REFUND, //!< Never set in current code may be present in older wallet databases
};
+
+struct CreatedTransactionResult
+{
+ CTransactionRef tx;
+ CAmount fee;
+ FeeCalculation fee_calc;
+ std::optional<unsigned int> change_pos;
+
+ CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional<unsigned int> _change_pos, const FeeCalculation& _fee_calc)
+ : tx(_tx), fee(_fee), fee_calc(_fee_calc), change_pos(_change_pos) {}
+};
+
} // namespace wallet
#endif // BITCOIN_WALLET_TYPES_H
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.