39 #include <boost/thread/mutex.hpp> 40 #include <boost/thread/thread.hpp> 41 #include <boost/thread/condition_variable.hpp> 45 class TransactionHistoryImpl;
46 class PendingTransactionImpl;
47 class UnsignedTransactionImpl;
48 class AddressBookImpl;
50 class SubaddressAccountImpl;
51 struct Wallet2CallbackImpl;
89 int status()
const override;
118 bool synchronized()
const override;
147 bool finalizeMultisig(
const std::vector<std::string>& extraMultisigInfo)
override;
157 std::set<uint32_t> subaddr_indices = {})
override;
165 virtual TransactionHistory *
history()
override;
169 virtual void setListener(WalletListener * l)
override;
192 virtual bool blackballOutputs(
const std::vector<std::string> &outputs,
bool add)
override;
207 void clearStatus()
const;
211 void refreshThreadFunc();
213 bool daemonSynced()
const;
215 bool isNewWallet()
const;
228 std::unique_ptr<tools::wallet2> m_wallet;
229 mutable boost::mutex m_statusMutex;
230 mutable int m_status;
233 std::unique_ptr<TransactionHistoryImpl> m_history;
234 std::unique_ptr<Wallet2CallbackImpl> m_wallet2Callback;
235 std::unique_ptr<AddressBookImpl> m_addressBook;
236 std::unique_ptr<SubaddressImpl> m_subaddress;
237 std::unique_ptr<SubaddressAccountImpl> m_subaddressAccount;
240 std::atomic<bool> m_refreshEnabled;
241 std::atomic<bool> m_refreshThreadDone;
242 std::atomic<int> m_refreshIntervalMillis;
243 std::atomic<bool> m_refreshShouldRescan;
245 boost::mutex m_refreshMutex;
248 boost::mutex m_refreshMutex2;
249 boost::condition_variable m_refreshCV;
250 boost::thread m_refreshThread;
254 std::atomic<bool> m_recoveringFromSeed;
255 std::atomic<bool> m_recoveringFromDevice;
256 std::atomic<bool> m_synchronized;
257 std::atomic<bool> m_rebuildWalletCache;
259 mutable std::atomic<bool> m_is_connected;
260 boost::optional<epee::net_utils::http::login> m_daemon_login{};
bool recoverFromDevice(const std::string &path, const std::string &password, const std::string &device_name)
virtual std::string getUserNote(const std::string &txid) const override
getUserNote - return an arbitrary string note attached to a txid
virtual bool checkTxProof(const std::string &txid, const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations) override
size_t importMultisigImages(const std::vector< std::string > &images) override
importMultisigImages - imports other participants' multisig images
void setSubaddressLabel(uint32_t accountIndex, uint32_t addressIndex, const std::string &label) override
setSubaddressLabel - sets the label of the specified subaddress
virtual std::string signMessage(const std::string &message) override
bool create(const std::string &path, const std::string &password, const std::string &language)
void rescanBlockchainAsync() override
rescanBlockchainAsync - rescans wallet asynchronously, starting from genesys
void setRecoveringFromDevice(bool recoveringFromDevice) override
setRecoveringFromDevice - set state to recovering from device
virtual bool blackballOutput(const std::string &amount, const std::string &offset) override
blackballs an output
virtual PendingTransaction * createSweepUnmixableTransaction() override
createSweepUnmixableTransaction creates transaction with unmixable outputs.
bool setPassword(const std::string &password) override
virtual void segregatePreForkOutputs(bool segregate) override
sets whether pre-fork outs are to be segregated
virtual void setDefaultMixin(uint32_t arg) override
setDefaultMixin - setum number of mixins to be used for new transactions
std::string publicViewKey() const override
publicViewKey - returns public view key
virtual bool checkSpendProof(const std::string &txid, const std::string &message, const std::string &signature, bool &good) const override
uint64_t unlockedBalance(uint32_t accountIndex=0, bool public_blockchain=false) const override
virtual bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector< std::string > &unknown_parameters, std::string &error) override
virtual std::string signMultisigParticipant(const std::string &message) const override
signMultisigParticipant signs given message with the multisig public signer key
std::string secretViewKey() const override
secretViewKey - returns secret view key
virtual bool unblackballOutput(const std::string &amount, const std::string &offset) override
unblackballs an output
std::string publicSpendKey() const override
publicSpendKey - returns public spend key
PendingTransaction * createTransaction(const std::string &dst_addr, const std::string &payment_id, optional< uint64_t > amount, uint32_t mixin_count, PendingTransaction::Priority priority=PendingTransaction::Priority_Low, uint32_t subaddr_account=0, std::set< uint32_t > subaddr_indices={}) override
createTransaction creates transaction. if dst_addr is an integrated address, payment_id is ignored ...
bool connectToDaemon() override
connectToDaemon - connects to the daemon. TODO: check if it can be removed
virtual bool getRings(const std::string &txid, std::vector< std::pair< std::string, std::vector< uint64_t >>> &rings) const override
gets the rings used for a txid, if any
virtual void segregationHeight(uint64_t height) override
sets the height where segregation should occur
bool close(bool store=true)
bool finalizeMultisig(const std::vector< std::string > &extraMultisigInfo) override
finalizeMultisig - finalizes N - 1 / N multisig wallets creation
std::string getSeedLanguage() const override
uint64_t daemonBlockChainTargetHeight() const override
daemonBlockChainTargetHeight - returns daemon blockchain target height
virtual void startRefresh() override
StartRefresh - Start/resume refresh thread (refresh every 10 seconds)
bool trustedDaemon() const override
virtual std::string getReserveProof(bool all, uint32_t account_index, uint64_t amount, const std::string &message) const override
getReserveProof - Generates a proof that proves the reserve of unspent funds Parameters account_index...
bool useForkRules(uint8_t version, int64_t early_blocks) const override
check if hard fork rules should be used
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const override
verifyMessageWithPublicKey verifies that message was signed with the given public key ...
bool exportKeyImages(const std::string &filename) override
exportKeyImages - exports key images to file
virtual bool unlockKeysFile() override
bool hasMultisigPartialKeyImages() const override
hasMultisigPartialKeyImages - checks if wallet needs to import multisig key images from other partici...
std::string errorString() const override
in case error status, returns error string
virtual bool isKeysFileLocked() override
returns true if the keys file is locked
virtual std::string getTxProof(const std::string &txid, const std::string &address, const std::string &message) const override
uint64_t getRefreshFromBlockHeight() const override
getRestoreHeight - get wallet creation height
bool recoverFromKeys(const std::string &path, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
virtual bool blackballOutputs(const std::vector< std::string > &outputs, bool add) override
blackballs a set of outputs
WalletImpl(NetworkType nettype=MAINNET, uint64_t kdf_rounds=1)
virtual void disposeTransaction(PendingTransaction *t) override
disposeTransaction - destroys transaction object
virtual void setListener(WalletListener *l) override
bool open(const std::string &path, const std::string &password)
bool init(const std::string &daemon_address, uint64_t upper_transaction_size_limit=0, const std::string &daemon_username="", const std::string &daemon_password="", bool use_ssl=false, bool lightWallet=false) override
init - initializes wallet with daemon connection params. if daemon_address is local address...
void statusWithErrorString(int &status, std::string &errorString) const override
returns both error and error string atomically. suggested to use in instead of status() and errorStri...
std::string integratedAddress(const std::string &payment_id) const override
integratedAddress - returns integrated address for current wallet address and given payment_id...
uint64_t estimateBlockChainHeight() const override
estimateBlockChainHeight - returns estimate blockchain height. More accurate than approximateBlockCha...
void setTrustedDaemon(bool arg) override
virtual void pauseRefresh() override
pauseRefresh - pause refresh thread
std::string address(uint32_t accountIndex=0, uint32_t addressIndex=0) const override
virtual bool lockKeysFile() override
locks/unlocks the keys file; returns true on success
bool rescanBlockchain() override
rescanBlockchain - rescans the wallet, updating transactions from daemon
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const override
verifySignedMessage - verify a signature matches a given message
PendingTransaction * restoreMultisigTransaction(const std::string &signData) override
restoreMultisigTransaction creates PendingTransaction from signData
virtual SubaddressAccount * subaddressAccount() override
bool rescanSpent() override
static void error(const std::string &category, const std::string &str)
virtual AddressBook * addressBook() override
void setSeedLanguage(const std::string &arg) override
void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const override
returns current hard fork info
bool setDevicePin(const std::string &password) override
bool exportMultisigImages(std::string &images) override
exportMultisigImages - exports transfers' key images
bool recover(const std::string &path, const std::string &password, const std::string &seed)
unsigned __int64 uint64_t
MultisigState multisig() const override
multisig - returns current state of multisig wallet creation process
virtual bool checkTxKey(const std::string &txid, std::string tx_key, const std::string &address, uint64_t &received, bool &in_pool, uint64_t &confirmations) override
std::string getMultisigInfo() const override
getMultisigInfo
virtual TransactionHistory * history() override
virtual bool setUserNote(const std::string &txid, const std::string ¬e) override
setUserNote - attach an arbitrary string note to a txid
void refreshAsync() override
refreshAsync - refreshes wallet asynchronously.
Transaction-like interface for sending etn.
bool refresh() override
refresh - refreshes the wallet, updating transactions from daemon
version
Supported socks variants.
virtual std::string getSpendProof(const std::string &txid, const std::string &message) const override
virtual bool lightWalletLogin(bool &isNewWallet) const override
Light wallet authenticate and login.
Device getDeviceType() const override
Queries backing device for wallet keys.
std::string message("Message requiring signing")
virtual void keyReuseMitigation2(bool mitigation) override
secondary key reuse mitigation
void addSubaddress(uint32_t accountIndex, const std::string &label) override
addSubaddress - appends a new subaddress at the end of the last minor index of the specified subaddre...
bool importKeyImages(const std::string &filename) override
importKeyImages - imports key images from file
void setRecoveringFromSeed(bool recoveringFromSeed) override
setRecoveringFromSeed - set state recover form seed
uint64_t blockChainHeight() const override
blockChainHeight - returns current blockchain height
bool createWatchOnly(const std::string &path, const std::string &password, const std::string &language) const override
createWatchOnly - Creates a watch only wallet
void setRefreshFromBlockHeight(uint64_t refresh_from_block_height) override
setRefreshFromBlockHeight - start refresh from block height on recover
bool setDevicePassphrase(const std::string &password) override
virtual bool setRing(const std::string &key_image, const std::vector< uint64_t > &ring, bool relative) override
sets the ring used for a key image
virtual uint32_t defaultMixin() const override
defaultMixin - returns number of mixins used in transactions
virtual bool checkReserveProof(const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const override
std::string seed() const override
int autoRefreshInterval() const override
autoRefreshInterval - returns automatic refresh interval in millis
bool watchOnly() const override
watchOnly - checks if wallet is watch only
std::string makeMultisig(const std::vector< std::string > &info, uint32_t threshold) override
makeMultisig - switches wallet in multisig state. The one and only creation phase for N / N wallets ...
size_t numSubaddressAccounts() const override
numSubaddressAccounts - returns the number of existing subaddress accounts
bool recoverFromKeysWithPassword(const std::string &path, const std::string &password, const std::string &language, const std::string &address_string, const std::string &viewkey_string, const std::string &spendkey_string="")
friend class PendingTransactionImpl
size_t numSubaddresses(uint32_t accountIndex) const override
numSubaddresses - returns the number of existing subaddresses associated with the specified subaddres...
NetworkType nettype() const override
std::string secretSpendKey() const override
secretSpendKey - returns secret spend key
uint64_t balance(uint32_t accountIndex=0, bool public_blockchain=false) const override
bool submitTransaction(const std::string &fileName) override
submitTransaction - submits transaction in signed tx file
std::string publicMultisigSignerKey() const override
publicMultisigSignerKey - returns public signer key
int status() const override
returns wallet status (Status_Ok | Status_Error)
uint64_t daemonBlockChainHeight() const override
daemonBlockChainHeight - returns daemon blockchain height
virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) override
Initiates a light wallet import wallet request.
bool store(const std::string &path) override
store - stores wallet to file.
static void info(const std::string &category, const std::string &str)
virtual std::string getTxKey(const std::string &txid) const override
std::string getSubaddressLabel(uint32_t accountIndex, uint32_t addressIndex) const override
getSubaddressLabel - gets the label of the specified subaddress
std::string exchangeMultisigKeys(const std::vector< std::string > &info) override
exchange_multisig_keys - provides additional key exchange round for arbitrary multisig schemes (like ...
virtual std::string getDefaultDataDir() const override
uint64_t approximateBlockChainHeight() const override
approximateBlockChainHeight - returns approximate blockchain height calculated from date/time ...
void setAutoRefreshInterval(int millis) override
setAutoRefreshInterval - setup interval for automatic refresh.
ConnectionStatus connected() const override
connected - checks if the wallet connected to the daemon
void setSubaddressLookahead(uint32_t major, uint32_t minor) override
setSubaddressLookahead - set size of subaddress lookahead
virtual bool getRing(const std::string &key_image, std::vector< uint64_t > &ring) const override
gets the ring used for a key image, if any
virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) override
loadUnsignedTx - creates transaction from unsigned tx file
std::string filename() const override
filename - returns wallet filename
std::string keysFilename() const override
keysFilename - returns keys filename. usually this formed as "wallet_filename".keys ...
virtual Subaddress * subaddress() override
void addSubaddressAccount(const std::string &label) override
addSubaddressAccount - appends a new subaddress account at the end of the last major index of existin...
virtual uint64_t coldKeyImageSync(uint64_t &spent, uint64_t &unspent) override
cold-device protocol key image sync
std::string path() const override
Interface for wallet operations. TODO: check if /include/IWallet.h is still actual.