diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-04-18 13:01:23 -0400 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2018-04-04 16:52:40 -0400 |
commit | 3ec2ebcd9b4beb4277f1f4791c6acbc538784f70 (patch) | |
tree | c86c3c7b5d346e6f2460426de31f753b949dd3e3 /src/interface | |
parent | 827de038ab6fa58aa3d46151eb2f8dc6add7743e (diff) | |
download | bitcoin-3ec2ebcd9b4beb4277f1f4791c6acbc538784f70.tar.xz |
Remove direct bitcoin calls from qt/addresstablemodel.cpp
Diffstat (limited to 'src/interface')
-rw-r--r-- | src/interface/wallet.cpp | 18 | ||||
-rw-r--r-- | src/interface/wallet.h | 29 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/interface/wallet.cpp b/src/interface/wallet.cpp index cbf30f49bc..efc9946fb6 100644 --- a/src/interface/wallet.cpp +++ b/src/interface/wallet.cpp @@ -85,6 +85,10 @@ public: } bool backupWallet(const std::string& filename) override { return m_wallet.BackupWallet(filename); } std::string getWalletName() override { return m_wallet.GetName(); } + bool getKeyFromPool(bool internal, CPubKey& pub_key) override + { + return m_wallet.GetKeyFromPool(pub_key, internal); + } bool getPubKey(const CKeyID& address, CPubKey& pub_key) override { return m_wallet.GetPubKey(address, pub_key); } bool getPrivKey(const CKeyID& address, CKey& key) override { return m_wallet.GetKey(address, key); } bool isSpendable(const CTxDestination& dest) override { return IsMine(m_wallet, dest) & ISMINE_SPENDABLE; } @@ -93,6 +97,10 @@ public: { return m_wallet.SetAddressBook(dest, name, purpose); } + bool delAddressBook(const CTxDestination& dest) override + { + return m_wallet.DelAddressBook(dest); + } bool getAddress(const CTxDestination& dest, std::string* name, isminetype* is_mine) override { LOCK(m_wallet.cs_wallet); @@ -108,6 +116,16 @@ public: } return true; } + std::vector<WalletAddress> getAddresses() override + { + LOCK(m_wallet.cs_wallet); + std::vector<WalletAddress> result; + for (const auto& item : m_wallet.mapAddressBook) { + result.emplace_back(item.first, IsMine(m_wallet, item.first), item.second.name, item.second.purpose); + } + return result; + } + void learnRelatedScripts(const CPubKey& key, OutputType type) override { m_wallet.LearnRelatedScripts(key, type); } bool addDestData(const CTxDestination& dest, const std::string& key, const std::string& value) override { LOCK(m_wallet.cs_wallet); diff --git a/src/interface/wallet.h b/src/interface/wallet.h index 6cc196fd94..4510276446 100644 --- a/src/interface/wallet.h +++ b/src/interface/wallet.h @@ -6,6 +6,7 @@ #define BITCOIN_INTERFACE_WALLET_H #include <amount.h> // For CAmount +#include <pubkey.h> // For CTxDestination (CKeyID and CScriptID) #include <script/ismine.h> // For isminefilter, isminetype #include <script/standard.h> // For CTxDestination #include <support/allocators/secure.h> // For SecureString @@ -30,6 +31,7 @@ namespace interface { class Handler; class PendingWalletTx; +struct WalletAddress; struct WalletBalances; struct WalletTxOut; @@ -67,6 +69,9 @@ public: //! Get wallet name. virtual std::string getWalletName() = 0; + // Get key from pool. + virtual bool getKeyFromPool(bool internal, CPubKey& pub_key) = 0; + //! Get public key. virtual bool getPubKey(const CKeyID& address, CPubKey& pub_key) = 0; @@ -82,11 +87,21 @@ public: //! Add or update address. virtual bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::string& purpose) = 0; + // Remove address. + virtual bool delAddressBook(const CTxDestination& dest) = 0; + //! Look up address in wallet, return whether exists. virtual bool getAddress(const CTxDestination& dest, std::string* name = nullptr, isminetype* is_mine = nullptr) = 0; + //! Get wallet address list. + virtual std::vector<WalletAddress> getAddresses() = 0; + + //! Add scripts to key store so old so software versions opening the wallet + //! database can detect payments to newer address types. + virtual void learnRelatedScripts(const CPubKey& key, OutputType type) = 0; + //! Add dest data. virtual bool addDestData(const CTxDestination& dest, const std::string& key, const std::string& value) = 0; @@ -216,6 +231,20 @@ public: std::string& reject_reason) = 0; }; +//! Information about one wallet address. +struct WalletAddress +{ + CTxDestination dest; + isminetype is_mine; + std::string name; + std::string purpose; + + WalletAddress(CTxDestination dest, isminetype is_mine, std::string name, std::string purpose) + : dest(std::move(dest)), is_mine(is_mine), name(std::move(name)), purpose(std::move(purpose)) + { + } +}; + //! Collection of wallet balances. struct WalletBalances { |