Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show All 23 Lines | |||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
namespace interfaces { | namespace interfaces { | ||||
namespace { | namespace { | ||||
class PendingWalletTxImpl : public PendingWalletTx { | class PendingWalletTxImpl : public PendingWalletTx { | ||||
public: | public: | ||||
explicit PendingWalletTxImpl(CWallet &wallet) | explicit PendingWalletTxImpl(CWallet &wallet) | ||||
: m_wallet(wallet), m_key(&wallet) {} | : m_wallet(wallet), m_dest(&wallet) {} | ||||
const CTransaction &get() override { return *m_tx; } | const CTransaction &get() override { return *m_tx; } | ||||
bool commit(WalletValueMap value_map, WalletOrderForm order_form, | bool commit(WalletValueMap value_map, WalletOrderForm order_form, | ||||
std::string &reject_reason) override { | std::string &reject_reason) override { | ||||
auto locked_chain = m_wallet.chain().lock(); | auto locked_chain = m_wallet.chain().lock(); | ||||
LOCK(m_wallet.cs_wallet); | LOCK(m_wallet.cs_wallet); | ||||
CValidationState state; | CValidationState state; | ||||
if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), | if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), | ||||
std::move(order_form), m_key, | std::move(order_form), m_dest, | ||||
state)) { | state)) { | ||||
reject_reason = state.GetRejectReason(); | reject_reason = state.GetRejectReason(); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
CTransactionRef m_tx; | CTransactionRef m_tx; | ||||
CWallet &m_wallet; | CWallet &m_wallet; | ||||
CReserveKey m_key; | ReserveDestination m_dest; | ||||
}; | }; | ||||
//! Construct wallet tx struct. | //! Construct wallet tx struct. | ||||
static WalletTx MakeWalletTx(interfaces::Chain::Lock &locked_chain, | static WalletTx MakeWalletTx(interfaces::Chain::Lock &locked_chain, | ||||
CWallet &wallet, const CWalletTx &wtx) { | CWallet &wallet, const CWalletTx &wtx) { | ||||
WalletTx result; | WalletTx result; | ||||
result.tx = wtx.tx; | result.tx = wtx.tx; | ||||
result.txin_is_mine.reserve(wtx.tx->vin.size()); | result.txin_is_mine.reserve(wtx.tx->vin.size()); | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | public: | ||||
createTransaction(const std::vector<CRecipient> &recipients, | createTransaction(const std::vector<CRecipient> &recipients, | ||||
const CCoinControl &coin_control, bool sign, | const CCoinControl &coin_control, bool sign, | ||||
int &change_pos, Amount &fee, | int &change_pos, Amount &fee, | ||||
std::string &fail_reason) override { | std::string &fail_reason) override { | ||||
auto locked_chain = m_wallet->chain().lock(); | auto locked_chain = m_wallet->chain().lock(); | ||||
LOCK(m_wallet->cs_wallet); | LOCK(m_wallet->cs_wallet); | ||||
auto pending = std::make_unique<PendingWalletTxImpl>(*m_wallet); | auto pending = std::make_unique<PendingWalletTxImpl>(*m_wallet); | ||||
if (!m_wallet->CreateTransaction( | if (!m_wallet->CreateTransaction( | ||||
*locked_chain, recipients, pending->m_tx, pending->m_key, | *locked_chain, recipients, pending->m_tx, pending->m_dest, | ||||
fee, change_pos, fail_reason, coin_control, sign)) { | fee, change_pos, fail_reason, coin_control, sign)) { | ||||
return {}; | return {}; | ||||
} | } | ||||
return pending; | return pending; | ||||
} | } | ||||
bool transactionCanBeAbandoned(const TxId &txid) override { | bool transactionCanBeAbandoned(const TxId &txid) override { | ||||
return m_wallet->TransactionCanBeAbandoned(txid); | return m_wallet->TransactionCanBeAbandoned(txid); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 270 Lines • Show Last 20 Lines |