Skip to content

Commit

Permalink
refactor: move CreatedTransactionResult to an util file
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Mar 22, 2024
1 parent 786e3c5 commit dec14e4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
12 changes: 1 addition & 11 deletions src/wallet/spend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <util/result.h>
#include <wallet/coinselection.h>
#include <wallet/transaction.h>
#include <wallet/util_spend.h>
#include <wallet/wallet.h>

#include <optional>
Expand Down Expand Up @@ -202,17 +203,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) {}
};

/**
* Create a new transaction paying the recipients with a set of coins
* selected by SelectCoins(); Also create the change output, when needed
Expand Down
24 changes: 24 additions & 0 deletions src/wallet/util_spend.h
Original file line number Diff line number Diff line change
@@ -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 <policy/fees.h>
#include <wallet/transaction.h>

#include <optional>

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) {}
};

#endif // BITCOIN_WALLET_UTIL_SPEND_H

0 comments on commit dec14e4

Please sign in to comment.