Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public: | ||||
return true; | return true; | ||||
} | } | ||||
CTransactionRef m_tx; | CTransactionRef m_tx; | ||||
CWallet &m_wallet; | CWallet &m_wallet; | ||||
CReserveKey m_key; | CReserveKey m_key; | ||||
}; | }; | ||||
//! Construct wallet TxOut struct. | |||||
WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, int n, | |||||
int depth) { | |||||
WalletTxOut result; | |||||
result.txout = wtx.tx->vout[n]; | |||||
result.time = wtx.GetTxTime(); | |||||
result.depth_in_main_chain = depth; | |||||
result.is_spent = wallet.IsSpent(wtx.GetId(), n); | |||||
return result; | |||||
} | |||||
class WalletImpl : public Wallet { | class WalletImpl : public Wallet { | ||||
public: | public: | ||||
WalletImpl(CWallet &wallet) : m_wallet(wallet) {} | WalletImpl(CWallet &wallet) : m_wallet(wallet) {} | ||||
bool encryptWallet(const SecureString &wallet_passphrase) override { | bool encryptWallet(const SecureString &wallet_passphrase) override { | ||||
return m_wallet.EncryptWallet(wallet_passphrase); | return m_wallet.EncryptWallet(wallet_passphrase); | ||||
} | } | ||||
bool isCrypted() override { return m_wallet.IsCrypted(); } | bool isCrypted() override { return m_wallet.IsCrypted(); } | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | public: | ||||
balances = getBalances(); | balances = getBalances(); | ||||
num_blocks = ::chainActive.Height(); | num_blocks = ::chainActive.Height(); | ||||
return true; | return true; | ||||
} | } | ||||
Amount getBalance() override { return m_wallet.GetBalance(); } | Amount getBalance() override { return m_wallet.GetBalance(); } | ||||
Amount getAvailableBalance(const CCoinControl &coin_control) override { | Amount getAvailableBalance(const CCoinControl &coin_control) override { | ||||
return m_wallet.GetAvailableBalance(&coin_control); | return m_wallet.GetAvailableBalance(&coin_control); | ||||
} | } | ||||
CoinsList listCoins() override { | |||||
LOCK2(::cs_main, m_wallet.cs_wallet); | |||||
CoinsList result; | |||||
for (const auto &entry : m_wallet.ListCoins()) { | |||||
auto &group = result[entry.first]; | |||||
for (const auto &coin : entry.second) { | |||||
group.emplace_back(COutPoint(coin.tx->GetId(), coin.i), | |||||
MakeWalletTxOut(m_wallet, *coin.tx, | |||||
coin.i, coin.nDepth)); | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
std::vector<WalletTxOut> | |||||
getCoins(const std::vector<COutPoint> &outputs) override { | |||||
LOCK2(::cs_main, m_wallet.cs_wallet); | |||||
std::vector<WalletTxOut> result; | |||||
result.reserve(outputs.size()); | |||||
for (const auto &output : outputs) { | |||||
result.emplace_back(); | |||||
auto it = m_wallet.mapWallet.find(output.GetTxId()); | |||||
if (it != m_wallet.mapWallet.end()) { | |||||
int depth = it->second.GetDepthInMainChain(); | |||||
if (depth >= 0) { | |||||
result.back() = MakeWalletTxOut(m_wallet, it->second, | |||||
output.GetN(), depth); | |||||
} | |||||
} | |||||
} | |||||
return result; | |||||
} | |||||
bool hdEnabled() override { return m_wallet.IsHDEnabled(); } | bool hdEnabled() override { return m_wallet.IsHDEnabled(); } | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleShowProgress(ShowProgressFn fn) override { | handleShowProgress(ShowProgressFn fn) override { | ||||
return MakeHandler(m_wallet.ShowProgress.connect(fn)); | return MakeHandler(m_wallet.ShowProgress.connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleStatusChanged(StatusChangedFn fn) override { | handleStatusChanged(StatusChangedFn fn) override { | ||||
return MakeHandler(m_wallet.NotifyStatusChanged.connect( | return MakeHandler(m_wallet.NotifyStatusChanged.connect( | ||||
Show All 33 Lines |