From dc961928d93c86e52d5d7a88de73a82930ea6eb0 Mon Sep 17 00:00:00 2001 From: Sergey Radionov Date: Thu, 3 Sep 2020 19:27:00 +0700 Subject: [PATCH 1/7] initial snap support added (#210) --- snap/snapcraft.yaml | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 snap/snapcraft.yaml diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..a80ede85 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,71 @@ +name: zano +base: core18 +adopt-info: zano +summary: "Zano coin: official wallet. Secure. Scalable. Easy to Use." +description: | + Zano is a scalable and secure coin, designed for use in e-commerce. + The technology behind our blockchain provides reliability, security, + and flexibility a perfect option for P2P transactions. + More info: http://zano.org +grade: devel +confinement: devmode + +architectures: + - build-on: amd64 + - build-on: i386 + +environment: + LC_ALL: C + +parts: + zano: + source: https://github.com/hyle-team/zano.git + plugin: cmake + override-pull: | + snapcraftctl pull + snapcraftctl set-version "$(git describe)" + configflags: + - -DBUILD_GUI=TRUE + override-build: | + snapcraftctl build + mkdir -p $SNAPCRAFT_PART_INSTALL/opt/Zano + cp $SNAPCRAFT_PART_BUILD/src/Zano $SNAPCRAFT_PART_INSTALL/opt/Zano/ + cp $SNAPCRAFT_PART_BUILD/src/simplewallet $SNAPCRAFT_PART_INSTALL/opt/Zano/ + cp $SNAPCRAFT_PART_BUILD/src/zanod $SNAPCRAFT_PART_INSTALL/opt/Zano/ + rsync -a $SNAPCRAFT_PART_SRC/src/gui/qt-daemon/html $SNAPCRAFT_PART_INSTALL/opt/Zano --exclude less --exclude package.json --exclude gulpfile.js + build-packages: + - make + - g++ + - libboost-all-dev + - qtwebengine5-dev + - rsync + build-attributes: [keep-execstack] + stage-packages: + - libboost-system1.65.1 + - libboost-filesystem1.65.1 + - libboost-thread1.65.1 + - libboost-date-time1.65.1 + - libboost-chrono1.65.1 + - libboost-regex1.65.1 + - libboost-serialization1.65.1 + - libboost-program-options1.65.1 + - libboost-locale1.65.1 + +apps: + zano: + command: opt/Zano/Zano --data-dir $SNAP_USER_COMMON + extensions: + - kde-neon + plugs: + - network + - home + simplewallet: + command: opt/Zano/simplewallet + plugs: + - network + - home + zanod: + command: opt/Zano/zanod --data-dir $SNAP_USER_COMMON + plugs: + - network + - network-bind From 211c1b4838d7f9e978c2d0520a72196ea0f0e5fc Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 3 Sep 2020 23:20:25 +0200 Subject: [PATCH 2/7] fixing i386 build --- contrib/db/liblmdb/mdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/db/liblmdb/mdb.c b/contrib/db/liblmdb/mdb.c index ca9f3b12..f9b48233 100644 --- a/contrib/db/liblmdb/mdb.c +++ b/contrib/db/liblmdb/mdb.c @@ -133,7 +133,7 @@ extern int cacheflush(char *addr, int nbytes, int cache); #ifdef _WIN32 typedef int64_t off64_t; #else -typedef off_t off64_t; +//typedef off_t off64_t; #endif From 038348ac779f54e7d1594aed3d09e7c0e9aa2bbf Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 4 Sep 2020 12:32:21 +0200 Subject: [PATCH 3/7] Changed devmode to strict --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index a80ede85..574a8602 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -8,7 +8,7 @@ description: | and flexibility a perfect option for P2P transactions. More info: http://zano.org grade: devel -confinement: devmode +confinement: strict architectures: - build-on: amd64 From 1028751ee69a08623f32317bda18359df8c211b2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 4 Sep 2020 14:03:56 +0200 Subject: [PATCH 4/7] grade -> stable --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 574a8602..e8bd23e0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -7,7 +7,7 @@ description: | The technology behind our blockchain provides reliability, security, and flexibility a perfect option for P2P transactions. More info: http://zano.org -grade: devel +grade: stable confinement: strict architectures: From 4ba14a2d4f91cf43348dd5b55a04b593bc901e4b Mon Sep 17 00:00:00 2001 From: Sergey Radionov Date: Sun, 6 Sep 2020 03:13:03 +0700 Subject: [PATCH 5/7] snap: fixed run on strict confinement (#213) --- snap/snapcraft.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e8bd23e0..f27305af 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -14,9 +14,6 @@ architectures: - build-on: amd64 - build-on: i386 -environment: - LC_ALL: C - parts: zano: source: https://github.com/hyle-team/zano.git @@ -59,6 +56,11 @@ apps: plugs: - network - home + - desktop + - opengl #for QML support + - browser-support #for Qt WebEngine support + - audio-playback + - unity7 #for tray icon support simplewallet: command: opt/Zano/simplewallet plugs: @@ -66,6 +68,8 @@ apps: - home zanod: command: opt/Zano/zanod --data-dir $SNAP_USER_COMMON + environment: + LC_ALL: C plugs: - network - network-bind From e52412facb59202ce4b58c796e7aeaed83de9d60 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 7 Sep 2020 17:36:41 +0300 Subject: [PATCH 6/7] wallet: fix for outgoing unconfirmed txs handling in tracking wallets --- src/wallet/wallet2.cpp | 102 ++++++++++++++++++++++++++--------------- src/wallet/wallet2.h | 1 + 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 64e1d0e1..ad616c6b 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -324,42 +324,12 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t const currency::txin_to_key& intk = boost::get(in); // check if this input spends our output - //transfer_details* p_td = nullptr; uint64_t tid = UINT64_MAX; if (is_auditable() && is_watch_only()) { - // auditable wallet - // try to find a reference among own UTXOs - std::vector abs_key_offsets = relative_output_offsets_to_absolute(intk.key_offsets); // potential speed-up: don't convert to abs offsets as we interested only in direct spends for auditable wallets. Now it's kind a bit paranoid. - for(auto v : abs_key_offsets) - { - if (v.type() != typeid(uint64_t)) - continue; - uint64_t gindex = boost::get(v); - auto it = m_amount_gindex_to_transfer_id.find(std::make_pair(intk.amount, gindex)); - if (it != m_amount_gindex_to_transfer_id.end()) - { - tid = it->second; - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(tid < m_transfers.size(), "invalid tid: " << tid << ", ref from input with amount: " << intk.amount << ", gindex: " << gindex); - auto& td = m_transfers[it->second]; - if (intk.key_offsets.size() != 1) - { - // own output was used in non-direct transaction - // the core should not allow this to happen, the only way it may happen - mixing in own output that was sent without mix_attr == 1 - // log strange situation - std::stringstream ss; - ss << "own transfer tid=" << tid << " tx=" << td.tx_hash() << " mix_attr=" << td.mix_attr() << ", is referenced by a transaction with mixins, ref from input with amount: " << intk.amount << ", gindex: " << gindex; - WLT_LOG_YELLOW(ss.str(), LOG_LEVEL_0); - if (m_wcallback) - m_wcallback->on_message(i_wallet2_callback::ms_yellow, ss.str()); - continue; - } - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(!td.is_spent(), "transfer is spent, tid: " << tid << ", ref from input with amount: " << intk.amount << ", gindex: " << gindex); - // own output is spent, handle it - break; - } - } + // tracking wallet, assuming all outputs are spent directly because of mix_attr = 1 + tid = get_directly_spent_transfer_id_by_input_in_tracking_wallet(intk); } else { @@ -1567,6 +1537,49 @@ bool wallet2::has_related_alias_entry_unconfirmed(const currency::transaction& t return false; } //---------------------------------------------------------------------------------------------------- +uint64_t wallet2::get_directly_spent_transfer_id_by_input_in_tracking_wallet(const currency::txin_to_key& intk) +{ + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(is_auditable() && is_watch_only(), "this is not an auditable-watch-only (tracking) wallet"); + + uint64_t tid = UINT64_MAX; + + // try to find a reference among own UTXOs + std::vector abs_key_offsets = relative_output_offsets_to_absolute(intk.key_offsets); // potential speed-up: don't convert to abs offsets as we interested only in direct spends for auditable wallets. Now it's kind a bit paranoid. + for (auto v : abs_key_offsets) + { + if (v.type() != typeid(uint64_t)) + continue; + uint64_t gindex = boost::get(v); + auto it = m_amount_gindex_to_transfer_id.find(std::make_pair(intk.amount, gindex)); + if (it != m_amount_gindex_to_transfer_id.end()) + { + tid = it->second; + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(tid < m_transfers.size(), "invalid tid: " << tid << ", ref from input with amount: " << intk.amount << ", gindex: " << gindex); + auto& td = m_transfers[it->second]; + if (intk.key_offsets.size() != 1) + { + // own output was used in non-direct transaction + // the core should not allow this to happen, the only way it may happen - mixing in own output that was sent without mix_attr == 1 + // log strange situation + std::stringstream ss; + ss << "own transfer tid=" << tid << " tx=" << td.tx_hash() << " mix_attr=" << td.mix_attr() << ", is referenced by a transaction with mixins, ref from input with amount: " << intk.amount << ", gindex: " << gindex; + WLT_LOG_YELLOW(ss.str(), LOG_LEVEL_0); + if (m_wcallback) + m_wcallback->on_message(i_wallet2_callback::ms_yellow, ss.str()); + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(td.mix_attr() != CURRENCY_TO_KEY_OUT_FORCED_NO_MIX, ss.str()); // if mix_attr == 1 this should never happen (mixing in an output with mix_attr = 1) as the core must reject such txs + // our own output has mix_attr != 1 for some reason (a sender did not set correct mix_attr e.g.) + // but mixin count > 1 so we can't say it is spent for sure + tid = UINT64_MAX; + continue; + } + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(td.m_spent_height == 0, "transfer is spent in blockchain, tid: " << tid << ", ref from input with amount: " << intk.amount << ", gindex: " << gindex); + // okay, own output is being spent, return it + break; + } + } + return tid; +} +//---------------------------------------------------------------------------------------------------- void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) { //get transaction pool content @@ -1646,12 +1659,29 @@ void wallet2::scan_tx_pool(bool& has_related_alias_in_unconfirmed) auto& in = tx.vin[i]; if (in.type() == typeid(currency::txin_to_key)) { - auto it = m_key_images.find(boost::get(in).k_image); - if (it != m_key_images.end()) + const currency::txin_to_key& intk = boost::get(in); + uint64_t tid = UINT64_MAX; + if (is_auditable() && is_watch_only()) { - tx_money_spent_in_ins += boost::get(in).amount; + // tracking wallet, assuming all outputs are spent directly because of mix_attr = 1 + tid = get_directly_spent_transfer_id_by_input_in_tracking_wallet(intk); + } + else + { + // wallet with spend secret key -- we can calculate own key images and then search among them + auto it = m_key_images.find(intk.k_image); + if (it != m_key_images.end()) + { + tid = it->second; + } + } + + if (tid != UINT64_MAX) + { + // own output is being spent by this input + tx_money_spent_in_ins += intk.amount; td.spent_indices.push_back(i); - spend_transfers.push_back(it->second); + spend_transfers.push_back(tid); } } else if (in.type() == typeid(currency::txin_multisig)) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 65400b88..349750db 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -927,6 +927,7 @@ private: //void check_if_block_matched(uint64_t i, const crypto::hash& id, bool& block_found, bool& block_matched, bool& full_reset_needed); uint64_t detach_from_block_ids(uint64_t height); uint64_t get_wallet_minimum_height(); + uint64_t get_directly_spent_transfer_id_by_input_in_tracking_wallet(const currency::txin_to_key& intk); void push_alias_info_to_extra_according_to_hf_status(const currency::extra_alias_entry& ai, std::vector& extra); void remove_transfer_from_amount_gindex_map(uint64_t tid); From 3678ba2154bd5d785dca2c019c90db0279b638ba Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 7 Sep 2020 20:59:44 +0200 Subject: [PATCH 7/7] fixed connectivity for simplewallet in srv mode --- src/wallet/wallet2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index ad616c6b..33e18f82 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -155,6 +155,7 @@ void wallet2::init(const std::string& daemon_address) { m_miner_text_info = PROJECT_VERSION_LONG; m_core_proxy->set_connection_addr(daemon_address); + m_core_proxy->check_connection(); } //---------------------------------------------------------------------------------------------------- bool wallet2::set_core_proxy(const std::shared_ptr& proxy)