Electroneum
Loading...
Searching...
No Matches
IWallet.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32#pragma once
33
34#include <array>
35#include <cstdint>
36#include <istream>
37#include <limits>
38#include <ostream>
39#include <string>
40#include <system_error>
41#include <vector>
42
43namespace CryptoNote {
44
45typedef size_t TransactionId;
46typedef size_t TransferId;
47typedef std::array<uint8_t, 32> TransacitonHash;
48
49struct Transfer {
50 std::string address;
52};
53
54const TransactionId INVALID_TRANSACTION_ID = std::numeric_limits<TransactionId>::max();
55const TransferId INVALID_TRANSFER_ID = std::numeric_limits<TransferId>::max();
56const uint64_t UNCONFIRMED_TRANSACTION_HEIGHT = std::numeric_limits<uint64_t>::max();
57
69
71public:
72 virtual void initCompleted(std::error_code result) {}
73 virtual void saveCompleted(std::error_code result) {}
74 virtual void synchronizationProgressUpdated(uint64_t current, uint64_t total) {}
75 virtual void actualBalanceUpdated(uint64_t actualBalance) {}
76 virtual void pendingBalanceUpdated(uint64_t pendingBalance) {}
77 virtual void externalTransactionCreated(TransactionId transactionId) {}
78 virtual void sendTransactionCompleted(TransactionId transactionId, std::error_code result) {}
79 virtual void transactionUpdated(TransactionId transactionId) {}
80};
81
82class IWallet {
83public:
84 virtual ~IWallet() = 0;
85 virtual void addObserver(IWalletObserver* observer) = 0;
86 virtual void removeObserver(IWalletObserver* observer) = 0;
87
88 virtual void initAndGenerate(const std::string& password) = 0;
89 virtual void initAndLoad(std::istream& source, const std::string& password) = 0;
90 virtual void shutdown() = 0;
91
92 virtual void save(std::ostream& destination, bool saveDetailed = true, bool saveCache = true) = 0;
93
94 virtual std::error_code changePassword(const std::string& oldPassword, const std::string& newPassword) = 0;
95
96 virtual std::string getAddress() = 0;
97
98 virtual uint64_t actualBalance() = 0;
99 virtual uint64_t pendingBalance() = 0;
100
101 virtual size_t getTransactionCount() = 0;
102 virtual size_t getTransferCount() = 0;
103
105
106 virtual bool getTransaction(TransactionId transactionId, Transaction& transaction) = 0;
107 virtual bool getTransfer(TransferId transferId, Transfer& transfer) = 0;
108
109 virtual TransactionId sendTransaction(const Transfer& transfer, uint64_t fee, const std::string& extra = "", uint64_t mixIn = 0, uint64_t unlockTimestamp = 0) = 0;
110 virtual TransactionId sendTransaction(const std::vector<Transfer>& transfers, uint64_t fee, const std::string& extra = "", uint64_t mixIn = 0, uint64_t unlockTimestamp = 0) = 0;
111 virtual std::error_code cancelTransaction(size_t transferId) = 0;
112};
113
114}
virtual std::string getAddress()=0
virtual void removeObserver(IWalletObserver *observer)=0
virtual void addObserver(IWalletObserver *observer)=0
virtual std::error_code cancelTransaction(size_t transferId)=0
virtual void shutdown()=0
virtual uint64_t actualBalance()=0
virtual bool getTransfer(TransferId transferId, Transfer &transfer)=0
virtual ~IWallet()=0
virtual void initAndLoad(std::istream &source, const std::string &password)=0
virtual bool getTransaction(TransactionId transactionId, Transaction &transaction)=0
virtual void save(std::ostream &destination, bool saveDetailed=true, bool saveCache=true)=0
virtual std::error_code changePassword(const std::string &oldPassword, const std::string &newPassword)=0
virtual uint64_t pendingBalance()=0
virtual void initAndGenerate(const std::string &password)=0
virtual TransactionId sendTransaction(const Transfer &transfer, uint64_t fee, const std::string &extra="", uint64_t mixIn=0, uint64_t unlockTimestamp=0)=0
virtual TransactionId sendTransaction(const std::vector< Transfer > &transfers, uint64_t fee, const std::string &extra="", uint64_t mixIn=0, uint64_t unlockTimestamp=0)=0
virtual size_t getTransferCount()=0
virtual TransactionId findTransactionByTransferId(TransferId transferId)=0
virtual size_t getTransactionCount()=0
virtual void actualBalanceUpdated(uint64_t actualBalance)
Definition IWallet.h:75
virtual void sendTransactionCompleted(TransactionId transactionId, std::error_code result)
Definition IWallet.h:78
virtual void synchronizationProgressUpdated(uint64_t current, uint64_t total)
Definition IWallet.h:74
virtual void initCompleted(std::error_code result)
Definition IWallet.h:72
virtual void pendingBalanceUpdated(uint64_t pendingBalance)
Definition IWallet.h:76
virtual void externalTransactionCreated(TransactionId transactionId)
Definition IWallet.h:77
virtual void transactionUpdated(TransactionId transactionId)
Definition IWallet.h:79
virtual void saveCompleted(std::error_code result)
Definition IWallet.h:73
const TransactionId INVALID_TRANSACTION_ID
Definition IWallet.h:54
size_t TransactionId
Definition IWallet.h:45
size_t TransferId
Definition IWallet.h:46
std::array< uint8_t, 32 > TransacitonHash
Definition IWallet.h:47
const uint64_t UNCONFIRMED_TRANSACTION_HEIGHT
Definition IWallet.h:56
const TransferId INVALID_TRANSFER_ID
Definition IWallet.h:55
const CharType(& source)[N]
Definition pointer.h:1147
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
TransferId firstTransferId
Definition IWallet.h:59
std::string extra
Definition IWallet.h:67
TransacitonHash hash
Definition IWallet.h:63
std::string address
Definition IWallet.h:50