diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2019-07-18 12:06:23 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2019-07-18 12:06:23 -0400 |
commit | 4d94916f0dda535cb69b538ee4e3fffb5b033c87 (patch) | |
tree | 6999cb335efe0785b6635105c6649fa69031ad08 /src/interfaces/wallet.cpp | |
parent | e5abb59a9a66723dd1d9a01f65e467636eb24f2d (diff) |
Get rid of PendingWalletTx class.
No reason for this class to exist if it doesn't have any code to run in the
destructor. e10e1e8db043e9b7c113e07faf408f337c1b732d from
https://github.com/bitcoin/bitcoin/pull/16208 recently removed code destructor
code that would return an unused key if the transaction wasn't committed.
Diffstat (limited to 'src/interfaces/wallet.cpp')
-rw-r--r-- | src/interfaces/wallet.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index deb1618ceb..077dc1ab4d 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -33,31 +33,6 @@ namespace interfaces { namespace { -class PendingWalletTxImpl : public PendingWalletTx -{ -public: - explicit PendingWalletTxImpl(CWallet& wallet) : m_wallet(wallet) {} - - const CTransaction& get() override { return *m_tx; } - - bool commit(WalletValueMap value_map, - WalletOrderForm order_form, - std::string& reject_reason) override - { - auto locked_chain = m_wallet.chain().lock(); - LOCK(m_wallet.cs_wallet); - CValidationState state; - if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), state)) { - reject_reason = state.GetRejectReason(); - return false; - } - return true; - } - - CTransactionRef m_tx; - CWallet& m_wallet; -}; - //! Construct wallet tx struct. WalletTx MakeWalletTx(interfaces::Chain::Lock& locked_chain, CWallet& wallet, const CWalletTx& wtx) { @@ -227,7 +202,7 @@ public: LOCK(m_wallet->cs_wallet); return m_wallet->ListLockedCoins(outputs); } - std::unique_ptr<PendingWalletTx> createTransaction(const std::vector<CRecipient>& recipients, + CTransactionRef createTransaction(const std::vector<CRecipient>& recipients, const CCoinControl& coin_control, bool sign, int& change_pos, @@ -236,12 +211,26 @@ public: { auto locked_chain = m_wallet->chain().lock(); LOCK(m_wallet->cs_wallet); - auto pending = MakeUnique<PendingWalletTxImpl>(*m_wallet); - if (!m_wallet->CreateTransaction(*locked_chain, recipients, pending->m_tx, fee, change_pos, + CTransactionRef tx; + if (!m_wallet->CreateTransaction(*locked_chain, recipients, tx, fee, change_pos, fail_reason, coin_control, sign)) { return {}; } - return std::move(pending); + return tx; + } + bool commitTransaction(CTransactionRef tx, + WalletValueMap value_map, + WalletOrderForm order_form, + std::string& reject_reason) override + { + auto locked_chain = m_wallet->chain().lock(); + LOCK(m_wallet->cs_wallet); + CValidationState state; + if (!m_wallet->CommitTransaction(std::move(tx), std::move(value_map), std::move(order_form), state)) { + reject_reason = state.GetRejectReason(); + return false; + } + return true; } bool transactionCanBeAbandoned(const uint256& txid) override { return m_wallet->TransactionCanBeAbandoned(txid); } bool abandonTransaction(const uint256& txid) override |