Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | static WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, | ||||
result.time = wtx.GetTxTime(); | result.time = wtx.GetTxTime(); | ||||
result.depth_in_main_chain = depth; | result.depth_in_main_chain = depth; | ||||
result.is_spent = wallet.IsSpent(COutPoint(wtx.GetId(), n)); | result.is_spent = wallet.IsSpent(COutPoint(wtx.GetId(), n)); | ||||
return result; | return result; | ||||
} | } | ||||
class WalletImpl : public Wallet { | class WalletImpl : public Wallet { | ||||
public: | public: | ||||
WalletImpl(CWallet &wallet) : m_wallet(wallet) {} | WalletImpl(const std::shared_ptr<CWallet> &wallet) | ||||
: m_shared_wallet(wallet), m_wallet(*wallet.get()) {} | |||||
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(); } | ||||
bool lock() override { return m_wallet.Lock(); } | bool lock() override { return m_wallet.Lock(); } | ||||
bool unlock(const SecureString &wallet_passphrase) override { | bool unlock(const SecureString &wallet_passphrase) override { | ||||
return m_wallet.Unlock(wallet_passphrase); | return m_wallet.Unlock(wallet_passphrase); | ||||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | public: | ||||
Amount getRequiredFee(unsigned int tx_bytes) override { | Amount getRequiredFee(unsigned int tx_bytes) override { | ||||
return GetRequiredFee(m_wallet, tx_bytes); | return GetRequiredFee(m_wallet, tx_bytes); | ||||
} | } | ||||
Amount getMinimumFee(unsigned int tx_bytes, | Amount getMinimumFee(unsigned int tx_bytes, | ||||
const CCoinControl &coin_control) override { | const CCoinControl &coin_control) override { | ||||
return GetMinimumFee(m_wallet, tx_bytes, coin_control, g_mempool); | return GetMinimumFee(m_wallet, tx_bytes, coin_control, g_mempool); | ||||
} | } | ||||
std::shared_ptr<CWallet> m_shared_wallet; | |||||
CWallet &m_wallet; | CWallet &m_wallet; | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
std::unique_ptr<Wallet> MakeWallet(CWallet &wallet) { | std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet> &wallet) { | ||||
return std::make_unique<WalletImpl>(wallet); | return std::make_unique<WalletImpl>(wallet); | ||||
} | } | ||||
} // namespace interfaces | } // namespace interfaces |