mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Remove direct bitcoin calls from qt/coincontroldialog.cpp
This commit is contained in:
parent
a0704a8996
commit
827de038ab
7 changed files with 140 additions and 70 deletions
|
|
@ -54,6 +54,17 @@ public:
|
|||
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.GetHash(), n);
|
||||
return result;
|
||||
}
|
||||
|
||||
class WalletImpl : public Wallet
|
||||
{
|
||||
public:
|
||||
|
|
@ -207,6 +218,36 @@ public:
|
|||
{
|
||||
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->GetHash(), 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.hash);
|
||||
if (it != m_wallet.mapWallet.end()) {
|
||||
int depth = it->second.GetDepthInMainChain();
|
||||
if (depth >= 0) {
|
||||
result.back() = MakeWalletTxOut(m_wallet, it->second, output.n, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool hdEnabled() override { return m_wallet.IsHDEnabled(); }
|
||||
OutputType getDefaultAddressType() override { return m_wallet.m_default_address_type; }
|
||||
OutputType getDefaultChangeType() override { return m_wallet.m_default_change_type; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue