ObsidianDragon - DragonX ImGui Wallet
Full-node GUI wallet for DragonX cryptocurrency. Built with Dear ImGui, SDL3, and OpenGL3/DX11. Features: - Send/receive shielded and transparent transactions - Autoshield with merged transaction display - Built-in CPU mining (xmrig) - Peer management and network monitoring - Wallet encryption with PIN lock - QR code generation for receive addresses - Transaction history with pagination - Console for direct RPC commands - Cross-platform (Linux, Windows)
This commit is contained in:
103
src/data/address_book.h
Normal file
103
src/data/address_book.h
Normal file
@@ -0,0 +1,103 @@
|
||||
// DragonX Wallet - ImGui Edition
|
||||
// Copyright 2024-2026 The Hush Developers
|
||||
// Released under the GPLv3
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace dragonx {
|
||||
namespace data {
|
||||
|
||||
/**
|
||||
* @brief A single address book entry
|
||||
*/
|
||||
struct AddressBookEntry {
|
||||
std::string label;
|
||||
std::string address;
|
||||
std::string notes;
|
||||
|
||||
AddressBookEntry() = default;
|
||||
AddressBookEntry(const std::string& l, const std::string& a, const std::string& n = "")
|
||||
: label(l), address(a), notes(n) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Address book manager
|
||||
*
|
||||
* Stores labeled addresses for easy access when sending.
|
||||
*/
|
||||
class AddressBook {
|
||||
public:
|
||||
AddressBook();
|
||||
~AddressBook();
|
||||
|
||||
/**
|
||||
* @brief Load address book from disk
|
||||
* @return true if loaded successfully
|
||||
*/
|
||||
bool load();
|
||||
|
||||
/**
|
||||
* @brief Save address book to disk
|
||||
* @return true if saved successfully
|
||||
*/
|
||||
bool save();
|
||||
|
||||
/**
|
||||
* @brief Get default address book file path
|
||||
*/
|
||||
static std::string getDefaultPath();
|
||||
|
||||
/**
|
||||
* @brief Add a new entry
|
||||
* @param entry The entry to add
|
||||
* @return true if added (false if duplicate address)
|
||||
*/
|
||||
bool addEntry(const AddressBookEntry& entry);
|
||||
|
||||
/**
|
||||
* @brief Update an existing entry
|
||||
* @param index Index of entry to update
|
||||
* @param entry New entry data
|
||||
* @return true if updated
|
||||
*/
|
||||
bool updateEntry(size_t index, const AddressBookEntry& entry);
|
||||
|
||||
/**
|
||||
* @brief Remove an entry
|
||||
* @param index Index of entry to remove
|
||||
* @return true if removed
|
||||
*/
|
||||
bool removeEntry(size_t index);
|
||||
|
||||
/**
|
||||
* @brief Find entry by address
|
||||
* @param address Address to search for
|
||||
* @return Index or -1 if not found
|
||||
*/
|
||||
int findByAddress(const std::string& address) const;
|
||||
|
||||
/**
|
||||
* @brief Get all entries
|
||||
*/
|
||||
const std::vector<AddressBookEntry>& entries() const { return entries_; }
|
||||
|
||||
/**
|
||||
* @brief Get entry count
|
||||
*/
|
||||
size_t size() const { return entries_.size(); }
|
||||
|
||||
/**
|
||||
* @brief Check if empty
|
||||
*/
|
||||
bool empty() const { return entries_.empty(); }
|
||||
|
||||
private:
|
||||
std::vector<AddressBookEntry> entries_;
|
||||
std::string file_path_;
|
||||
};
|
||||
|
||||
} // namespace data
|
||||
} // namespace dragonx
|
||||
Reference in New Issue
Block a user