Merge pull request #241 from layters/backup

Backup
pull/245/head
layters 2 months ago committed by GitHub
commit 253ab1f871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +1,5 @@
# neroshop - WORK IN PROGRESS (ON HOLD)
[![banner](assets/images/appicons/LogoLight250x250.png)](https://github.com/larteyoh/testshop "neroshop logo")
[![banner](assets/images/appicons/LogoLight250x250.png)](https://github.com/layters/testshop "neroshop logo")
NeroShop is a decentralized peer-to-peer marketplace for trading goods and services with [**Monero**](https://getmonero.org/)
@ -30,28 +30,28 @@ https://user-images.githubusercontent.com/58671384/219222567-f170f728-be31-43d5-
<details>
<summary>Click to load images</summary>
![Wallet_Keys_Generation](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Wallet_Keys_Generation.png)
![Registration](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Registration.png)
![Login](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Login.png)
![CatalogGrid](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/CatalogGrid.png)
![CatalogList](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/CatalogList.png)
![ProductPage](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProductPage.png)
![SettingsDialog_Network](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/SettingsDialog_Monero.png)
![SettingsDialog_General](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/SettingsDialog_General.png)
![HomePage](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/HomePage.png)
![HomePage_Recent_Listings](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/HomePage_Recent_Listings.png)
![Dashboard](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Dashboard_Overview.png)
![Store_Inventory](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Store_InventoryTab.png)
![Store_Inventory_ProductDialog_Top](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Top.png)
![Store_Inventory_ProductDialog_Mid](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Mid.png)
![Store_Inventory_ProductDialog_Bottom](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Bottom.png)
![WalletPage_Send](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceSend.png)
![WalletPage_Receive](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceReceive.png)
![WalletPage_Transactions](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceTxs.png)
![ProfilePage_ListingsTab](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_ListingsTab.png)
![ProfilePage_RatingsTab](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_RatingsTab.png)
![ProfilePage_With_Custom_Avatar](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_With_Custom_Avatar.png)
![MessagesPage](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Messages_Page.png)
![Wallet_Keys_Generation](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Wallet_Keys_Generation.png)
![Registration](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Registration.png)
![Login](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Login.png)
![CatalogGrid](https://github.com/layters/testshop/blob/main/assets/images/screenshots/CatalogGrid.png)
![CatalogList](https://github.com/layters/testshop/blob/main/assets/images/screenshots/CatalogList.png)
![ProductPage](https://github.com/layters/testshop/blob/main/assets/images/screenshots/ProductPage.png)
![SettingsDialog_Network](https://github.com/layters/testshop/blob/main/assets/images/screenshots/SettingsDialog_Monero.png)
![SettingsDialog_General](https://github.com/layters/testshop/blob/main/assets/images/screenshots/SettingsDialog_General.png)
![HomePage](https://github.com/layters/testshop/blob/main/assets/images/screenshots/HomePage.png)
![HomePage_Recent_Listings](https://github.com/layters/testshop/blob/main/assets/images/screenshots/HomePage_Recent_Listings.png)
![Dashboard](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Dashboard_Overview.png)
![Store_Inventory](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Store_InventoryTab.png)
![Store_Inventory_ProductDialog_Top](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Top.png)
![Store_Inventory_ProductDialog_Mid](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Mid.png)
![Store_Inventory_ProductDialog_Bottom](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Store_InventoryTab_ProductDialog_Bottom.png)
![WalletPage_Send](https://github.com/layters/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceSend.png)
![WalletPage_Receive](https://github.com/layters/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceReceive.png)
![WalletPage_Transactions](https://github.com/layters/testshop/blob/main/assets/images/screenshots/WalletPage_BalanceTxs.png)
![ProfilePage_ListingsTab](https://github.com/layters/testshop/blob/main/assets/images/screenshots/ProfilePage_ListingsTab.png)
![ProfilePage_RatingsTab](https://github.com/layters/testshop/blob/main/assets/images/screenshots/ProfilePage_RatingsTab.png)
![ProfilePage_With_Custom_Avatar](https://github.com/layters/testshop/blob/main/assets/images/screenshots/ProfilePage_With_Custom_Avatar.png)
![MessagesPage](https://github.com/layters/testshop/blob/main/assets/images/screenshots/Messages_Page.png)
</details>
@ -124,7 +124,7 @@ sudo dnf install gcc gcc-c++ make cmake git
**1. Clone neroshop (and its submodules)**
```bash
git clone --recurse-submodules https://github.com/larteyoh/testshop.git
git clone --recurse-submodules https://github.com/layters/testshop.git
```
```bash
cd testshop
@ -192,7 +192,7 @@ sudo make install
cd ../
```
<!-- git submodule update --init --force --> <!-- <= call this before building monero -->
<!-- git submodule update --init --force --recursive --> <!-- <= call this before building monero -->
**5. Build monero-project to create .a libraries**
```bash
@ -231,7 +231,7 @@ make -j$(nproc)
## Contributing
See [Wiki](https://github.com/larteyoh/testshop/wiki/Contributing)
See [Wiki](https://github.com/layters/testshop/wiki/Contributing)
## License
@ -264,9 +264,9 @@ WW2pQTQWHpyJf2CHrCmZG7Tn3zBnYRZTH8g4U3pSZf5s6xsTXrZc9odDWmrWzjRc9MMQWrKXxjHsRdzH
## Resources
- Website: [neroshop.org](https://neroshop.org/)
- Neroshop DHT Specification: [specs](https://github.com/larteyoh/specs)
- Neroshop DHT Specification: [specs](https://github.com/layters/specs)
- Wiki: [Wikipage](https://github.com/larteyoh/testshop/wiki)
- Wiki: [Wikipage](https://github.com/layters/testshop/wiki)
- Git Mirrors:
- [Codeberg](https://codeberg.org/layter/neroshop)
@ -297,5 +297,5 @@ everyone in our matrix room — for sharing many great ideas that have been usef
[//]: # (git add .gitignore .gitmodules assets/ cmake/ CMakeLists.txt external/ LICENSE qml/ qml.qrc README.md src/ tests/)
[//]: # (git commit -m"..." or git commit -a --allow-empty-message -m "")
[//]: # (git push -u origin backup --force)
[//]: # (https://git.slipfox.xyz/larteyoh/testshop/settings => Mirror Settings => Synchronize Now)
[//]: # (https://git.wownero.com/layter/neroshop/settings => Mirror Settings => Synchronize Now)
[//]: # (removing an external lib from submodules index: git rm --cached path/to/submodule)

@ -1048,6 +1048,9 @@ Item {
let remote_node_port = remote_node.split(":")[1]
console.log("connecting to remote node:", (remote_node_ip + ":" + remote_node_port))
Wallet.nodeConnect(remote_node_ip, remote_node_port)
if(Wallet.isConnectedToDaemon()) {
moneroDaemonSyncBar.title = settingsDialog.moneroNodeAddress
}
}
}
}

@ -312,7 +312,7 @@ ApplicationWindow {
x: parent.x + (parent.width - this.width) / 2
height: contentHeight + 20; width: (contentWidth > parent.width) ? 300 : parent.width
bottomMargin : footer.height + 5
text: qsTr("%1\n%2 %3%4").arg(moneroDaemonSyncBar.title).arg((!Wallet.opened || parent.value <= 0.0) ? ((moneroDaemonSyncBar.title != "monerod") ? "Waiting" : "Disconnected") : ((parent.value > 0.0 && parent.value < 1.0) ? Wallet.getSyncMessage() : "Connected")).arg((parent.value > 0.0 && parent.value != 1.0) ? ("(" + (parent.value * 100).toFixed(2) + "%)") : "").arg((!Wallet.opened || parent.value <= 0.0) ? "" : ((parent.value > 0.0 && parent.value != 1.0) ? ("\nBlocks remaining: " + Wallet.getSyncHeight() + " / " + Wallet.getSyncEndHeight()) : ""))
text: qsTr("%1\n%2 %3%4").arg(moneroDaemonSyncBar.title).arg((!Wallet.opened || parent.value <= 0.0) ? ((moneroDaemonSyncBar.title != "monerod") ? "Waiting" : "Disconnected") : ((parent.value > 0.0 && parent.value < 1.0) ? Wallet.getSyncMessage() : "Synchronized")).arg((parent.value > 0.0 && parent.value != 1.0) ? ("(" + (parent.value * 100).toFixed(2) + "%)") : "").arg((!Wallet.opened || parent.value <= 0.0) ? "" : ((parent.value > 0.0 && parent.value != 1.0) ? ("\nBlocks remaining: " + Wallet.getSyncHeight() + " / " + Wallet.getSyncEndHeight()) : ""))
pointer.visible: false
}
}

@ -173,11 +173,20 @@ Page {
font.pixelSize: 32
}
}
Text {
Column {
anchors.left: parent.children[0].right; anchors.leftMargin: 20
anchors.verticalCenter: parent.verticalCenter
text: modelData.is_incoming ? qsTr("Received") : qsTr("Sent")
color: balanceTxColumn.textColor
spacing: 1
Text {
text: modelData.is_incoming ? qsTr("Received") : qsTr("Sent")
color: balanceTxColumn.textColor
}
Text {
text: "2024-01-01 00:00" // TODO: get actual tx date and time
color: "#777"
font.pointSize: 10
visible: false // <- hide this for now
}
}
Column {
anchors.horizontalCenter: parent.horizontalCenter
@ -190,7 +199,7 @@ Page {
Text {
text: (!Wallet.opened) ? "" : qsTr("%1 %2%3 %4").arg(modelData.is_incoming ? "+" : "-").arg(Backend.getCurrencySign(priceDisplayText.currency)).arg(CurrencyExchangeRates.getXmrPrice(priceDisplayText.currency) * modelData.amount.toFixed(12)).arg(priceDisplayText.currency.toUpperCase())
color: "#777"
//font.bold: true
font.pointSize: 10
}
}
Button {

@ -24,7 +24,7 @@ const std::vector<Category> predefined_categories = {
{ 1, "Food & Beverages", "Grocery", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAACZUlEQVR4nO2aPWgUQRSABy0iokRIdWoTBJtoIVqEgD+NINHCZiWFprCykYDa2MUmimBjCrWyCAouBCwEC7GwUUyTwlILrSL4V0RBRf3CoMKRm73d2503vovvg+lm3sz72Jmdt3fOGYZhGIZhdAEYR47limvIQoML+uaBrnmVeYIAJ5FlQLuAKWEBLe0CpoUFjGgXMCssYL92AXeEBRzXLuChsIDT2gU8FxZwQbuAV8ICZrQL+Cgs4KZaAcB64KewgFyzgCHkeaxZwE75/FnULGBUPn/eaBYwLp8/nzULOEUaBrQKmCINLa0CLpGGEa0CrpOGjooQGP6TuG/XCsZlgfYs0O+e1kqwsCIEJojHrNZKsLAiBA4Tj4t1BSyQho6KENgbMf5YXQEvScNMwRkQg7fAuroCPpCGW4G5t0SKfb5W8h5/SyMNt90qgM0R4voneIOrC/CJNHR8EwAGG8ZcBnbXTt4DvCYNV90qgG0N4r0HDrqmAPOk4URg7kM1Yz0BdjRO3gOcQ55fwHYXvgj9qBjjC3AfOOZiArSAb8ICHnWZ358DY8CVgrFHgF3AxqiJtwPMCQs46kropRiKDrBV8Mvwg4pr+HcCPMCkQPLvvFzXDwI8/kYVMXl/v9jnKqJCgAc4C3xtmLz/pWmP6wE1Ajz+dlXw0aGM78ANYJPrEVUC/gIcAO4CSyXv+BfA5dC7vq8FtAOcKRAw5CLQDwIyyQWaAOwJyGwLCG6xxtgZgB2C2Zo+BPn9P4G8S3saWmDJmLyfBGQI0HR+2azbMAHYE5D971tgtOxAq9Oazi+btWEYhlvbrADFelwIpcui8wAAAABJRU5ErkJggg=="},
{ 2, "Electronics", "", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAACO0lEQVR4nO2bTU7DMBCF3y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F0CqYnSSZW8mE+SttC5lbm7/BSoDDZq+vGmXtQ8d6e4Yj6MhHVc+8MICpr7w4SO2/QNFpBG7F1DqaqgFMvfZJip1TitbpBDpy79Y0DSiTjFGr3F0EfE+oNZiKAUCzkvCmGx5F0/DYDNxzBHWwWl0B3AU2Ga2i0bYZr/x3qKUBOcfNita4pabBEdbyuqJc/ypzLS3pJGlsS8OAwhw2PbWldFvRke12jUIaBpS0O6W99eUN0PFvQOCXwByDzwHsjnEAQnp+Nlcrrg8o1x85qkONXWnkgHbHzS5Y47aak19hR2D6letybKbD0pIzRRob0jCgwZz41LgO9AKXQg5B5aymp8aY0egNqRLfWifKamOAAJwlGc+toKUSfJlQ68y0ThoGNAOvYwYsy2GHopV3LJUwXtldopoaIMj6Az5HDFg2QY4FDuSYrNIFciGF0XpFo7YGCMAaR6a3A/73ze7CFDzVDJVjdasd82tvQEVSlN2eG8A70yL7aPb/T0rNH0REjs5L0wR4YIybNMluuFpvMTUDPB6Px+PxBFnnL5kjkrLcntRPAAAAAElFTkSuQmCC"},
{ 6, "Services", "Non-product services, Freelancing, etc.", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAADjUlEQVR4nO2aS6hNURjH/+t61c2juCjKsy5loCiuiTKiFGUiTEQxo0gGCteEiYmZPGbUjQkhRhQDEiZInYG8out6XFeKe/kZ7H1qO/fsx7l7rb3Ocfdvck77nG+t7/+tb639rbW3VFJSUjKKMb4dkCRgk6T1kiqSThljfnh2qTiALfzLZd8+FQpwrSYAQ8Ak3345B5gHHAR6Gc5pYLVvH50ATAPOA4N1hNfyAOjy7XMugA6gM/y+AnifQXiUQeBAaD8DWOhXUQMAe4CfoZDnwECD4qM8BP6E368DE3zrS4Qg1X/lEJzGDht+ttloJIapksY5bH+GjUacBcAYU5F0N+PfK5KuSHog6XeG/w9Iav56AZgC3ElI4wFgZ41NJ/AkwaYfWO5LU8MANxudx8Bs4H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ahTPTkrp7aiDC7lTJCVgDXgKXAwQK8U7oF0ASaeADeB+kFRvmMt83Qum8OQhI4CkZeBBARcLOd+AJ51bGDkygKQLwM1CLhaavgGXmHCpPC40BVgsYmGkKcBUf/owxo1QBu+Bg8B5TSwA18hfykcOieAbcDml9CtoXhaStoHlNjNa1RvisPTJD/jedkBUgGNLDeAWcFMDBM1x3S+09o9aBs9Keg7sB83LYR6413ZI5I3QeuCsYtRrgFvATQ3gFnBTA7gF3NQAbgE3NYBbwE0N4BZwUwO4BdzUAG4BNzWAW8BNDeAWcFMDuAXc1ABuATc1gFvAzcwHaPPb4E/+7A3qOz8mfqekFf3LlqTbkuYDJfvJfwI8dDsV5a8AL90+XTDORXCzMwsjTQEOhx7vdSnioinAx6HH17sU6SWS5iR9HlwDPkg67XYqjqTHQxfCV5LOuJ0iadzeJukk8Aa4NXjqC/AMeA3sdqcWxteU0sg9xVn7+ySdA3aAO1FWBVlNKW2POpi1DKaU9oC7wCPgU5BYLxh7h+fgH6Q3gCtMwV9nK7POb7zRpspIHJDQAAAAAElFTkSuQmCC"},
@ -80,6 +80,7 @@ const std::vector<Subcategory> predefined_subcategories = {
{ static_cast<unsigned int>(predefined_categories.size() + 21), predefined_categories[9].name, predefined_categories[9].description, predefined_categories[9].thumbnail, 5 },
// New (Unique) subcategories
{ 505, "Digital Art & Memes", "", "", 5 },
};
//-----------------------------------------------------------------------------

@ -56,7 +56,7 @@ void neroshop::Escrow::test_create_multisig_wallet(int M, int N) {
// wallets are now multisig
for(auto wallet : wallets) {
std::string primary_address = wallet->get_monero_wallet()->get_address(0, 0);
if(!monero_utils::is_valid_address(primary_address, wallet->get_network_type())) {
if(!monero_utils::is_valid_address(primary_address, wallet->get_monero_wallet()->get_network_type())) {
throw std::runtime_error("wallet address is not valid!");
}
std::cout << "multisig address: " << primary_address << std::endl;

@ -439,6 +439,7 @@ void neroshop::Order::set_payment_coin(PaymentCoin payment_coin) {
void neroshop::Order::set_payment_coin_by_string(const std::string& payment_coin) {
if(payment_coin == "None") set_payment_coin(PaymentCoin::None);
if(payment_coin == "Monero") set_payment_coin(PaymentCoin::Monero);
if(payment_coin == "Wownero") set_payment_coin(PaymentCoin::Wownero);
//if(payment_coin == "") set_payment_coin(PaymentCoin::);
}
@ -470,18 +471,18 @@ neroshop::OrderStatus neroshop::Order::get_status() const {
std::string neroshop::Order::get_status_as_string() const {
switch(status) {
case OrderStatus::New: return "New"; break;
case OrderStatus::Pending: return "Pending"; break;
case OrderStatus::Processing: return "Processing"; break;
case OrderStatus::Shipped: return "Shipped"; break;
case OrderStatus::ReadyForPickup: return "Ready For Pickup"; break; //case OrderStatus::Ready: return "Ready For Pickup"; break;
case OrderStatus::Delivered: return "Delivered"; break; //case OrderStatus::Done: return "Delivered"; break;
case OrderStatus::Cancelled: return "Cancelled"; break;
case OrderStatus::Failed: return "Failed"; break;
case OrderStatus::Returned: return "Returned"; break;
case OrderStatus::Disputed: return "Disputed"; break;
case OrderStatus::Declined: return "Declined"; break;
//case OrderStatus::: return ""; break;
case OrderStatus::New: return "New";
case OrderStatus::Pending: return "Pending";
case OrderStatus::Processing: return "Processing";
case OrderStatus::Shipped: return "Shipped";
case OrderStatus::ReadyForPickup: return "Ready For Pickup"; //case OrderStatus::Ready: return "Ready For Pickup";
case OrderStatus::Delivered: return "Delivered"; //case OrderStatus::Done: return "Delivered";
case OrderStatus::Cancelled: return "Cancelled";
case OrderStatus::Failed: return "Failed";
case OrderStatus::Returned: return "Returned";
case OrderStatus::Disputed: return "Disputed";
case OrderStatus::Declined: return "Declined";
//case OrderStatus::: return "";
default: return "New";
}
}
@ -516,9 +517,9 @@ neroshop::PaymentOption neroshop::Order::get_payment_option() const {
std::string neroshop::Order::get_payment_option_as_string() const {
switch(payment_option) {
case PaymentOption::Escrow: return "Escrow"; break;
case PaymentOption::Multisig: return "Multisig"; break;
case PaymentOption::Finalize: return "Finalize"; break;
case PaymentOption::Escrow: return "Escrow";
case PaymentOption::Multisig: return "Multisig";
case PaymentOption::Finalize: return "Finalize";
default: return "Escrow";
}
}
@ -529,9 +530,10 @@ neroshop::PaymentCoin neroshop::Order::get_payment_coin() const {
std::string neroshop::Order::get_payment_coin_as_string() const {
switch(payment_coin) {
case PaymentCoin::None: return "None"; break;
case PaymentCoin::Monero: return "Monero"; break;
//case PaymentCoin::: return ""; break;
case PaymentCoin::None: return "None";
case PaymentCoin::Monero: return "Monero";
case PaymentCoin::Wownero: return "Wownero";
//case PaymentCoin::: return "";
default: return "Monero";
}
}
@ -542,8 +544,8 @@ neroshop::DeliveryOption neroshop::Order::get_delivery_option() const {
std::string neroshop::Order::get_delivery_option_as_string() const {
switch(delivery_option) {
case DeliveryOption::Delivery: return "Delivery"; break;
case DeliveryOption::Pickup: return "Pickup"; break;
case DeliveryOption::Delivery: return "Delivery";
case DeliveryOption::Pickup: return "Pickup";
default: return "Delivery";
}
}

@ -57,8 +57,8 @@ enum class PaymentMethod {
enum class PaymentCoin {
None = -1, // intended for cash and card payments
Monero,
//Wownero, // coming soon!
//Bitcoin, // coming soon or not :S
Wownero,
//Bitcoin,
};
// delivery options

@ -99,11 +99,6 @@ std::string neroshop::Seller::list_item(
return key;
}
////////////////////
/*void neroshop::Seller::list_item(const neroshop::Product& item, unsigned int stock_qty, double sales_price, std::string currency, double discount, unsigned int discounted_items, unsigned int discount_times, std::string discount_expiry, std::string condition) { // ex. 5% off 10 balls
list_item(item.get_id(), stock_qty, sales_price, currency, discount, discounted_items, discount_times, discount_expiry, condition);
}*/
// static_cast<Seller *>(user)->list_item(ball, 50, 8.50, "usd", 0.00, 0, 0, "", "new"); // $0.50 cents off every 2 balls
////////////////////
void neroshop::Seller::delist_item(const std::string& listing_key) {
// Transition from Sqlite to DHT:
Client * client = Client::get_main_client();
@ -450,7 +445,7 @@ unsigned int neroshop::Seller::get_total_ratings() const {
}
////////////////////
unsigned int neroshop::Seller::get_reputation() const {
neroshop::db::Sqlite3 * database = neroshop::get_database();
/*neroshop::db::Sqlite3 * database = neroshop::get_database();
if(!database) throw std::runtime_error("database is NULL");
// Get seller reputation as percentage
unsigned int ratings_count = database->get_integer_params("SELECT COUNT(*) FROM seller_ratings WHERE seller_id = $1", { get_id() });
@ -459,7 +454,8 @@ unsigned int neroshop::Seller::get_reputation() const {
unsigned int good_ratings = database->get_integer_params("SELECT COUNT(score) FROM seller_ratings WHERE seller_id = $1 AND score = $2", { get_id(), std::to_string(1) });
// Calculate seller reputation
double reputation = (good_ratings / static_cast<double>(ratings_count)) * 100;
return static_cast<int>(reputation); // convert reputation to an integer (for easier readability)
return static_cast<int>(reputation); // convert reputation to an integer (for easier readability)*/
return 0;
}
////////////////////
std::vector<unsigned int> neroshop::Seller::get_top_rated_sellers(unsigned int limit) {
@ -681,11 +677,8 @@ bool neroshop::Seller::has_stock(const neroshop::Product& item) const {
// callbacks
////////////////////
neroshop::User * neroshop::Seller::on_login(const neroshop::Wallet& wallet) { // assumes user data already exists in database
/*neroshop::db::Sqlite3 * database = neroshop::get_database();
if(!database) throw std::runtime_error("database is NULL");*/
//std::string user_id = database->get_text_params("SELECT monero_address FROM users WHERE name = $1", { username });
std::string monero_address = wallet.get_monero_wallet()->get_primary_address();
if(!monero_utils::is_valid_address(monero_address, wallet.get_network_type())) {
std::string monero_primary_address = wallet.get_primary_address();
if(!wallet.is_valid_address(monero_primary_address)) {
neroshop::print("Invalid monero address");
return nullptr;
}
@ -693,7 +686,7 @@ neroshop::User * neroshop::Seller::on_login(const neroshop::Wallet& wallet) { //
neroshop::User * user = new Seller();
// set user properties retrieved from database
dynamic_cast<Seller *>(user)->set_logged(true); // protected, so can only be accessed by child class obj
dynamic_cast<Seller *>(user)->set_id(monero_address);
dynamic_cast<Seller *>(user)->set_id(monero_primary_address);
dynamic_cast<Seller *>(user)->set_wallet(wallet);
dynamic_cast<Seller *>(user)->set_account_type(UserAccountType::Seller);
//-------------------------------

@ -7,10 +7,11 @@
#include <cmath>
#include <filesystem>
neroshop::Wallet::Wallet() : process(nullptr), percentage(0.0), monero_wallet_obj(nullptr)
neroshop::Wallet::Wallet() : wallet_type(WalletType::Monero), monero_wallet_obj(nullptr),
process(nullptr), percentage(0.0)
{}
//-------------------------------------------------------
monero::monero_network_type neroshop::Wallet::network_type(monero_network_type::STAGENET);
neroshop::WalletNetworkType neroshop::Wallet::network_type(WalletNetworkType::Stagenet);
//-------------------------------------------------------
neroshop::Wallet::~Wallet()
{
@ -18,7 +19,7 @@ neroshop::Wallet::~Wallet()
// remove listener
monero_wallet_obj->remove_listener (*this);//int listener_count = monero_wallet_obj->get_listeners().size();if(listener_count > 0) { std::cout << NEROSHOP_TAG "still need to delete listeners (" << listener_count << ")" << std::endl; }
// close monero wallet
close(false);
monero_wallet_obj->close(false);
// reset (delete) monero wallet
monero_wallet_obj.reset(); // will call monero_wallet_full destructor
if(!monero_wallet_obj.get()) std::cout << "monero wallet deleted\n"; // just to confirm that the monero wallet has been set to nullptr after deletion
@ -49,13 +50,11 @@ int neroshop::Wallet::create_random(const std::string& password, const std::stri
neroshop::print("Wallet file with the same name already exists", 1);
return static_cast<int>(WalletError::AlreadyExists);
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_random (path, password, network_type/*, const monero_rpc_connection &daemon_connection=monero_rpc_connection(), const std::string &language="English", std::unique_ptr< epee::net_utils::http::http_client_factory > http_client_factory=nullptr*/));
monero::monero_wallet_config wallet_config_obj;
wallet_config_obj.m_path = path;
wallet_config_obj.m_password = password;
wallet_config_obj.m_network_type = this->network_type;
wallet_config_obj.m_network_type = static_cast<monero::monero_network_type>(this->network_type);
monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet (wallet_config_obj, nullptr));
if(monero_wallet_obj.get()) std::cout << "\033[1;35;49m" << "created wallet \"" << path << ".keys\"" << "\033[0m" << std::endl;
@ -76,13 +75,11 @@ int neroshop::Wallet::create_from_seed(const std::string& seed, const std::strin
neroshop::print("Wallet file with the same name already exists", 1);
return static_cast<int>(WalletError::AlreadyExists);
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_mnemonic (path, password, network_type, mnemonic));
monero::monero_wallet_config wallet_config_obj;
wallet_config_obj.m_path = path;
wallet_config_obj.m_password = password;
wallet_config_obj.m_network_type = this->network_type;
wallet_config_obj.m_network_type = static_cast<monero::monero_network_type>(this->network_type);
wallet_config_obj.m_seed = seed;
monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet (wallet_config_obj, nullptr));
@ -106,13 +103,11 @@ int neroshop::Wallet::create_from_keys(const std::string& primary_address, const
neroshop::print("Wallet file with the same name already exists", 1);
return static_cast<int>(WalletError::AlreadyExists);
}
// This is deprecated :(
////monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_keys(path, password, network_type, primary_address, view_key, spend_key));
monero::monero_wallet_config wallet_config_obj;
wallet_config_obj.m_path = path;
wallet_config_obj.m_password = password;
wallet_config_obj.m_network_type = this->network_type;
wallet_config_obj.m_network_type = static_cast<monero::monero_network_type>(this->network_type);
wallet_config_obj.m_primary_address = primary_address;
wallet_config_obj.m_private_view_key = view_key;
wallet_config_obj.m_private_spend_key = spend_key;
@ -129,13 +124,10 @@ int neroshop::Wallet::create_from_keys(const std::string& primary_address, const
//-------------------------------------------------------
int neroshop::Wallet::restore_from_seed(const std::string& seed)
{
// This is deprecated :(
//monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_mnemonic("", "", network_type, mnemonic)); // set path to "" for an in-memory wallet
monero::monero_wallet_config wallet_config_obj;
wallet_config_obj.m_path = "";
wallet_config_obj.m_path = ""; // set path to "" for an in-memory wallet
wallet_config_obj.m_password = "";
wallet_config_obj.m_network_type = this->network_type;
wallet_config_obj.m_network_type = static_cast<monero::monero_network_type>(this->network_type);
wallet_config_obj.m_seed = seed;
wallet_config_obj.m_restore_height = 0;
@ -148,17 +140,15 @@ int neroshop::Wallet::restore_from_seed(const std::string& seed)
int neroshop::Wallet::restore_from_keys(const std::string& primary_address, const std::string& view_key, const std::string& spend_key)
{
// Check validity of primary address
if(!monero_utils::is_valid_address(primary_address, this->network_type)) {
if(!monero_utils::is_valid_address(primary_address, static_cast<monero::monero_network_type>(this->network_type))) {
neroshop::print("Invalid Monero address", 1);
return false;
return static_cast<int>(WalletError::IsNotOpened);
}
// This is deprecated :(
//monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero_wallet_full::create_wallet_from_keys ("", "", network_type, primary_address, view_key, spend_key)); // set path to "" for an in-memory wallet
monero::monero_wallet_config wallet_config_obj;
wallet_config_obj.m_path = "";
wallet_config_obj.m_path = ""; // set path to "" for an in-memory wallet
wallet_config_obj.m_password = "";
wallet_config_obj.m_network_type = this->network_type;
wallet_config_obj.m_network_type = static_cast<monero::monero_network_type>(this->network_type);
wallet_config_obj.m_primary_address = primary_address;
wallet_config_obj.m_private_view_key = view_key;
wallet_config_obj.m_private_spend_key = spend_key;
@ -175,7 +165,7 @@ int neroshop::Wallet::open(const std::string& path, const std::string& password)
}
try {
monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero::monero_wallet_full::open_wallet(path, password, this->network_type));
monero_wallet_obj = std::unique_ptr<monero_wallet_full>(monero::monero_wallet_full::open_wallet(path, password, static_cast<monero::monero_network_type>(this->network_type)));
} catch (const std::exception& e) {
std::string error_msg = e.what();
neroshop::print(error_msg, 1);//tools::error::invalid_password
@ -200,8 +190,16 @@ int neroshop::Wallet::open(const std::string& path, const std::string& password)
//-------------------------------------------------------
void neroshop::Wallet::close(bool save)
{
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
monero_wallet_obj->close(save);
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
monero_wallet_obj->close(save);
break;
case WalletType::Wownero:
break;
default:
break;
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::upload(bool open, std::string password) { // opens the wallet file
@ -226,7 +224,7 @@ bool neroshop::Wallet::verify_password(const std::string& password) {
return verify_message(password, this->password_hash);
}
//-------------------------------------------------------
// refer to https://moneroecosystem.org/monero-cpp/structmonero_1_1monero__tx__config.html
// refer to https://woodser.github.io/monero-cpp/doxygen/structmonero_1_1monero__tx__config.html
//-------------------------------------------------------
void neroshop::Wallet::transfer(const std::string& address, double amount) {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
@ -237,11 +235,10 @@ void neroshop::Wallet::transfer(const std::string& address, double amount) {
neroshop::print("Monero address is invalid", 1); return;
}
// Convert monero to piconero
double piconero = 0.000000000001;
uint64_t monero_to_piconero = amount / piconero; //std::cout << neroshop::string::precision(amount, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
uint64_t monero_to_piconero = amount / PICONERO; //std::cout << neroshop::string::precision(amount, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
// TODO: for the 2-of-3 escrow system, take 0.5% of order total in piconeros
// Check if amount is zero or too low
if((amount < piconero) || (monero_to_piconero == 0)) {
if((amount < PICONERO) || (monero_to_piconero == 0)) {
neroshop::print("Nothing to send (amount is zero)", 1); return;
}
// Check if balance is sufficient
@ -267,7 +264,7 @@ void neroshop::Wallet::transfer(const std::string& address, double amount) {
bool in_pool = sent_tx->m_in_tx_pool.get(); // true
// Get tx fee and hash
uint64_t fee = sent_tx->m_fee.get(); // "Are you sure you want to send ...?"
std::cout << "Estimated fee: " << (fee * piconero) << "\n";
std::cout << "Estimated fee: " << (fee * PICONERO) << "\n";
//uint64_t deducted_amount = (monero_to_piconero + fee);
std::string tx_hash = monero_wallet_obj->relay_tx(*sent_tx); // recipient receives notification within 5 seconds
std::cout << "Tx hash: " << tx_hash << "\n";
@ -288,7 +285,6 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
tx_config.m_account_index = 0; // withdraw funds from this account
tx_config.m_relay = false; // create transaction and relay to the network if true
double piconero = 0.000000000001;
// Calculate the total amount owed
double total_amount = 0.000000000000;
for (const auto& address : payment_addresses) {
@ -296,7 +292,7 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
}
std::cout << "Total amount to pay: " << total_amount << " (xmr)\n";
// Check if balance is sufficient
uint64_t total_to_piconero = total_amount / piconero;
uint64_t total_to_piconero = total_amount / PICONERO;
std::cout << "Wallet balance (spendable): " << monero_wallet_obj->get_unlocked_balance() << " (picos)\n";
std::cout << "Amount to send: " << total_to_piconero << " (picos)\n";
if(monero_wallet_obj->get_unlocked_balance() < total_to_piconero) {
@ -311,7 +307,7 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
continue; // skip to the next address
}
// Convert monero to piconero
uint64_t monero_to_piconero = address.second / piconero; //std::cout << neroshop::string::precision(address.second, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
uint64_t monero_to_piconero = address.second / PICONERO; //std::cout << neroshop::string::precision(address.second, 12) << " xmr to piconero: " << monero_to_piconero << "\n";
destinations.push_back(std::make_shared<monero_destination>(address.first, monero_to_piconero));
// Print address and amount
std::cout << "Address: " << address.first << ", Amount: " << address.second << std::endl;
@ -326,13 +322,27 @@ void neroshop::Wallet::transfer(const std::vector<std::pair<std::string, double>
}
//-------------------------------------------------------
std::string neroshop::Wallet::sign_message(const std::string& message, monero_message_signature_type signature_type) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->sign_message(message, signature_type, 0, 0);
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->sign_message(message, signature_type, 0, 0);
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
bool neroshop::Wallet::verify_message(const std::string& message, const std::string& signature) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->verify_message(message, monero_wallet_obj.get()->get_primary_address(), signature).m_is_good;
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->verify_message(message, monero_wallet_obj.get()->get_primary_address(), signature).m_is_good;
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
@ -347,17 +357,33 @@ monero::monero_subaddress neroshop::Wallet::create_subaddress(unsigned int accou
}
//-------------------------------------------------------
//-------------------------------------------------------
void neroshop::Wallet::set_wallet_type(WalletType wallet_type) {
this->wallet_type = wallet_type;
}
//-------------------------------------------------------
// NOTE: It is IMPOSSIBLE to change the network type of a pre-existing monero wallet, but it can be set before its creation
void neroshop::Wallet::set_network_type(monero::monero_network_type network_type) {
if(get_network_type() == network_type) return;
if(monero_wallet_obj.get()) throw std::runtime_error("Cannot change the network type of " + get_network_type_string() + " wallet");
void neroshop::Wallet::set_network_type(WalletNetworkType network_type) {
auto current_network_type = get_network_type();
if(current_network_type == network_type) {
return;
}
auto network_type_str = get_network_type_as_string();
switch(wallet_type) {
case WalletType::Monero:
if(monero_wallet_obj.get()) throw std::runtime_error("cannot change " + network_type_str + " wallet network type");
break;
case WalletType::Wownero:
break;
default:
break;
}
this->network_type = network_type;
}
//-------------------------------------------------------
void neroshop::Wallet::set_network_type_by_string(const std::string& network_type) {
if(network_type == "mainnet") set_network_type(monero_network_type::MAINNET);
if(network_type == "testnet") set_network_type(monero_network_type::TESTNET);
if(network_type == "stagenet") set_network_type(monero_network_type::STAGENET);
if(network_type == "mainnet") set_network_type(WalletNetworkType::Mainnet);
if(network_type == "testnet") set_network_type(WalletNetworkType::Testnet);
if(network_type == "stagenet") set_network_type(WalletNetworkType::Stagenet);
std::cout << "Monero network type has been set to: " << network_type << std::endl;
}
//-------------------------------------------------------
@ -471,8 +497,6 @@ std::string neroshop::Wallet::generate_uri(const std::string& payment_address, d
//-------------------------------------------------------
// override
//-------------------------------------------------------
// I get the error: "../../src/xcb_io.c:641: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed." when using this function
// or maybe its just some random threading error
void neroshop::Wallet::on_sync_progress(uint64_t height, uint64_t start_height, uint64_t end_height, double percent_done, const std::string& message) {
// all of this takes place in a separate thread
// if monero_wallet is already synced, skip this function (this function keeps spamming throughout the entire app session -.-)
@ -514,8 +538,7 @@ void neroshop::Wallet::on_output_received(const monero_output_wallet& output) {
int account_index = output.m_account_index.get(); // should always be 0 (default)
int subaddress_index = output.m_subaddress_index.get();
// get balance (actual)
double piconero = 0.000000000001;
double balance = (amount * piconero);
double balance = (amount * PICONERO);
// get the subaddress
std::string subaddress = get_address(subaddress_index);
// you've received some xmr but it may be unspendable for the meantime
@ -529,25 +552,6 @@ void neroshop::Wallet::on_output_received(const monero_output_wallet& output) {
// at this point, any recently used subaddress will be removed from vector returned by Wallet::addresses_unused() (this is the final confirmation) - sometimes this message shows twice
if(is_confirmed) {
std::cout << "\033[1;32;49m" << "You have received " << std::fixed << std::setprecision(12) << balance << std::fixed << std::setprecision(2) << " xmr " << "(txid: " << tx_hash << ", account_idx: " << account_index << ", subaddress_idx: " << subaddress_index << ")" << "\033[0m" << std::endl;
// set message box text then show message box
// box text0 (label)
/*neroshop::Message::get_second()->set_text(String::to_string_with_precision(balance, 12) + " xmr was deposited into your account ", 0, 107, 61);//56, 117, 11);//if(get_monero_wallet() != nullptr) //neroshop::Message::get_second()->set_text(std::string("You have received " + String::to_string_with_precision(balance, 12) + " xmr"), 56, 117, 11);//34, 139, 34);//neroshop::Message message(std::string("output received: " + std::to_string(balance) + " xmr"), 34, 139, 34);//(address: " + String::get_first_n_characters(subaddress, 4) + ".." + String::get_last_n_characters(subaddress, 4) + ")"
neroshop::Message::get_second()->get_label(0)->set_alignment("none");
neroshop::Message::get_second()->get_label(0)->set_relative_position((neroshop::Message::get_second()->get_width() / 2) - (neroshop::Message::get_second()->get_label(0)->get_width() / 2), ((neroshop::Message::get_second()->get_height() - neroshop::Message::get_second()->get_label(0)->get_height()) / 2) - 20);
std::cout << neroshop::Message::get_second()->get_label(0)->get_string() << " (width: " << (neroshop::Message::get_second()->get_label(0)->get_string().length() * 10) << ")" << std::endl;
// box text1
int text_gap = 10;//5; // space between text0 and text1 (vertically)
neroshop::Message::get_second()->set_text(String::get_first_n_characters(subaddress, 15) + ".." + String::get_last_n_characters(subaddress, 15) + " (idx: " + std::to_string(subaddress_index) + ")", 1);
neroshop::Message::get_second()->get_label(1)->set_alignment("none");//neroshop::Message::get_second()->get_label(0)->get_relative_x()
neroshop::Message::get_second()->get_label(1)->set_relative_position(((neroshop::Message::get_second()->get_width() / 2) - (neroshop::Message::get_second()->get_label(1)->get_string().length()*10 / 2)) - (10 * std::to_string(subaddress_index).length()), neroshop::Message::get_second()->get_label(0)->get_relative_y() + neroshop::Message::get_second()->get_label(0)->get_height() + text_gap); // 1
// cancel button
neroshop::Message::get_second()->get_button(0)->set_text("Close");
neroshop::Message::get_second()->get_button(0)->set_color(214, 31, 31, 1.0);
neroshop::Message::get_second()->get_button(0)->set_relative_position((neroshop::Message::get_second()->get_width() / 2) - (neroshop::Message::get_second()->get_button(0)->get_width() / 2), neroshop::Message::get_second()->get_height() - neroshop::Message::get_second()->get_button(0)->get_height() - 20);//200-30(height)-20(bottompadding) = 150(button_y)
// show message box, labels and buttons
neroshop::Message::get_second()->get_label(1)->show();
neroshop::Message::get_second()->get_button(0)->show();
neroshop::Message::get_second()->show();*/
}
}
//-------------------------------------------------------
@ -555,9 +559,8 @@ void neroshop::Wallet::on_balances_changed(uint64_t new_balance, uint64_t new_un
// if wallet is not fully synced with a daemon, skip this function
if(!monero_wallet_obj.get()) return;
if(!monero_wallet_obj.get()->is_synced()) return;
double piconero = 0.000000000001;
double balance = (new_balance * piconero);
double unlocked_balance = (new_unlocked_balance * piconero);
double balance = (new_balance * PICONERO);
double unlocked_balance = (new_unlocked_balance * PICONERO);
// if total balance is still locked, display it
// but if total balance is fully unlocked, then you already have the balance so no need to keep displaying it
if(unlocked_balance != balance) {
@ -595,7 +598,8 @@ void neroshop::Wallet::daemon_open(const std::string& daemon_dir, bool confirm_e
std::string args = (" --data-dir=" + data_dir) + (" --rpc-bind-ip=" + ip) + (" --rpc-bind-port=38081");
if(confirm_external_bind == true) { args = args + " --confirm-external-bind"; }
if(confirm_external_bind == true && restricted_rpc == true) { args = args + " --restricted-rpc"; }
if(neroshop::string::lower(this->get_network_type_string()) != "mainnet") args = args + (" --" + neroshop::string::lower(this->get_network_type_string()));
auto network_type_str = get_network_type_as_string();
if(neroshop::string::lower(network_type_str) != "mainnet") args = args + (" --" + neroshop::string::lower(network_type_str));
args = args + (" --detach"); // https://monero.stackexchange.com/questions/12005/what-is-the-difference-between-monerod-detach-and-monerod-non-interactive
std::cout << "\033[1;95;49m" << "$ " << daemon_dir + args << "\033[0m" << std::endl;
// start the daemon (monerod) as a new process on launch
@ -688,14 +692,13 @@ void neroshop::Wallet::wallet_info() {
std::string restored_primary = monero_wallet_obj->get_primary_address(); // same as: monero_wallet_obj->get_account(0, true).m_primary_address.get()
std::cout << "primary_address: " << restored_primary << std::endl;
uint64_t balance_raw = monero_wallet_obj->get_balance(); // can specify account and subaddress indices
double piconero = 0.000000000001; // the smallest unit of a monero (monero has 12 decimal places) // https://web.getmonero.org/resources/moneropedia/denominations.html
double balance = (double)balance_raw * piconero;
double balance = (double)balance_raw * PICONERO;
std::cout << std::fixed << std::setprecision(12) << "balance: " << balance << std::fixed << std::setprecision(2) << std::endl;
// account ---------------------------------------------------------------
// account_0 is the default/main account where the primary address derives from
monero_account account = monero_wallet_obj->get_account(0, true); // get account with subaddresses
uint64_t unlocked_balance_raw = account.m_unlocked_balance.get();
double unlocked_balance = (double)unlocked_balance_raw * piconero;
double unlocked_balance = (double)unlocked_balance_raw * PICONERO;
std::cout << std::fixed << std::setprecision(12) << "unlocked_balance: " << unlocked_balance << std::fixed << std::setprecision(2) << std::endl; // uint64_t
// view and spend keys ----------------------------------------------------
std::cout << "view_key: " << get_view_keys().first << std::endl;
@ -719,6 +722,33 @@ void neroshop::Wallet::set_tx_note(const std::string& txid, const std::string& t
//-------------------------------------------------------
// getters
//-------------------------------------------------------
neroshop::WalletType neroshop::Wallet::get_wallet_type() const {
return wallet_type;
}
//-------------------------------------------------------
neroshop::WalletNetworkType neroshop::Wallet::get_network_type() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) return this->network_type;
return static_cast<WalletNetworkType>(monero_wallet_obj->get_network_type());
case WalletType::Wownero:
return this->network_type;
default:
return this->network_type;
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_network_type_as_string() const {
auto network_type = get_network_type();
switch(network_type) {
case WalletNetworkType::Mainnet: return "mainnet"; // 0
case WalletNetworkType::Testnet: return "testnet"; // 1
case WalletNetworkType::Stagenet: return "stagenet"; // 2
default: return "mainnet";
}
}
//-------------------------------------------------------
//-------------------------------------------------------
double neroshop::Wallet::get_sync_percentage() const {
std::lock_guard<std::mutex> lock(wallet_data_mutex);
return percentage;
@ -746,47 +776,137 @@ std::string neroshop::Wallet::get_sync_message() const {
//-------------------------------------------------------
//-------------------------------------------------------
std::string neroshop::Wallet::get_primary_address() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_primary_address();// same as://monero_wallet_obj->get_account(0, true).m_primary_address.get();//monero_account monero::monero_wallet_full::get_account ( const uint32_t account_idx,bool include_subaddresses ) //const
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_primary_address(); // same as: monero_wallet_obj->get_account(0, true).m_primary_address.get();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_address(unsigned int index) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_account(0, true).m_subaddresses[index].m_address.get(); // account_idx "0" is default
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_account(0, true).m_subaddresses[index].m_address.get(); // account_idx is 0
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
unsigned int neroshop::Wallet::get_address_count() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_account(0, true).m_subaddresses.size();// all subaddresses will be created on the default account at index 0
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_account(0, true).m_subaddresses.size(); // subaddresses will be created on account_idx 0
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
uint64_t neroshop::Wallet::get_balance_raw() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_balance(); // get wallet balance
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
uint64_t neroshop::Wallet::get_balance_raw(unsigned int account_index) const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_balance(account_index); // get balance from account
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//------------------------------------------------------- for some reason, "account.m_subaddresses[i].m_address.get()" fails, but "monero_wallet_obj->get_account(0, true).m_subaddresses.size()" usually succeeds ...-> https://stackoverflow.com/questions/68733975/difficult-to-understand-runtime-error-this-is-initialized-failure-in-boost#comment121472560_68733975
double neroshop::Wallet::get_balance_raw(unsigned int account_index, unsigned int subaddress_index) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
// get balance from subaddress
if(subaddress_index > 0) return monero_wallet_obj->get_balance(account_index, subaddress_index);//uint64_t monero::monero_wallet_full::get_balance ( uint32_t account_idx, uint32_t subaddress_idx ) //const
// get balance from account (primary address)
else return monero_wallet_obj->get_balance(account_index);//uint64_t monero::monero_wallet_full::get_balance ( uint32_t account_idx ) const
return 0.0;
} // "balance"
//-------------------------------------------------------
double neroshop::Wallet::get_unlocked_balance_raw(unsigned int account_index, unsigned int subaddress_index) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
// get a subaddress's unlocked balance
if(subaddress_index > 0) return monero_wallet_obj->get_unlocked_balance(account_index, subaddress_index);//uint64_t monero::monero_wallet_full::get_unlocked_balance ( uint32_t account_idx, uint32_t subaddress_idx ) const
// get an account's unlocked balance (primary address)
else return monero_wallet_obj->get_unlocked_balance(account_index);//uint64_t monero::monero_wallet_full::get_unlocked_balance ( ) const//uint64_t monero::monero_wallet_full::get_unlocked_balance ( uint32_t account_idx ) const
return 0.0;
} // "balance"
uint64_t neroshop::Wallet::get_balance_raw(unsigned int account_index, unsigned int subaddress_index) const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_balance(account_index, subaddress_index); // get balance from subaddress
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
uint64_t neroshop::Wallet::get_unlocked_balance_raw() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_unlocked_balance(); // get wallet unlocked balance
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
uint64_t neroshop::Wallet::get_unlocked_balance_raw(unsigned int account_index) const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_unlocked_balance(account_index); // get unlocked balance from account
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
uint64_t neroshop::Wallet::get_unlocked_balance_raw(unsigned int account_index, unsigned int subaddress_index) const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_unlocked_balance(account_index, subaddress_index); // get unlocked balance from subaddress
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
double neroshop::Wallet::get_balance() const {
return get_balance_raw() * PICONERO;
}
//-------------------------------------------------------
double neroshop::Wallet::get_balance(unsigned int account_index) const {
return get_balance_raw(account_index) * PICONERO;
}
//-------------------------------------------------------
double neroshop::Wallet::get_balance(unsigned int account_index, unsigned int subaddress_index) const {
double piconero = 0.000000000001;
return get_balance_raw(account_index, subaddress_index) * piconero;
return get_balance_raw(account_index, subaddress_index) * PICONERO;
}
//-------------------------------------------------------
double neroshop::Wallet::get_unlocked_balance() const {
return get_unlocked_balance_raw() * PICONERO;
}
//-------------------------------------------------------
double neroshop::Wallet::get_unlocked_balance(unsigned int account_index) const {
return get_unlocked_balance_raw(account_index) * PICONERO;
}
//-------------------------------------------------------
double neroshop::Wallet::get_unlocked_balance(unsigned int account_index, unsigned int subaddress_index) const {
double piconero = 0.000000000001;
return get_unlocked_balance_raw(account_index, subaddress_index) * piconero;
return get_unlocked_balance_raw(account_index, subaddress_index) * PICONERO;
}
//-------------------------------------------------------
std::vector<std::string> neroshop::Wallet::get_transactions() const {
@ -842,61 +962,105 @@ std::string neroshop::Wallet::get_last_subaddress() const
//std::string neroshop::Wallet::get_tx_note(const std::string& txid) const {return "";} // "get_tx_note <txid>" - useful for retrieving address information
//-------------------------------------------------------
std::string neroshop::Wallet::get_private_view_key() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_private_view_key();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_private_view_key();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_public_view_key() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_public_view_key();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_public_view_key();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::pair<std::string, std::string> neroshop::Wallet::get_view_keys() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return std::make_pair(monero_wallet_obj->get_private_view_key(), monero_wallet_obj->get_public_view_key());
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return std::make_pair(monero_wallet_obj->get_private_view_key(), monero_wallet_obj->get_public_view_key());
case WalletType::Wownero:
return std::make_pair("", "");
default:
return std::make_pair("", "");
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_private_spend_key() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_private_spend_key();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_private_spend_key();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_public_spend_key() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_public_spend_key();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_public_spend_key();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::pair<std::string, std::string> neroshop::Wallet::get_spend_keys() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return std::make_pair(monero_wallet_obj->get_private_spend_key(), monero_wallet_obj->get_public_spend_key());
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return std::make_pair(monero_wallet_obj->get_private_spend_key(), monero_wallet_obj->get_public_spend_key());
case WalletType::Wownero:
return std::make_pair("", "");
default:
return std::make_pair("", "");
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_seed() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_seed();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_seed();
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-Image * neroshop::Wallet::get_qr_code() const {} // returns address qrcode // "show_qr_code"
//-Image * neroshop::Wallet::get_qr_code(unsigned int address_index) const {} // returns the qrcode of the address at "index"
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
//-------------------------------------------------------
std::string neroshop::Wallet::get_path() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->monero_wallet_full::get_path(); // returns the path of this wallet's file on disk (without the .keys ext)
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->monero_wallet_full::get_path(); // returns the path of this wallet's file on disk (without the .keys ext)
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_description() const {
/*std::string neroshop::Wallet::get_description() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return "";
} // "wallet_info"
}*/
//-------------------------------------------------------
std::string neroshop::Wallet::get_type() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
@ -904,65 +1068,122 @@ std::string neroshop::Wallet::get_type() const {
} // "wallet_info": Normal, HW
//-------------------------------------------------------
unsigned int neroshop::Wallet::get_daemon_height() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_daemon_height();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_daemon_height();
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
unsigned int neroshop::Wallet::get_height() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_height();
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_height();
case WalletType::Wownero:
return 0;
default:
return 0;
}
}
//-------------------------------------------------------
unsigned int neroshop::Wallet::get_height_by_date(int year, int month, int day) const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_height_by_date(year, month, day);
}
//-------------------------------------------------------
monero::monero_network_type neroshop::Wallet::get_network_type() const {
if(!monero_wallet_obj.get()) return this->network_type;
return monero_wallet_obj->get_network_type();
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_network_type_string() const {
switch(this->get_network_type()) {
case monero_network_type::MAINNET: return "mainnet"; break; // 0
case monero_network_type::TESTNET: return "testnet"; break; // 1
case monero_network_type::STAGENET: return "stagenet"; break; // 2
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->get_height_by_date(year, month, day);
case WalletType::Wownero:
return 0;
default:
return 0;
}
return "mainnet";
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_status() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return "";
} // "status" - Check current status of wallet.
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return "";
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
std::string neroshop::Wallet::get_version() const {
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
//monero_version monero::monero_wallet_full::get_version();
return "";
} // "version" - Check software version.
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return "";//monero_version monero::monero_wallet_full::get_version();
break;
case WalletType::Wownero:
return "";
default:
return "";
}
}
//-------------------------------------------------------
monero_wallet_full * neroshop::Wallet::get_monero_wallet() const
{
return monero_wallet_obj.get();
}
//-------------------------------------------------------
// callbacks
//-------------------------------------------------------
void neroshop::Wallet::load_from_config(std::string/*const std::string&*/ password) // load configs on opening
{
}
//-------------------------------------------------------
//-------------------------------------------------------
//void neroshop::Wallet::set_daemon() {} // "set_daemon <host>[:<port>] [trusted|untrusted|this-is-probably-a-spy-node]" - connects to a daemon
//-------------------------------------------------------
//void neroshop::Wallet::refresh() {}
//-------------------------------------------------------
bool neroshop::Wallet::is_opened() const {
switch(wallet_type) {
case WalletType::Monero:
return (monero_wallet_obj != nullptr);
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
bool neroshop::Wallet::is_connected_to_daemon() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->is_connected_to_daemon();
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
bool neroshop::Wallet::is_synced() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
return monero_wallet_obj->is_synced();
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
bool neroshop::Wallet::is_daemon_synced() const {
switch(wallet_type) {
case WalletType::Monero:
if(!monero_wallet_obj.get()) throw std::runtime_error("monero_wallet_full is not opened");
if(!monero_wallet_obj->is_connected_to_daemon()) {
return false;
}
return monero_wallet_obj->is_daemon_synced(); // will cause crash if wallet is not connected to daemon
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
//-------------------------------------------------------
bool neroshop::Wallet::file_exists(const std::string& filename) const {
@ -970,6 +1191,18 @@ bool neroshop::Wallet::file_exists(const std::string& filename) const {
}
//-------------------------------------------------------
bool neroshop::Wallet::is_valid_address(const std::string& address) const {
return monero_utils::is_valid_address(address, this->get_network_type());
auto network_type = get_network_type();
switch(wallet_type) {
case WalletType::Monero:
return monero_utils::is_valid_address(address, static_cast<monero::monero_network_type>(network_type));
case WalletType::Wownero:
return false;
default:
return false;
}
}
//-------------------------------------------------------
bool neroshop::Wallet::is_cryptonote_based() const {
return (wallet_type == WalletType::Monero || wallet_type == WalletType::Wownero);
}
//-------------------------------------------------------

@ -3,14 +3,10 @@
#ifndef WALLET_HPP_NEROSHOP
#define WALLET_HPP_NEROSHOP
#include <daemon/monero_daemon.h>
#include <daemon/monero_daemon_model.h>
#include <utils/gen_utils.h>
#include <utils/monero_utils.h>
#include <wallet/monero_wallet.h>
#include <wallet/monero_wallet_full.h>
#include <wallet/monero_wallet_keys.h>
#include <wallet/monero_wallet_model.h>
#define PICONERO 0.000000000001 // the smallest unit of a monero (monero has 12 decimal places) // https://web.getmonero.org/resources/moneropedia/denominations.html
#include "wallets/monero.hpp"
//#include "wallets/wownero.hpp"
#include <iostream>
#include <string>
@ -22,6 +18,17 @@ namespace neroshop {
class Process; // forward declaration
enum class WalletType {
Monero = 0,
Wownero
};
enum class WalletNetworkType : uint8_t { // refer to daemon/monero_daemon_model.h
Mainnet = 0,
Testnet,
Stagenet
};
enum class WalletError {
Ok = 0,
WrongPassword,
@ -84,27 +91,42 @@ public:
//void explore_tx(const std::string& tx_hash);
void wallet_info();
std::string sign_message(const std::string& message, monero_message_signature_type signature_type) const;//, unsigned int account_idx = 0, unsigned int subaddress_idx = 0) const;
std::string sign_message(const std::string& message, monero_message_signature_type signature_type) const;
bool verify_message(const std::string& message, const std::string& signature) const;
// setters
void set_network_type(monero::monero_network_type network_type);
void set_wallet_type(WalletType wallet_type);
void set_network_type(WalletNetworkType network_type);
void set_network_type_by_string(const std::string& network_type);
void set_tx_note(const std::string& txid, const std::string& tx_note); // "set_tx_note <txid> [free note text here]" - useful for filling address information
// getters
WalletType get_wallet_type() const;
double get_sync_percentage() const;
unsigned long long get_sync_height() const;
unsigned long long get_sync_start_height() const;
unsigned long long get_sync_end_height() const;
std::string get_sync_message() const;
std::string get_primary_address() const; // returns primary address string // "address"
std::string get_primary_address() const;
std::string get_address(unsigned int index) const; // returns address at "index"'s string (primary address is index 0) // "address all"
unsigned int get_address_count() const; // address_list.size();
double get_balance_raw(unsigned int account_index = 0, unsigned int subaddress_index = 0) const; // "balance"
double get_unlocked_balance_raw(unsigned int account_index = 0, unsigned int subaddress_index = 0) const; // "balance"
double get_balance(unsigned int account_index = 0, unsigned int subaddress_index = 0) const;
double get_unlocked_balance(unsigned int account_index = 0, unsigned int subaddress_index = 0) const;
unsigned int get_address_count() const;
uint64_t get_balance_raw() const;
uint64_t get_balance_raw(unsigned int account_index) const;
uint64_t get_balance_raw(unsigned int account_index, unsigned int subaddress_index) const;
uint64_t get_unlocked_balance_raw() const;
uint64_t get_unlocked_balance_raw(unsigned int account_index) const;
uint64_t get_unlocked_balance_raw(unsigned int account_index, unsigned int subaddress_index) const;
double get_balance() const;
double get_balance(unsigned int account_index) const;
double get_balance(unsigned int account_index, unsigned int subaddress_index) const;
double get_unlocked_balance() const;
double get_unlocked_balance(unsigned int account_index) const;
double get_unlocked_balance(unsigned int account_index, unsigned int subaddress_index) const;
std::vector<std::string> get_transactions() const; // "show_transfers"
unsigned int get_transactions_count() const;
// subaddress
@ -117,24 +139,29 @@ public:
std::string get_public_spend_key() const;
std::pair<std::string, std::string> get_spend_keys() const; // secret, public // "spendkey"
std::string get_seed() const; // "seed"
//-Image * get_qr_code() const; // returns address qrcode // "show_qr_code"
//-Image * get_qr_code(unsigned int address_index) const; // returns the qrcode of the address at "index"
std::string get_path() const; // "wallet_info"
std::string get_description() const; // "wallet_info"
std::string get_path() const;
//std::string get_description() const;
std::string get_type() const; // "wallet_info": Normal, HW
unsigned int get_daemon_height() const;
unsigned int get_height() const;
unsigned int get_height_by_date(int year, int month, int day) const;
monero::monero_network_type get_network_type() const; // "wallet_info": Mainnet, Testnet, Stagenet
std::string get_network_type_string() const; // "wallet_info": Mainnet, Testnet, Stagenet
WalletNetworkType get_network_type() const; // "wallet_info": Mainnet, Testnet, Stagenet
std::string get_network_type_as_string() const; // "wallet_info": Mainnet, Testnet, Stagenet
std::string get_status() const; // "status" - Check current status of wallet.
std::string get_version() const; // "version" - Check software version.
// get wallet handles (monero, wownero, etc.)
monero_wallet_full * get_monero_wallet() const;
//wownero_wallet_full * get_wownero_wallet() const;
std::vector<std::string> recent_address_list; // recently used addresses
// boolean functions
bool is_opened() const;
bool is_connected_to_daemon() const;
bool is_synced() const;
bool is_daemon_synced() const;
bool file_exists(const std::string& filename) const;
bool is_valid_address(const std::string& address) const;
bool is_cryptonote_based() const;
// friends
friend class Seller; // seller can access wallet private members
friend class WalletController;
@ -145,8 +172,10 @@ private:
// callbacks
void load_from_config(std::string/*const std::string&*/ password = "supersecretpassword123");
private:
WalletType wallet_type; // can switch between different wallets
static WalletNetworkType network_type;
std::unique_ptr<monero::monero_wallet_full> monero_wallet_obj; // monero wallet
static monero::monero_network_type network_type; // default will be mainnet when this application is released
//std::unique_ptr<wownero::wownero_wallet_full> wownero_wallet_obj;
std::unique_ptr<Process> process; // monerod process // every wallet will have its own process
volatile double percentage; // sync progress
mutable std::mutex wallet_data_mutex;

@ -0,0 +1,15 @@
#pragma once
#ifndef MONERO_HPP_NEROSHOP
#define MONERO_HPP_NEROSHOP
#include <daemon/monero_daemon.h>
#include <daemon/monero_daemon_model.h>
#include <utils/gen_utils.h>
#include <utils/monero_utils.h>
#include <wallet/monero_wallet.h>
#include <wallet/monero_wallet_full.h>
#include <wallet/monero_wallet_keys.h>
#include <wallet/monero_wallet_model.h>
#endif // MONERO_HPP_NEROSHOP

@ -0,0 +1,15 @@
#pragma once
#ifndef WOWNERO_HPP_NEROSHOP
#define WOWNERO_HPP_NEROSHOP
#include <daemon/wownero_daemon.h>
#include <daemon/wownero_daemon_model.h>
#include <utils/gen_utils.h>
#include <utils/wownero_utils.h>
#include <wallet/wownero_wallet.h>
#include <wallet/wownero_wallet_full.h>
#include <wallet/wownero_wallet_keys.h>
#include <wallet/wownero_wallet_model.h>
#endif // WOWNERO_HPP_NEROSHOP

@ -1852,34 +1852,27 @@ int neroshop::Backend::loginWithWalletFile(WalletController* wallet_controller,
//----------------------------------------
// Load RSA keys from file
std::string config_path = NEROSHOP_DEFAULT_KEYS_PATH;
std::string public_key_path = config_path + "/" + primary_address + ".pub";
std::string private_key_path = config_path + "/" + primary_address + ".key";
std::string public_key_path = config_path + "/" + (primary_address + ".pub");
std::string private_key_path = config_path + "/" + (primary_address + ".key");
//----------------------------------------
// Load public_key
// Load public_key (optional)
std::ifstream public_key_file(public_key_path);
if (!public_key_file) {
// Handle file open error
throw std::runtime_error("Failed to open public key file: " + public_key_path);
if (public_key_file) {
std::ostringstream buffer;
buffer << public_key_file.rdbuf();
std::string public_key = buffer.str();
user_controller->_user->set_public_key(public_key);
}
std::ostringstream buffer0;
buffer0 << public_key_file.rdbuf();
std::string public_key = buffer0.str();
//----------------------------------------
// Load private_key
// Load private_key (mandatory)
std::ifstream private_key_file(private_key_path);
if (!private_key_file) {
// Handle file open error
throw std::runtime_error("Failed to open private key file: " + private_key_path);
}
std::ostringstream buffer;
buffer << private_key_file.rdbuf();
std::string private_key = buffer.str();
//----------------------------------------
// Set RSA private key
user_controller->_user->set_public_key(public_key);
user_controller->_user->set_private_key(private_key);
user_controller->_user->set_private_key(private_key); // Set RSA private key
//----------------------------------------
emit user_controller->userChanged();
emit user_controller->userLogged();

@ -59,7 +59,7 @@ int neroshop::WalletController::open(const QString& path, const QString& passwor
void neroshop::WalletController::close(bool save) {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
_wallet->get_monero_wallet()->close(save);
_wallet->close(save);
// set monero_wallet to nullptr so that we know it has been deleted
_wallet->monero_wallet_obj.reset();
emit walletChanged();
@ -78,13 +78,12 @@ QVariantMap neroshop::WalletController::createUniqueSubaddressObject(unsigned in
QVariantMap subaddress_object;
monero::monero_subaddress subaddress = _wallet->create_subaddress(account_idx,
label.toStdString());
double piconero = 0.000000000001;
subaddress_object.insert("account_index", subaddress.m_account_index.get());
subaddress_object.insert("index", subaddress.m_index.get());
subaddress_object.insert("address", QString::fromStdString(subaddress.m_address.get()));
subaddress_object.insert("label", QString::fromStdString(subaddress.m_label.get()));
subaddress_object.insert("balance", (qulonglong(subaddress.m_balance.get()) * piconero));
subaddress_object.insert("unlocked_balance", (qulonglong(subaddress.m_unlocked_balance.get()) * piconero));
subaddress_object.insert("balance", (qulonglong(subaddress.m_balance.get()) * PICONERO));
subaddress_object.insert("unlocked_balance", (qulonglong(subaddress.m_unlocked_balance.get()) * PICONERO));
subaddress_object.insert("num_unspent_outputs", qulonglong(subaddress.m_num_unspent_outputs.get()));
subaddress_object.insert("is_used", subaddress.m_is_used.get());
subaddress_object.insert("num_blocks_to_unlock", qulonglong(subaddress.m_num_blocks_to_unlock.get())); // uint64_t is an unsigned long long so we have to convert it into a qulonglong
@ -113,6 +112,11 @@ bool neroshop::WalletController::verifyMessage(const QString& message, const QSt
return _wallet->verify_message(message.toStdString(), signature.toStdString());
}
int neroshop::WalletController::getWalletType() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
return static_cast<int>(_wallet->get_wallet_type());
}
int neroshop::WalletController::getNetworkType() const {
if (!_wallet)
@ -123,21 +127,21 @@ int neroshop::WalletController::getNetworkType() const {
QString neroshop::WalletController::getNetworkTypeString() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
return QString::fromStdString(_wallet->get_network_type_string());
return QString::fromStdString(_wallet->get_network_type_as_string());
}
QString neroshop::WalletController::getSeed() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
return "";
return QString::fromStdString(_wallet->get_monero_wallet()->get_seed());
/*if (!_wallet->get_monero_wallet())
return "";*/
return QString::fromStdString(_wallet->get_seed());
}
QStringList neroshop::WalletController::getSeedList() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
QStringList seed_phrase = QString::fromStdString(_wallet->get_monero_wallet()->get_seed())
QStringList seed_phrase = QString::fromStdString(_wallet->get_seed())
.split(' ');
return seed_phrase;
}
@ -145,9 +149,7 @@ QStringList neroshop::WalletController::getSeedList() const {
QString neroshop::WalletController::getPrimaryAddress() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
return QString::fromStdString(_wallet->get_monero_wallet()->get_primary_address());
return QString::fromStdString(_wallet->get_primary_address());
}
QStringList neroshop::WalletController::getAddressesAll() const {
@ -183,60 +185,37 @@ QStringList neroshop::WalletController::getAddressesUnused() const {
double neroshop::WalletController::getBalanceLocked() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
return _wallet->get_monero_wallet()->get_balance() * piconero;
return _wallet->get_balance();
}
double neroshop::WalletController::getBalanceLocked(unsigned int account_index) const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
// primary address balance
return _wallet->get_monero_wallet()->get_balance(account_index) * piconero;
return _wallet->get_balance(account_index);
}
double neroshop::WalletController::getBalanceLocked(unsigned int account_index, unsigned int subaddress_index) const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
// subaddress balance
return _wallet->get_monero_wallet()->get_balance(account_index, subaddress_index) * piconero;
return _wallet->get_balance(account_index, subaddress_index);
}
double neroshop::WalletController::getBalanceUnlocked() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
return _wallet->get_monero_wallet()->get_unlocked_balance() * piconero;
return _wallet->get_unlocked_balance();
}
double neroshop::WalletController::getBalanceUnlocked(unsigned int account_index) const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
// primary address balance unlocked
return _wallet->get_monero_wallet()->get_unlocked_balance(account_index) * piconero;
return _wallet->get_unlocked_balance(account_index);
}
double neroshop::WalletController::getBalanceUnlocked(unsigned int account_index, unsigned int subaddress_index) const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
double piconero = 0.000000000001;
// subaddress balance unlocked
return _wallet->get_monero_wallet()->get_unlocked_balance(account_index, subaddress_index)
* piconero;
return _wallet->get_unlocked_balance(account_index, subaddress_index);
}
@ -245,7 +224,6 @@ QVariantList neroshop::WalletController::getTransfers() const {
if (!_wallet->get_monero_wallet()) throw std::runtime_error("monero_wallet_full is not opened");
// TODO: make this function async or put in a separate thread
std::packaged_task<QVariantList(void)> get_transfers_task([this]() -> QVariantList {
double piconero = 0.000000000001;
monero_transfer_query transfer_query; // optional
auto transfers = _wallet->get_monero_wallet()->get_transfers(transfer_query);
@ -255,11 +233,11 @@ QVariantList neroshop::WalletController::getTransfers() const {
monero_transfer * transfer = transfers[i].get();*/
QVariantMap transfer_object;
transfer_object.insert("amount", (transfer->m_amount.get() * piconero));
transfer_object.insert("amount", (transfer->m_amount.get() * PICONERO));
transfer_object.insert("account_index", transfer->m_account_index.get()); // obviously account index 0
transfer_object.insert("is_incoming", transfer->is_incoming().get());
transfer_object.insert("is_outgoing", transfer->is_outgoing().get());
monero_tx_wallet * tx_wallet = transfer->m_tx.get();
monero_tx_wallet * tx_wallet = transfer->m_tx.get(); // refer to: https://woodser.github.io/monero-cpp/doxygen/structmonero_1_1monero__tx__wallet.html
////transfer_object.insert("", tx_wallet->);
//std::cout << ": " << tx_wallet-> << "\n";
@ -279,6 +257,7 @@ QVariantList neroshop::WalletController::getTransfers() const {
void neroshop::WalletController::nodeConnect(const QString& ip, const QString& port, const QString& username, const QString& password) {
if (!_wallet) throw std::runtime_error("neroshop::Wallet is not initialized");
_wallet->daemon_connect_remote(ip.toStdString(),
port.toStdString(),
username.toStdString(),
@ -287,10 +266,12 @@ void neroshop::WalletController::nodeConnect(const QString& ip, const QString& p
}
void neroshop::WalletController::daemonConnect(const QString& username, const QString& password) {
if (!_wallet) throw std::runtime_error("neroshop::Wallet is not initialized");
_wallet->daemon_connect_local(username.toStdString(), password.toStdString());
}
void neroshop::WalletController::daemonExecute(const QString& daemon_dir, bool confirm_external_bind, bool restricted_rpc, QString data_dir, unsigned int restore_height) {//const {
if (!_wallet) throw std::runtime_error("neroshop::Wallet is not initialized");
_wallet->daemon_open(daemon_dir.toStdString(),
confirm_external_bind,
restricted_rpc,
@ -325,6 +306,11 @@ QString neroshop::WalletController::getSyncMessage() const {
_wallet->message); //QString::fromStdString(wallet->get_sync_message());
}
void neroshop::WalletController::setWalletType(unsigned int wallet_type) {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
_wallet->set_wallet_type(static_cast<WalletType>(wallet_type));
}
void neroshop::WalletController::setNetworkTypeByString(const QString& network_type) {
if (!_wallet)
@ -336,36 +322,30 @@ void neroshop::WalletController::setNetworkTypeByString(const QString& network_t
bool neroshop::WalletController::isConnectedToDaemon() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
return _wallet->get_monero_wallet()->is_connected_to_daemon();
return _wallet->is_connected_to_daemon();
}
bool neroshop::WalletController::isSynced() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
return _wallet->get_monero_wallet()->is_synced();
return _wallet->is_synced();
}
bool neroshop::WalletController::isDaemonSynced() const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
if (!_wallet->get_monero_wallet())
throw std::runtime_error("monero_wallet_full is not opened");
if (!_wallet->get_monero_wallet()->is_connected_to_daemon()) {
return false;
}
return _wallet->get_monero_wallet()
->is_daemon_synced(); // will cause crash if wallet is not connected to daemon
return _wallet->is_daemon_synced();
}
bool neroshop::WalletController::isOpened() const {
return (_wallet->get_monero_wallet() != nullptr);
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
return _wallet->is_opened();
}
bool neroshop::WalletController::fileExists(const QString& filename) const {
if (!_wallet)
throw std::runtime_error("neroshop::Wallet is not initialized");
return _wallet->file_exists(filename.toStdString());
}

@ -43,6 +43,7 @@ public:
Q_INVOKABLE unsigned int getSyncStartHeight() const;
Q_INVOKABLE unsigned int getSyncEndHeight() const;
Q_INVOKABLE QString getSyncMessage() const;
Q_INVOKABLE int getWalletType() const;
Q_INVOKABLE int getNetworkType() const;
Q_INVOKABLE QString getNetworkTypeString() const;
Q_INVOKABLE QString getSeed() const;
@ -61,6 +62,7 @@ public:
Q_INVOKABLE QVariantList getTransfers() const;
Q_INVOKABLE neroshop::Wallet * getWallet() const;
Q_INVOKABLE void setWalletType(unsigned int wallet_type);
Q_INVOKABLE void setNetworkTypeByString(const QString& network_type);
//Q_INVOKABLE <type> <function_name>() const {}

Loading…
Cancel
Save