From dec14e44ac7475969cccc79274004c66b796e470 Mon Sep 17 00:00:00 2001 From: furszy Date: Thu, 21 Mar 2024 17:57:19 -0300 Subject: [PATCH] refactor: move CreatedTransactionResult to an util file --- src/Makefile.am | 1 + src/wallet/spend.h | 12 +----------- src/wallet/util_spend.h | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 src/wallet/util_spend.h diff --git a/src/Makefile.am b/src/Makefile.am index 1f55bfbafda..21df5ac72f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -358,6 +358,7 @@ BITCOIN_CORE_H = \ wallet/sqlite.h \ wallet/transaction.h \ wallet/types.h \ + wallet/util_spend.h \ wallet/wallet.h \ wallet/walletdb.h \ wallet/wallettool.h \ diff --git a/src/wallet/spend.h b/src/wallet/spend.h index 62a7b4e4c89..1f53bb86720 100644 --- a/src/wallet/spend.h +++ b/src/wallet/spend.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -202,17 +203,6 @@ util::Result 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 change_pos; - - CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional _change_pos, const FeeCalculation& _fee_calc) - : tx(_tx), fee(_fee), fee_calc(_fee_calc), change_pos(_change_pos) {} -}; - /** * Create a new transaction paying the recipients with a set of coins * selected by SelectCoins(); Also create the change output, when needed diff --git a/src/wallet/util_spend.h b/src/wallet/util_spend.h new file mode 100644 index 00000000000..bef4ac0b055 --- /dev/null +++ b/src/wallet/util_spend.h @@ -0,0 +1,24 @@ +// Copyright (c) 2024-present The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_WALLET_UTIL_SPEND_H +#define BITCOIN_WALLET_UTIL_SPEND_H + +#include +#include + +#include + +struct CreatedTransactionResult +{ + CTransactionRef tx; + CAmount fee; + FeeCalculation fee_calc; + std::optional change_pos; + + CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional _change_pos, const FeeCalculation& _fee_calc) + : tx(_tx), fee(_fee), fee_calc(_fee_calc), change_pos(_change_pos) {} +}; + +#endif // BITCOIN_WALLET_UTIL_SPEND_H