Skip to content
Permalink
Browse files

Wallet format upgrade mostly working

  • Loading branch information...
zpalmtree committed Jun 17, 2019
1 parent a14df36 commit 79dc303a23281ca08a906931ae17fb027f5ad966
@@ -65,6 +65,8 @@ struct TransactionSpentOutputInformation: public TransactionOutputInformation {
uint32_t inputInTransaction;
};

struct SpentTransactionOutput;

class ITransfersContainer : public IStreamSerializable {
public:
enum Flags : uint32_t {
@@ -98,6 +100,8 @@ class ITransfersContainer : public IStreamSerializable {
//only type flags are feasible for this function
virtual std::vector<TransactionOutputInformation> getTransactionInputs(const Crypto::Hash& transactionHash, uint32_t flags) const = 0;
virtual void getUnconfirmedTransactions(std::vector<Crypto::Hash>& transactions) const = 0;
virtual std::vector<SpentTransactionOutput> getUnspentInputs() const = 0;
virtual std::vector<SpentTransactionOutput> getSpentInputs() const = 0;
};

}
@@ -150,7 +150,7 @@ target_link_libraries(Serialization Common Crypto ${Boost_LIBRARIES})
target_link_libraries(SubWallets Common Logger)
target_link_libraries(Transfers CryptoNoteCore)
target_link_libraries(Utilities Common Errors Wallet)
target_link_libraries(Wallet NodeRpcProxy Transfers CryptoNoteCore Common ${Boost_LIBRARIES})
target_link_libraries(Wallet NodeRpcProxy Transfers CryptoNoteCore Common WalletBackend ${Boost_LIBRARIES})
target_link_libraries(WalletApi WalletBackend)
target_link_libraries(WalletBackend Serialization Mnemonics Nigel cryptopp-static __filesystem Utilities SubWallets Logger Config)
target_link_libraries(WalletService JsonRpcServer Wallet Mnemonics Errors)
@@ -294,6 +294,8 @@ class FileMappedVector : public EnableIfPod<T>::type {
void rename(const std::string& newPath, std::error_code& ec);
void rename(const std::string& newPath);

std::string getPath() const;

template<class F>
void atomicUpdate(F&& func);

@@ -756,6 +758,12 @@ void FileMappedVector<T>::rename(const std::string& newPath) {
m_path = newPath;
}

template<class T>
std::string FileMappedVector<T>::getPath() const
{
return m_path;
}

template<class T>
template<class F>
void FileMappedVector<T>::atomicUpdate(F&& func) {
@@ -131,6 +131,8 @@ class Core : public ICore, public ICoreInformation {

virtual uint64_t get_current_blockchain_height() const;

static std::string getPaymentIDFromExtra(const std::vector<uint8_t> &extra);

private:
const Currency& currency;
System::Dispatcher& dispatcher;
@@ -686,6 +686,35 @@ uint64_t TransfersContainer::balance(uint32_t flags) const {
return amount;
}

std::vector<SpentTransactionOutput> TransfersContainer::getUnspentInputs() const
{
std::vector<SpentTransactionOutput> result;

for (const auto &input : m_availableTransfers)
{
if (input.blockHeight != WALLET_UNCONFIRMED_TRANSACTION_HEIGHT)
{
/* "cast" TransactionOutputInformationEx to SpentTransactionOutput,
leaving other members default constructed */
result.push_back({input});
}
}

return result;
}

std::vector<SpentTransactionOutput> TransfersContainer::getSpentInputs() const
{
std::vector<SpentTransactionOutput> result;

for (const auto &input : m_spentTransfers)
{
result.push_back(input);
}

return result;
}

void TransfersContainer::getOutputs(std::vector<TransactionOutputInformation>& transfers, uint32_t flags) const {
std::lock_guard<std::mutex> lk(m_mutex);
for (const auto& t : m_availableTransfers) {
@@ -164,6 +164,8 @@ class TransfersContainer : public ITransfersContainer {
//only type flags are feasible for this function
virtual std::vector<TransactionOutputInformation> getTransactionInputs(const Crypto::Hash& transactionHash, uint32_t flags) const override;
virtual void getUnconfirmedTransactions(std::vector<Crypto::Hash>& transactions) const override;
virtual std::vector<SpentTransactionOutput> getUnspentInputs() const override;
virtual std::vector<SpentTransactionOutput> getSpentInputs() const override;

// IStreamSerializable
virtual void save(std::ostream& os) override;

0 comments on commit 79dc303

Please sign in to comment.
You can’t perform that action at this time.