From 0925c02a770de21295c221b49169469c44eb3359 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 24 Jun 2021 00:57:38 +0200 Subject: [PATCH 01/37] implemented basic suppoer of wrapping in wallet(service commands) + inital support in simplewallet --- src/currency_core/currency_basic.h | 10 ++- src/currency_core/currency_format_utils.cpp | 90 ++++++++++++++++++--- src/currency_core/currency_format_utils.h | 1 + src/simplewallet/simplewallet.cpp | 32 +++++++- src/wallet/wrap_service.h | 12 +++ 5 files changed, 129 insertions(+), 16 deletions(-) create mode 100644 src/wallet/wrap_service.h diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 274a2f25..29aa7483 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -386,8 +386,14 @@ namespace currency }; // applicable flags for tx_service_attachment::flags, can be combined using bitwise OR -#define TX_SERVICE_ATTACHMENT_ENCRYPT_BODY static_cast(1 << 0) -#define TX_SERVICE_ATTACHMENT_DEFLATE_BODY static_cast(1 << 1) +#define TX_SERVICE_ATTACHMENT_ENCRYPT_BODY static_cast(1 << 0) +#define TX_SERVICE_ATTACHMENT_DEFLATE_BODY static_cast(1 << 1) + +// with this flag enabled body encrypted/decrypted with the key created as a derivation from onetime key and "spend keys" of receiver +#define TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE static_cast(1 << 2) +// add proof of content, without revealing secrete +#define TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF static_cast(1 << 3) + //, diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 7c014f2a..0d877864 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -759,8 +759,12 @@ namespace currency struct encrypt_attach_visitor : public boost::static_visitor { bool& m_was_crypted_entries; + const keypair& m_onetime_keypair; + const account_public_address& m_destination_addr; const crypto::key_derivation& m_key; - encrypt_attach_visitor(bool& was_crypted_entries, const crypto::key_derivation& key) :m_was_crypted_entries(was_crypted_entries), m_key(key) + + encrypt_attach_visitor(bool& was_crypted_entries, const crypto::key_derivation& key, const keypair& onetime_keypair = keypair(), const account_public_address& destination_addr = account_public_address()) : + m_was_crypted_entries(was_crypted_entries), m_key(key), m_onetime_keypair(onetime_keypair), m_destination_addr(m_destination_addr) {} void operator()(tx_comment& comment) { @@ -789,6 +793,7 @@ namespace currency } void operator()(tx_service_attachment& sa) { + const std::string orignal_body = sa.body; if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY) { zlib_helper::pack(sa.body); @@ -796,7 +801,27 @@ namespace currency if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_BODY) { - crypto::chacha_crypt(sa.body, m_key); + crypto::key_derivation derivation_local = m_key; + if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE) + { + CHECK_AND_ASSERT_THROW_MES(m_destination_addr.spend_public_key != currency::null_pkey && m_onetime_keypair.sec != currency::null_skey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); + //encrypt with "spend keys" only, to prevent auditable watchers decrypt it + bool r = crypto::generate_key_derivation(m_destination_addr.spend_public_key, m_onetime_keypair.sec, derivation_local); + crypto::chacha_crypt(sa.body, derivation_local); + } + else + { + crypto::chacha_crypt(sa.body, derivation_local); + } + if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF) + { + //take hash from derivation and use it as a salt + crypto::hash derivation_hash = crypto::cn_fast_hash(&derivation_local, sizeof(derivation_local)); + std::string salted_body = orignal_body; + string_tools::apped_pod_to_strbuff(salted_body, derivation_hash); + crypto::hash proof_hash = crypto::cn_fast_hash(salted_body.data(), salted_body.size()); + sa.security.push_back(*(crypto::public_key*)&proof_hash); + } m_was_crypted_entries = true; } } @@ -808,12 +833,18 @@ namespace currency struct decrypt_attach_visitor : public boost::static_visitor { + const account_keys& m_acc_keys; + const crypto::public_key& m_tx_onetime_pubkey; const crypto::key_derivation& rkey; std::vector& rdecrypted_att; decrypt_attach_visitor(const crypto::key_derivation& key, - std::vector& decrypted_att) : + std::vector& decrypted_att, + const account_keys& acc_keys = account_keys(), + const crypto::public_key& tx_onetime_pubkey = crypto::public_key()) : rkey(key), - rdecrypted_att(decrypted_att) + rdecrypted_att(decrypted_att), + m_acc_keys(acc_keys), + m_tx_onetime_pubkey(tx_onetime_pubkey) {} void operator()(const tx_comment& comment) { @@ -825,15 +856,44 @@ namespace currency void operator()(const tx_service_attachment& sa) { tx_service_attachment local_sa = sa; + crypto::key_derivation derivation_local = rkey; if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_BODY) { - crypto::chacha_crypt(local_sa.body, rkey); + if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE) + { + if (m_acc_keys.spend_secret_key == null_skey) + { + //this watch only wallet, decrypting supposed to be impossible + return; + } + CHECK_AND_ASSERT_THROW_MES(m_acc_keys.spend_secret_key != currency::null_skey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); + bool r = crypto::generate_key_derivation(m_tx_onetime_pubkey, m_acc_keys.spend_secret_key, derivation_local); + CHECK_AND_ASSERT_THROW_MES(r, "Failed to generate_key_derivation at TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE"); + crypto::chacha_crypt(sa.body, derivation_local); + + } + else + { + crypto::chacha_crypt(local_sa.body, derivation_local); + } } if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY) { zlib_helper::unpack(local_sa.body); } + + if (sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_BODY && sa.flags&TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF) + { + CHECK_AND_ASSERT_MES(sa.security.size() == 1, void(), "Unexpected key in tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE"); + //take hash from derivation and use it as a salt + crypto::hash derivation_hash = crypto::cn_fast_hash(&derivation_local, sizeof(derivation_local)); + std::string salted_body = local_sa.body; + string_tools::apped_pod_to_strbuff(salted_body, derivation_hash); + crypto::hash proof_hash = crypto::cn_fast_hash(salted_body.data(), salted_body.size()); + CHECK_AND_ASSERT_MES(*(crypto::public_key*)&proof_hash == sa.security.front(), void(), "Proof hash missmatch on decrypting with TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF"); + } + rdecrypted_att.push_back(local_sa); } @@ -870,9 +930,10 @@ namespace currency //--------------------------------------------------------------- template - bool decrypt_payload_items(const crypto::key_derivation& derivation, const items_container_t& items_to_decrypt, std::vector& decrypted_att) + bool decrypt_payload_items(const crypto::key_derivation& derivation, const items_container_t& items_to_decrypt, std::vector& decrypted_att, const account_keys& acc_keys = account_keys(), + const crypto::public_key& tx_onetime_pubkey = crypto::public_key()) { - decrypt_attach_visitor v(derivation, decrypted_att); + decrypt_attach_visitor v(derivation, decrypted_att, acc_keys, tx_onetime_pubkey); for (auto& a : items_to_decrypt) boost::apply_visitor(v, a); @@ -955,8 +1016,8 @@ namespace currency return true; } - decrypt_payload_items(derivation, tx.extra, decrypted_items); - decrypt_payload_items(derivation, tx.attachment, decrypted_items); + decrypt_payload_items(derivation, tx.extra, decrypted_items, acc_keys, get_tx_pub_key_from_extra(tx)); + decrypt_payload_items(derivation, tx.attachment, decrypted_items, acc_keys, get_tx_pub_key_from_extra(tx)); return true; } @@ -969,11 +1030,11 @@ namespace currency bool was_attachment_crypted_entries = false; bool was_extra_crypted_entries = false; - encrypt_attach_visitor v(was_attachment_crypted_entries, derivation); + encrypt_attach_visitor v(was_attachment_crypted_entries, derivation, tx_random_key, destination_addr); for (auto& a : tx.attachment) boost::apply_visitor(v, a); - encrypt_attach_visitor v2(was_extra_crypted_entries, derivation); + encrypt_attach_visitor v2(was_extra_crypted_entries, derivation, tx_random_key, destination_addr); for (auto& a : tx.extra) boost::apply_visitor(v2, a); @@ -2888,6 +2949,13 @@ namespace currency return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Zano address (normal) } //----------------------------------------------------------------------- + bool is_address_looks_like_wrapped(const std::string& addr) + { + if (addr.length() == 42 && addr.substr(0, 2) == "0x") + return true; + else return false; + } + //----------------------------------------------------------------------- std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const payment_id_t& payment_id) { if (addr.flags == 0) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 6474307d..86952896 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -289,6 +289,7 @@ namespace currency bool decrypt_payload_items(bool is_income, const transaction& tx, const account_keys& acc_keys, std::vector& decrypted_items); void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key); bool is_derivation_used_to_encrypt(const transaction& tx, const crypto::key_derivation& derivation); + bool is_address_looks_like_wrapped(const std::string& addr); void load_wallet_transfer_info_flags(tools::wallet_public::wallet_transfer_info& x); uint64_t get_tx_type(const transaction& tx); uint64_t get_tx_type_ex(const transaction& tx, tx_out& htlc_out, txin_htlc& htlc_in); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 8656eb2c..3517e318 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -20,6 +20,7 @@ #include "wallet/wallet_rpc_server.h" #include "version.h" #include "string_coding.h" +#include "wallet/wrap_service.h" #include @@ -1208,13 +1209,32 @@ bool simple_wallet::transfer(const std::vector &args_) return true; } + std::vector extra; vector dsts; + bool wrapped_transaction = false; for (size_t i = 0; i < local_args.size(); i += 2) { std::string integrated_payment_id; currency::tx_destination_entry de; de.addr.resize(1); - if(!(de.addr.size() == 1 && m_wallet->get_transfer_address(local_args[i], de.addr.front(), integrated_payment_id))) + //check if address looks like wrapped address + if (is_address_looks_like_wrapped(local_args[i])) + { + success_msg_writer(true) << "Address " << local_args[i] << " recognized as wrapped address, creating wrapping transaction..."; + //put into service attachment specially encrypted entry which will contain wrap address and network + tx_service_attachment sa = AUTO_VAL_INIT(sa); + sa.service_id = BC_WRAP_SERVICE_ID; + sa.instruction = BC_WRAP_SERVICE_INSTRUCTION_ERC20; + sa.flags = TX_SERVICE_ATTACHMENT_ENCRYPT_BODY | TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE; + sa.body = local_args[i]; + extra.push_back(sa); + + currency::account_public_address acc = AUTO_VAL_INIT(acc); + currency::get_account_address_from_str(acc, BC_WRAP_SERVICE_CUSTODY_WALLET); + de.addr.front() = acc; + wrapped_transaction = true; + //encrypt body with a special way + }else if(!(de.addr.size() == 1 && m_wallet->get_transfer_address(local_args[i], de.addr.front(), integrated_payment_id))) { fail_msg_writer() << "wrong address: " << local_args[i]; return true; @@ -1258,13 +1278,19 @@ bool simple_wallet::transfer(const std::vector &args_) try { currency::transaction tx; - std::vector extra; m_wallet->transfer(dsts, fake_outs_count, 0, m_wallet->get_core_runtime_config().tx_default_fee, extra, attachments, tx); if (!m_wallet->is_watch_only()) - success_msg_writer(true) << "Money successfully sent, transaction " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; + { + if(wrapped_transaction) + success_msg_writer(true) << "Money successfully sent to wZano custody wallet, transaction " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; + else + success_msg_writer(true) << "Money successfully sent, transaction " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; + } else + { success_msg_writer(true) << "Transaction prepared for signing and saved into \"zano_tx_unsigned\" file, use full wallet to sign transfer and then use \"submit_transfer\" on this wallet to broadcast the transaction to the network"; + } } catch (const tools::error::daemon_busy&) { diff --git a/src/wallet/wrap_service.h b/src/wallet/wrap_service.h new file mode 100644 index 00000000..852d60d7 --- /dev/null +++ b/src/wallet/wrap_service.h @@ -0,0 +1,12 @@ +// Copyright (c) 2014-2018 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#define BC_WRAP_SERVICE_ID "W" + +#define BC_WRAP_SERVICE_INSTRUCTION_ERC20 "ERC20" //erc20 wrapped operation + + +#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxbJPXzkjCJDpGEVvkMir9B4fRKPo73r2e5D7nLHuVgEBXXQYc2Tk2hHroxVwiCDLDHZu215pgNocUsrchH4HHzWbHzL4nMfPq" \ No newline at end of file From 4d324fc1bfc2a01b86828913c8aba056de86a2cd Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 24 Jun 2021 20:34:13 +0200 Subject: [PATCH 02/37] fixed default initialization for decrypt/encrypt visitors --- src/currency_core/account.h | 1 + src/currency_core/currency_basic.h | 1 + src/currency_core/currency_format_utils.cpp | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/currency_core/account.h b/src/currency_core/account.h index 305b02e3..e9674307 100644 --- a/src/currency_core/account.h +++ b/src/currency_core/account.h @@ -97,6 +97,7 @@ namespace currency std::vector m_keys_seed_binary; }; + const static account_keys null_acc_keys = AUTO_VAL_INIT(null_acc_keys); std::string transform_addr_to_str(const account_public_address& addr); account_public_address transform_str_to_addr(const std::string& str); diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 29aa7483..1193bd8a 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -696,6 +696,7 @@ namespace currency return k; } }; + const static keypair null_keypair = AUTO_VAL_INIT(null_keypair); //--------------------------------------------------------------- //PoS //based from ppcoin/novacoin approach diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 0d877864..4e5d717d 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -763,7 +763,7 @@ namespace currency const account_public_address& m_destination_addr; const crypto::key_derivation& m_key; - encrypt_attach_visitor(bool& was_crypted_entries, const crypto::key_derivation& key, const keypair& onetime_keypair = keypair(), const account_public_address& destination_addr = account_public_address()) : + encrypt_attach_visitor(bool& was_crypted_entries, const crypto::key_derivation& key, const keypair& onetime_keypair = null_keypair, const account_public_address& destination_addr = null_pub_addr) : m_was_crypted_entries(was_crypted_entries), m_key(key), m_onetime_keypair(onetime_keypair), m_destination_addr(m_destination_addr) {} void operator()(tx_comment& comment) @@ -807,6 +807,7 @@ namespace currency CHECK_AND_ASSERT_THROW_MES(m_destination_addr.spend_public_key != currency::null_pkey && m_onetime_keypair.sec != currency::null_skey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); //encrypt with "spend keys" only, to prevent auditable watchers decrypt it bool r = crypto::generate_key_derivation(m_destination_addr.spend_public_key, m_onetime_keypair.sec, derivation_local); + CHECK_AND_ASSERT_THROW_MES(r, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: Failed to make derivation"); crypto::chacha_crypt(sa.body, derivation_local); } else @@ -839,8 +840,8 @@ namespace currency std::vector& rdecrypted_att; decrypt_attach_visitor(const crypto::key_derivation& key, std::vector& decrypted_att, - const account_keys& acc_keys = account_keys(), - const crypto::public_key& tx_onetime_pubkey = crypto::public_key()) : + const account_keys& acc_keys = null_acc_keys, + const crypto::public_key& tx_onetime_pubkey = null_pkey) : rkey(key), rdecrypted_att(decrypted_att), m_acc_keys(acc_keys), @@ -866,7 +867,7 @@ namespace currency //this watch only wallet, decrypting supposed to be impossible return; } - CHECK_AND_ASSERT_THROW_MES(m_acc_keys.spend_secret_key != currency::null_skey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); + CHECK_AND_ASSERT_THROW_MES(m_acc_keys.spend_secret_key != currency::null_skey && m_tx_onetime_pubkey != currency::null_pkey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); bool r = crypto::generate_key_derivation(m_tx_onetime_pubkey, m_acc_keys.spend_secret_key, derivation_local); CHECK_AND_ASSERT_THROW_MES(r, "Failed to generate_key_derivation at TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE"); crypto::chacha_crypt(sa.body, derivation_local); @@ -930,8 +931,8 @@ namespace currency //--------------------------------------------------------------- template - bool decrypt_payload_items(const crypto::key_derivation& derivation, const items_container_t& items_to_decrypt, std::vector& decrypted_att, const account_keys& acc_keys = account_keys(), - const crypto::public_key& tx_onetime_pubkey = crypto::public_key()) + bool decrypt_payload_items(const crypto::key_derivation& derivation, const items_container_t& items_to_decrypt, std::vector& decrypted_att, const account_keys& acc_keys = null_acc_keys, + const crypto::public_key& tx_onetime_pubkey = null_pkey) { decrypt_attach_visitor v(derivation, decrypted_att, acc_keys, tx_onetime_pubkey); for (auto& a : items_to_decrypt) From 331548c9a681710ff900db14c72446849ce58064 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 24 Jun 2021 22:10:09 +0200 Subject: [PATCH 03/37] added isolated items to rpc-structures --- src/wallet/wallet2.cpp | 13 +++++++++---- src/wallet/wallet2.h | 8 +++++--- src/wallet/wallet_public_structs_defs.h | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d0456a00..b6c054a8 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -715,6 +715,11 @@ void wallet2::prepare_wti_decrypted_attachments(wallet_public::wallet_transfer_i wti.show_sender = handle_2_alternative_types_in_variant_container(decrypted_att, [&](const tx_payer& p) { sender_address = p.acc_addr; return false; /* <- continue? */ } ); if (wti.show_sender) wti.remote_addresses.push_back(currency::get_account_address_as_str(sender_address)); + + for (const auto& item : decrypted_att) + { + wti.service_entries.push_back(item); + } } else { @@ -1238,7 +1243,7 @@ void wallet2::prepare_wti(wallet_public::wallet_transfer_info& wti, uint64_t hei wti.tx_blob_size = static_cast(currency::get_object_blobsize(wti.tx)); wti.tx_hash = currency::get_transaction_hash(tx); load_wallet_transfer_info_flags(wti); - bc_services::extract_market_instructions(wti.srv_attachments, tx.attachment); + bc_services::extract_market_instructions(wti.marketplace_entries, tx.attachment); // escrow transactions, which are built with TX_FLAG_SIGNATURE_MODE_SEPARATE flag actually encrypt attachments // with buyer as a sender, and seller as receiver, despite the fact that for both sides transaction seen as outgoing @@ -4570,7 +4575,7 @@ bool wallet2::extract_offers_from_transfer_entry(size_t i, std::unordered_map diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index afcddc49..d9edd8ab 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -87,6 +87,17 @@ namespace wallet_public #define WALLET_TRANSFER_INFO_FLAGS_HTLC_DEPOSIT static_cast(1 << 0) + struct tx_service_attachment_kv: public tx_service_attachment + { + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(service_id) + KV_SERIALIZE(instruction) + KV_SERIALIZE(body) + KV_SERIALIZE_CONTAINER_POD_AS_BLOB(security) + KV_SERIALIZE(flags) + END_KV_SERIALIZE_MAP() + }; + struct wallet_transfer_info { uint64_t amount; @@ -105,16 +116,18 @@ namespace wallet_public bool is_mining; uint64_t tx_type; wallet_transfer_info_details td; + std::vector service_entries; //not included in streaming serialization uint64_t fee; bool show_sender; std::vector contract; uint16_t extra_flags; + //not included in kv serialization map currency::transaction tx; std::vector selected_indicies; - std::list srv_attachments; + std::list marketplace_entries; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(amount) @@ -136,6 +149,7 @@ namespace wallet_public KV_SERIALIZE(tx_type) KV_SERIALIZE(show_sender) KV_SERIALIZE(contract) + KV_SERIALIZE(service_entries) END_KV_SERIALIZE_MAP() }; From d83f8c3e9e9f74d64301708f390ea732f6fffb1a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 24 Jun 2021 23:24:38 +0200 Subject: [PATCH 04/37] added test isolate_auditable_and_proof --- src/currency_core/currency_format_utils.cpp | 6 +- src/currency_core/currency_format_utils.h | 2 +- src/simplewallet/simplewallet.cpp | 2 +- src/wallet/wallet2.cpp | 5 +- src/wallet/wallet_public_structs_defs.h | 2 +- .../isolate_auditable_and_proof.cpp | 116 ++++++++++++++++++ .../core_tests/isolate_auditable_and_proof.h | 19 +++ 7 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 tests/core_tests/isolate_auditable_and_proof.cpp create mode 100644 tests/core_tests/isolate_auditable_and_proof.h diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 4e5d717d..27ecdc9d 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -793,7 +793,7 @@ namespace currency } void operator()(tx_service_attachment& sa) { - const std::string orignal_body = sa.body; + const std::string original_body = sa.body; if (sa.flags&TX_SERVICE_ATTACHMENT_DEFLATE_BODY) { zlib_helper::pack(sa.body); @@ -818,7 +818,7 @@ namespace currency { //take hash from derivation and use it as a salt crypto::hash derivation_hash = crypto::cn_fast_hash(&derivation_local, sizeof(derivation_local)); - std::string salted_body = orignal_body; + std::string salted_body = original_body; string_tools::apped_pod_to_strbuff(salted_body, derivation_hash); crypto::hash proof_hash = crypto::cn_fast_hash(salted_body.data(), salted_body.size()); sa.security.push_back(*(crypto::public_key*)&proof_hash); @@ -2950,7 +2950,7 @@ namespace currency return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); // new format Zano address (normal) } //----------------------------------------------------------------------- - bool is_address_looks_like_wrapped(const std::string& addr) + bool is_address_like_wrapped(const std::string& addr) { if (addr.length() == 42 && addr.substr(0, 2) == "0x") return true; diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 86952896..9a108417 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -289,7 +289,7 @@ namespace currency bool decrypt_payload_items(bool is_income, const transaction& tx, const account_keys& acc_keys, std::vector& decrypted_items); void encrypt_attachments(transaction& tx, const account_keys& sender_keys, const account_public_address& destination_addr, const keypair& tx_random_key); bool is_derivation_used_to_encrypt(const transaction& tx, const crypto::key_derivation& derivation); - bool is_address_looks_like_wrapped(const std::string& addr); + bool is_address_like_wrapped(const std::string& addr); void load_wallet_transfer_info_flags(tools::wallet_public::wallet_transfer_info& x); uint64_t get_tx_type(const transaction& tx); uint64_t get_tx_type_ex(const transaction& tx, tx_out& htlc_out, txin_htlc& htlc_in); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 3517e318..654ec78d 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1218,7 +1218,7 @@ bool simple_wallet::transfer(const std::vector &args_) currency::tx_destination_entry de; de.addr.resize(1); //check if address looks like wrapped address - if (is_address_looks_like_wrapped(local_args[i])) + if (is_address_like_wrapped(local_args[i])) { success_msg_writer(true) << "Address " << local_args[i] << " recognized as wrapped address, creating wrapping transaction..."; //put into service attachment specially encrypted entry which will contain wrap address and network diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b6c054a8..2f6f0dd7 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -718,7 +718,10 @@ void wallet2::prepare_wti_decrypted_attachments(wallet_public::wallet_transfer_i for (const auto& item : decrypted_att) { - wti.service_entries.push_back(item); + if (item.type() == typeid(currency::tx_service_attachment)) + { + wti.service_entries.push_back(tools::wallet_public::tx_service_attachment_kv(boost::get(item))); + } } } else diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index d9edd8ab..02bc1973 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -87,7 +87,7 @@ namespace wallet_public #define WALLET_TRANSFER_INFO_FLAGS_HTLC_DEPOSIT static_cast(1 << 0) - struct tx_service_attachment_kv: public tx_service_attachment + struct tx_service_attachment_kv: public currency::tx_service_attachment { BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(service_id) diff --git a/tests/core_tests/isolate_auditable_and_proof.cpp b/tests/core_tests/isolate_auditable_and_proof.cpp new file mode 100644 index 00000000..2fb3fa69 --- /dev/null +++ b/tests/core_tests/isolate_auditable_and_proof.cpp @@ -0,0 +1,116 @@ +// Copyright (c) 2014-2021 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "chaingen.h" +#include "escrow_wallet_tests.h" +#include "random_helper.h" +#include "chaingen_helpers.h" +#include "atomic_tests.h" + +using namespace epee; +using namespace crypto; +using namespace currency; + + +isolate_auditable_and_proof::isolate_auditable_and_proof() +{ + REGISTER_CALLBACK_METHOD(isolate_auditable_and_proof, c1); + REGISTER_CALLBACK_METHOD(isolate_auditable_and_proof, configure_core); +} + +bool isolate_auditable_and_proof::generate(std::vector& events) const +{ + random_state_test_restorer::reset_random(0); // to make the test deterministic + m_genesis_timestamp = 1450000000; + test_core_time::adjust(m_genesis_timestamp); + + + epee::debug::get_set_enable_assert(true, true); + + currency::account_base genesis_acc; + genesis_acc.generate(); + m_mining_accunt.generate(); + m_mining_accunt.set_createtime(m_genesis_timestamp); + + + block blk_0 = AUTO_VAL_INIT(blk_0); + generator.construct_genesis_block(blk_0, genesis_acc, test_core_time::get_time()); + events.push_back(blk_0); + DO_CALLBACK(events, "configure_core"); + REWIND_BLOCKS_N(events, blk_0r, blk_0, m_mining_accunt, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 5); + + DO_CALLBACK(events, "c1"); + epee::debug::get_set_enable_assert(true, false); + return true; +} + +bool isolate_auditable_and_proof::configure_core(currency::core& c, size_t ev_index, const std::vector& events) +{ + return true; +} +/************************************************************************/ +/* */ +/************************************************************************/ + +bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const std::vector& events) +{ + epee::debug::get_set_enable_assert(true, true); + misc_utils::auto_scope_leave_caller scope_exit_handler = misc_utils::create_scope_leave_handler([&](){epee::debug::get_set_enable_assert(true, false); }); + + LOG_PRINT_MAGENTA("Mining Address: " << currency::get_account_address_as_str(m_mining_accunt.get_public_address()), LOG_LEVEL_0); + + currency::account_base auditable_test; + auditable_test.generate(true); + auditable_test.set_createtime(m_genesis_timestamp); + LOG_PRINT_MAGENTA(": " << currency::get_account_address_as_str(auditable_test.get_public_address()), LOG_LEVEL_0); + std::shared_ptr auditable_test_instance = init_playtime_test_wallet(events, c, auditable_test); + + +#define AMOUNT_TO_TRANSFER_LOCAL (TESTS_DEFAULT_FEE*10) + + std::shared_ptr miner_wlt = init_playtime_test_wallet(events, c, m_mining_accunt); + miner_wlt->refresh(); + + + //create transaction that use TX_SERVICE_ATTACHMENT_ENCRYPT_BODY and TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE + { + std::vector extra; + std::vector attachments; + vector dsts; + + currency::tx_destination_entry de; + de.addr.resize(1); + //put into service attachment specially encrypted entry which will contain wrap address and network + tx_service_attachment sa = AUTO_VAL_INIT(sa); + sa.service_id = BC_WRAP_SERVICE_ID; + sa.instruction = BC_WRAP_SERVICE_INSTRUCTION_ERC20; + sa.flags = TX_SERVICE_ATTACHMENT_ENCRYPT_BODY | TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE; + sa.body = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"; + extra.push_back(sa); + + currency::account_public_address acc = AUTO_VAL_INIT(acc); + de.addr.front() = auditable_test.get_public_address(); + currency::transaction tx; + miner_wlt->transfer(dsts, 0, 0, miner_wlt->get_core_runtime_config().tx_default_fee, extra, attachments, tx); + } + + bool r = mine_next_pow_blocks_in_playtime(m_mining_accunt.get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW); + CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed"); + + miner_wlt->refresh(); + auditable_test_instance->refresh(); + + epee::json_rpc::error je; + tools::wallet_rpc_server::connection_context ctx; + tools::wallet_rpc_server miner_wlt_rpc(*auditable_test_instance); + wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request req = AUTO_VAL_INIT(); + wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request res = AUTO_VAL_INIT(); + req.count = 100; + req.offset = 0; + miner_wlt_rpc->on_get_recent_txs_and_info(req, res, je, ctx); + std::string ps = epee::serialization::store_t_to_json(res); + + return r; +} + diff --git a/tests/core_tests/isolate_auditable_and_proof.h b/tests/core_tests/isolate_auditable_and_proof.h new file mode 100644 index 00000000..b0df5b8d --- /dev/null +++ b/tests/core_tests/isolate_auditable_and_proof.h @@ -0,0 +1,19 @@ +// Copyright (c) 2014-2021 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once +#include "chaingen.h" +#include "wallet_tests_basic.h" + + +struct isolate_auditable_and_proof : public wallet_test +{ + isolate_auditable_and_proof(); + bool generate(std::vector& events) const; + virtual bool c1(currency::core& c, size_t ev_index, const std::vector& events)=0; + virtual bool configure_core(currency::core& c, size_t ev_index, const std::vector& events); +protected: + mutable uint64_t m_genesis_timestamp; + mutable currency::account_base m_mining_accunt; +}; From 33b26a68c9230718f92fddbbf89747cebd5fd7d2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 26 Jun 2021 02:40:41 +0200 Subject: [PATCH 05/37] bunch of fixes over isolate_auditable_and_proof test --- src/currency_core/currency_basic.h | 8 ++++++++ src/wallet/wallet2.cpp | 2 +- src/wallet/wallet_public_structs_defs.h | 13 +------------ tests/core_tests/isolate_auditable_and_proof.cpp | 12 +++++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 1193bd8a..7dd6a8cd 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -383,6 +383,14 @@ namespace currency FIELD(security) FIELD(flags) END_SERIALIZE() + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(service_id) + KV_SERIALIZE(instruction) + KV_SERIALIZE(body) + KV_SERIALIZE_CONTAINER_POD_AS_BLOB(security) + KV_SERIALIZE(flags) + END_KV_SERIALIZE_MAP() }; // applicable flags for tx_service_attachment::flags, can be combined using bitwise OR diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 2f6f0dd7..5b753b91 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -720,7 +720,7 @@ void wallet2::prepare_wti_decrypted_attachments(wallet_public::wallet_transfer_i { if (item.type() == typeid(currency::tx_service_attachment)) { - wti.service_entries.push_back(tools::wallet_public::tx_service_attachment_kv(boost::get(item))); + wti.service_entries.push_back(boost::get(item)); } } } diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 02bc1973..3b78f2b4 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -87,17 +87,6 @@ namespace wallet_public #define WALLET_TRANSFER_INFO_FLAGS_HTLC_DEPOSIT static_cast(1 << 0) - struct tx_service_attachment_kv: public currency::tx_service_attachment - { - BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(service_id) - KV_SERIALIZE(instruction) - KV_SERIALIZE(body) - KV_SERIALIZE_CONTAINER_POD_AS_BLOB(security) - KV_SERIALIZE(flags) - END_KV_SERIALIZE_MAP() - }; - struct wallet_transfer_info { uint64_t amount; @@ -116,7 +105,7 @@ namespace wallet_public bool is_mining; uint64_t tx_type; wallet_transfer_info_details td; - std::vector service_entries; + std::vector service_entries; //not included in streaming serialization uint64_t fee; bool show_sender; diff --git a/tests/core_tests/isolate_auditable_and_proof.cpp b/tests/core_tests/isolate_auditable_and_proof.cpp index 2fb3fa69..b2907824 100644 --- a/tests/core_tests/isolate_auditable_and_proof.cpp +++ b/tests/core_tests/isolate_auditable_and_proof.cpp @@ -6,7 +6,9 @@ #include "escrow_wallet_tests.h" #include "random_helper.h" #include "chaingen_helpers.h" -#include "atomic_tests.h" +#include "isolate_auditable_and_proof.h" +#include "wallet/wrap_service.h" +#include "wallet/wallet_rpc_server.h" using namespace epee; using namespace crypto; @@ -77,7 +79,7 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s { std::vector extra; std::vector attachments; - vector dsts; + std::vector dsts; currency::tx_destination_entry de; de.addr.resize(1); @@ -104,11 +106,11 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s epee::json_rpc::error je; tools::wallet_rpc_server::connection_context ctx; tools::wallet_rpc_server miner_wlt_rpc(*auditable_test_instance); - wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request req = AUTO_VAL_INIT(); - wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request res = AUTO_VAL_INIT(); + tools::wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::request req = AUTO_VAL_INIT(req); + tools::wallet_public::COMMAND_RPC_GET_RECENT_TXS_AND_INFO::response res = AUTO_VAL_INIT(res); req.count = 100; req.offset = 0; - miner_wlt_rpc->on_get_recent_txs_and_info(req, res, je, ctx); + miner_wlt_rpc.on_get_recent_txs_and_info(req, res, je, ctx); std::string ps = epee::serialization::store_t_to_json(res); return r; From 0d7b10eddaa42301b032776ce33fac111343df3e Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 27 Jun 2021 01:24:04 +0200 Subject: [PATCH 06/37] fixed minor bugs, proofs working now --- src/currency_core/currency_format_utils.cpp | 4 ++-- tests/core_tests/chaingen_main.cpp | 3 +++ tests/core_tests/chaingen_tests_list.h | 1 + tests/core_tests/isolate_auditable_and_proof.cpp | 2 +- tests/core_tests/isolate_auditable_and_proof.h | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 27ecdc9d..73bf0200 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -764,7 +764,7 @@ namespace currency const crypto::key_derivation& m_key; encrypt_attach_visitor(bool& was_crypted_entries, const crypto::key_derivation& key, const keypair& onetime_keypair = null_keypair, const account_public_address& destination_addr = null_pub_addr) : - m_was_crypted_entries(was_crypted_entries), m_key(key), m_onetime_keypair(onetime_keypair), m_destination_addr(m_destination_addr) + m_was_crypted_entries(was_crypted_entries), m_key(key), m_onetime_keypair(onetime_keypair), m_destination_addr(destination_addr) {} void operator()(tx_comment& comment) { @@ -870,7 +870,7 @@ namespace currency CHECK_AND_ASSERT_THROW_MES(m_acc_keys.spend_secret_key != currency::null_skey && m_tx_onetime_pubkey != currency::null_pkey, "tx_service_attachment with TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE: keys uninitialized"); bool r = crypto::generate_key_derivation(m_tx_onetime_pubkey, m_acc_keys.spend_secret_key, derivation_local); CHECK_AND_ASSERT_THROW_MES(r, "Failed to generate_key_derivation at TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE"); - crypto::chacha_crypt(sa.body, derivation_local); + crypto::chacha_crypt(local_sa.body, derivation_local); } else diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index 1f21fce7..6cd4425d 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1029,6 +1029,9 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY(atomic_test_wrong_redeem_wrong_refund); GENERATE_AND_PLAY(atomic_test_altchain_simple); GENERATE_AND_PLAY(atomic_test_check_hardfork_rules); + + GENERATE_AND_PLAY(isolate_auditable_and_proof); + // GENERATE_AND_PLAY(gen_block_reward); diff --git a/tests/core_tests/chaingen_tests_list.h b/tests/core_tests/chaingen_tests_list.h index 2a419569..9d2e4c54 100644 --- a/tests/core_tests/chaingen_tests_list.h +++ b/tests/core_tests/chaingen_tests_list.h @@ -39,3 +39,4 @@ #include "hard_fork_1.h" #include "hard_fork_2.h" #include "atomic_tests.h" +#include "isolate_auditable_and_proof.h" diff --git a/tests/core_tests/isolate_auditable_and_proof.cpp b/tests/core_tests/isolate_auditable_and_proof.cpp index b2907824..9b602f09 100644 --- a/tests/core_tests/isolate_auditable_and_proof.cpp +++ b/tests/core_tests/isolate_auditable_and_proof.cpp @@ -87,7 +87,7 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s tx_service_attachment sa = AUTO_VAL_INIT(sa); sa.service_id = BC_WRAP_SERVICE_ID; sa.instruction = BC_WRAP_SERVICE_INSTRUCTION_ERC20; - sa.flags = TX_SERVICE_ATTACHMENT_ENCRYPT_BODY | TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE; + sa.flags = TX_SERVICE_ATTACHMENT_ENCRYPT_BODY | TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE| TX_SERVICE_ATTACHMENT_ENCRYPT_ADD_PROOF; sa.body = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"; extra.push_back(sa); diff --git a/tests/core_tests/isolate_auditable_and_proof.h b/tests/core_tests/isolate_auditable_and_proof.h index b0df5b8d..361abc27 100644 --- a/tests/core_tests/isolate_auditable_and_proof.h +++ b/tests/core_tests/isolate_auditable_and_proof.h @@ -11,7 +11,7 @@ struct isolate_auditable_and_proof : public wallet_test { isolate_auditable_and_proof(); bool generate(std::vector& events) const; - virtual bool c1(currency::core& c, size_t ev_index, const std::vector& events)=0; + virtual bool c1(currency::core& c, size_t ev_index, const std::vector& events); virtual bool configure_core(currency::core& c, size_t ev_index, const std::vector& events); protected: mutable uint64_t m_genesis_timestamp; From c9b7e5689c95d62dcd01dde1a7077741cb242009 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 28 Jun 2021 00:08:33 +0200 Subject: [PATCH 07/37] fixed last bugs in isolate_auditable_and_proof --- src/currency_core/currency_format_utils.cpp | 4 ++-- tests/core_tests/isolate_auditable_and_proof.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 73bf0200..d78ec011 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -1017,8 +1017,8 @@ namespace currency return true; } - decrypt_payload_items(derivation, tx.extra, decrypted_items, acc_keys, get_tx_pub_key_from_extra(tx)); - decrypt_payload_items(derivation, tx.attachment, decrypted_items, acc_keys, get_tx_pub_key_from_extra(tx)); + decrypt_payload_items(derivation, tx.extra, decrypted_items, is_income ? acc_keys: account_keys(), get_tx_pub_key_from_extra(tx)); + decrypt_payload_items(derivation, tx.attachment, decrypted_items, is_income ? acc_keys : account_keys(), get_tx_pub_key_from_extra(tx)); return true; } diff --git a/tests/core_tests/isolate_auditable_and_proof.cpp b/tests/core_tests/isolate_auditable_and_proof.cpp index 9b602f09..f752b81a 100644 --- a/tests/core_tests/isolate_auditable_and_proof.cpp +++ b/tests/core_tests/isolate_auditable_and_proof.cpp @@ -93,7 +93,9 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s currency::account_public_address acc = AUTO_VAL_INIT(acc); de.addr.front() = auditable_test.get_public_address(); - currency::transaction tx; + de.amount = AMOUNT_TO_TRANSFER_LOCAL; + dsts.push_back(de); + currency::transaction tx = AUTO_VAL_INIT(tx); miner_wlt->transfer(dsts, 0, 0, miner_wlt->get_core_runtime_config().tx_default_fee, extra, attachments, tx); } From e27b8fdf18893eda414984cfb6329964269474ae Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 29 Jun 2021 16:46:03 +0200 Subject: [PATCH 08/37] final fixes in isolate_auditable_and_proof --- tests/core_tests/isolate_auditable_and_proof.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/core_tests/isolate_auditable_and_proof.cpp b/tests/core_tests/isolate_auditable_and_proof.cpp index f752b81a..e3fadbdb 100644 --- a/tests/core_tests/isolate_auditable_and_proof.cpp +++ b/tests/core_tests/isolate_auditable_and_proof.cpp @@ -76,7 +76,7 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s //create transaction that use TX_SERVICE_ATTACHMENT_ENCRYPT_BODY and TX_SERVICE_ATTACHMENT_ENCRYPT_BODY_ISOLATE_AUDITABLE - { + //{ std::vector extra; std::vector attachments; std::vector dsts; @@ -97,7 +97,7 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s dsts.push_back(de); currency::transaction tx = AUTO_VAL_INIT(tx); miner_wlt->transfer(dsts, 0, 0, miner_wlt->get_core_runtime_config().tx_default_fee, extra, attachments, tx); - } + //} bool r = mine_next_pow_blocks_in_playtime(m_mining_accunt.get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW); CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed"); @@ -113,8 +113,13 @@ bool isolate_auditable_and_proof::c1(currency::core& c, size_t ev_index, const s req.count = 100; req.offset = 0; miner_wlt_rpc.on_get_recent_txs_and_info(req, res, je, ctx); - std::string ps = epee::serialization::store_t_to_json(res); + CHECK_AND_ASSERT_MES(res.transfers.size() == 1, false, "res.transfers.size() == 1 failed"); + CHECK_AND_ASSERT_MES(res.transfers[0].service_entries.size(), false, "res.transfers[0].service_entries.size() failed"); + + CHECK_AND_ASSERT_MES(res.transfers[0].service_entries[0].body == sa.body, false, "res.transfers[0].service_entries[0].body == sa.body failed"); + CHECK_AND_ASSERT_MES(res.transfers[0].service_entries[0].service_id == sa.service_id, false, "res.transfers[0].service_entries[0].service_id == sa.service_id failed"); + CHECK_AND_ASSERT_MES(res.transfers[0].service_entries[0].instruction == sa.instruction, false, "res.transfers[0].service_entries[0].instruction == sa.instruction failed"); - return r; + return true; } From 2e5c49300465a848605e22e1b282543d63bab4a1 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 1 Jul 2021 21:05:50 +0200 Subject: [PATCH 09/37] added transfer_internal_index to wallet_transfer_info struct --- src/wallet/wallet2.cpp | 3 ++- src/wallet/wallet_public_structs_defs.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5b753b91..5801d511 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1662,7 +1662,7 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop //block matched in that number last_matched_index = height; been_matched_block = true; - WLT_LOG_L2("Block " << bl_id << " @ " << height << " is already in wallet's blockchain"); + WLT_LOG_L4("Block " << bl_id << " @ " << height << " is already in wallet's blockchain"); } else { @@ -3207,6 +3207,7 @@ void wallet2::get_recent_transfers_history(std::vector= count) { diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 3b78f2b4..48251797 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -111,6 +111,7 @@ namespace wallet_public bool show_sender; std::vector contract; uint16_t extra_flags; + uint64_t transfer_internal_index; //not included in kv serialization map @@ -139,6 +140,7 @@ namespace wallet_public KV_SERIALIZE(show_sender) KV_SERIALIZE(contract) KV_SERIALIZE(service_entries) + KV_SERIALIZE(transfer_internal_index) END_KV_SERIALIZE_MAP() }; From cabdf494301e15b7d53fc376b77d7e64fc8f34c2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 1 Jul 2021 23:00:28 +0200 Subject: [PATCH 10/37] added current_height to COMMAND_RPC_GET_RECENT_TXS_AND_INFO response --- src/wallet/wallet_public_structs_defs.h | 5 +++++ src/wallet/wallet_rpc_server.cpp | 2 ++ src/wallet/wallet_rpc_server.h | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 48251797..f93242e3 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -259,6 +259,7 @@ namespace wallet_public uint64_t transfer_entries_count; bool is_whatch_only; std::vector utxo_distribution; + uint64_t current_height; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(address) @@ -267,6 +268,8 @@ namespace wallet_public KV_SERIALIZE(transfer_entries_count) KV_SERIALIZE(is_whatch_only) KV_SERIALIZE(utxo_distribution) + KV_SERIALIZE(current_height) + KV_SERIALIZE_POD_AS_HEX_STRING(last_block_id) END_KV_SERIALIZE_MAP() }; }; @@ -304,6 +307,7 @@ namespace wallet_public uint64_t transfer_entries_count; uint64_t balance; uint64_t unlocked_balance; + uint64_t curent_height; BEGIN_KV_SERIALIZE_MAP() @@ -311,6 +315,7 @@ namespace wallet_public KV_SERIALIZE(transfer_entries_count) KV_SERIALIZE(balance) KV_SERIALIZE(unlocked_balance) + KV_SERIALIZE(curent_height) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 71d34fa1..4f581e22 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -208,6 +208,7 @@ namespace tools for (const auto& ent : distribution) res.utxo_distribution.push_back(currency::print_money_brief(ent.first) + ":" + std::to_string(ent.second)); + res.current_height = m_wallet.get_top_block_height(); return true; } catch (std::exception& e) @@ -245,6 +246,7 @@ namespace tools res.pi.balance = m_wallet.balance(res.pi.unlocked_balance); res.pi.transfer_entries_count = m_wallet.get_transfer_entries_count(); res.pi.transfers_count = m_wallet.get_recent_transfers_total_count(); + res.pi.curent_height = m_wallet.get_top_block_height(); } if (req.offset == 0) diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 2d94bc52..3c75296e 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -66,10 +66,10 @@ namespace tools MAP_JON_RPC_WE("marketplace_push_update_offer", on_marketplace_push_update_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER) MAP_JON_RPC_WE("marketplace_cancel_offer", on_marketplace_cancel_offer, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER) //HTLC API - MAP_JON_RPC_WE("atomics_create_htlc_proposal", on_create_htlc_proposal, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL) - MAP_JON_RPC_WE("atomics_get_list_of_active_htlc", on_get_list_of_active_htlc, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC) - MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC) - MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED) + MAP_JON_RPC_WE("atomics_create_htlc_proposal", on_create_htlc_proposal, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL) + MAP_JON_RPC_WE("atomics_get_list_of_active_htlc", on_get_list_of_active_htlc, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC) + MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC) + MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED) END_JSON_RPC_MAP() END_URI_MAP2() From 585c01d3aaf0b65c977faf972336452557ebe91f Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 1 Jul 2021 23:47:31 +0200 Subject: [PATCH 11/37] removed forgotten field --- src/wallet/wallet_public_structs_defs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index f93242e3..4c3061fd 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -269,7 +269,6 @@ namespace wallet_public KV_SERIALIZE(is_whatch_only) KV_SERIALIZE(utxo_distribution) KV_SERIALIZE(current_height) - KV_SERIALIZE_POD_AS_HEX_STRING(last_block_id) END_KV_SERIALIZE_MAP() }; }; From 83dcb88d229fc31074ec878a8f58e5ce345a2782 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 4 Jul 2021 21:08:54 +0200 Subject: [PATCH 12/37] added FORCE_HEADER_ONLY for projects that use header files as external interface --- src/currency_core/account.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/currency_core/account.h b/src/currency_core/account.h index e9674307..37a0c953 100644 --- a/src/currency_core/account.h +++ b/src/currency_core/account.h @@ -16,13 +16,15 @@ #define SEED_PHRASE_V2_WORDS_COUNT 26 +#ifndef FORCE_HEADER_ONLY + #define KV_SERIALIZE_ADDRESS_AS_TEXT_N(varialble, val_name) \ + KV_SERIALIZE_CUSTOM_N(varialble, std::string, currency::transform_addr_to_str, currency::transform_str_to_addr, val_name) -#define KV_SERIALIZE_ADDRESS_AS_TEXT_N(varialble, val_name) \ - KV_SERIALIZE_CUSTOM_N(varialble, std::string, currency::transform_addr_to_str, currency::transform_str_to_addr, val_name) - -#define KV_SERIALIZE_ADDRESS_AS_TEXT(varialble) KV_SERIALIZE_ADDRESS_AS_TEXT_N(varialble, #varialble) - - + #define KV_SERIALIZE_ADDRESS_AS_TEXT(varialble) KV_SERIALIZE_ADDRESS_AS_TEXT_N(varialble, #varialble) +#else + #define KV_SERIALIZE_ADDRESS_AS_TEXT_N(varialble, val_name) + #define KV_SERIALIZE_ADDRESS_AS_TEXT(varialble) +#endif namespace currency { From 232a6d71d0128df159ef0edfca7913a76e4a5432 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 6 Jul 2021 15:40:40 +0200 Subject: [PATCH 13/37] removed annoying < and > symbols --- src/common/crypto_stream_operators.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/crypto_stream_operators.h b/src/common/crypto_stream_operators.h index 0201603b..fa2531de 100644 --- a/src/common/crypto_stream_operators.h +++ b/src/common/crypto_stream_operators.h @@ -15,20 +15,20 @@ bool parse_hash256(const std::string str_hash, crypto::hash& hash); template std::ostream &print_t(std::ostream &o, const T &v) { - return o << "<" << epee::string_tools::pod_to_hex(v) << ">"; + return o << "" << epee::string_tools::pod_to_hex(v) << ""; } template std::ostream &print16(std::ostream &o, const T &v) { - return o << "<" << epee::string_tools::pod_to_hex(v).substr(0, 5) << "..>"; + return o << "" << epee::string_tools::pod_to_hex(v).substr(0, 5) << ".."; } template std::string print16(const T &v) { - return std::string("<") + epee::string_tools::pod_to_hex(v).substr(0, 5) + "..>"; + return std::string("") + epee::string_tools::pod_to_hex(v).substr(0, 5) + ".."; } From 71c9069d27aae50287d73ed8eaf60b23d925f1c0 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 17 Jul 2021 00:05:41 +0200 Subject: [PATCH 14/37] extended wallet transfer API to service_entries option --- src/currency_core/currency_basic.h | 2 +- src/wallet/wallet2.h | 7 ++++--- src/wallet/wallet_public_structs_defs.h | 5 ++++- src/wallet/wallet_rpc_server.cpp | 28 ++++++++++++++++++------- src/wallet/wrap_service.h | 3 ++- 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 7dd6a8cd..dc973a66 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -387,7 +387,7 @@ namespace currency BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(service_id) KV_SERIALIZE(instruction) - KV_SERIALIZE(body) + KV_SERIALIZE_BLOB_AS_HEX_STRING(body) KV_SERIALIZE_CONTAINER_POD_AS_BLOB(security) KV_SERIALIZE(flags) END_KV_SERIALIZE_MAP() diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 4d4d8b92..b1281e08 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -595,12 +595,12 @@ namespace tools void transfer(construct_tx_param& ctp, currency::transaction &tx, bool send_to_network, - std::string* p_unsigned_filename_or_tx_blob_str); + std::string* p_unsigned_filename_or_tx_blob_str = nullptr); void transfer(construct_tx_param& ctp, currency::finalized_tx& result, bool send_to_network, - std::string* p_unsigned_filename_or_tx_blob_str); + std::string* p_unsigned_filename_or_tx_blob_str = nullptr); template @@ -854,6 +854,7 @@ namespace tools uint64_t get_sync_progress(); uint64_t get_wallet_file_size()const; void set_use_deffered_global_outputs(bool use); + construct_tx_param get_default_construct_tx_param_inital(); /* create_htlc_proposal: if htlc_hash == null_hash, then this wallet is originator of the atomic process, and @@ -943,7 +944,7 @@ private: void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_public::wallet_transfer_info& wti) const; void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const; - construct_tx_param get_default_construct_tx_param_inital(); + const construct_tx_param& get_default_construct_tx_param(); uint64_t get_tx_expiration_median() const; diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 4c3061fd..0084e418 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -388,16 +388,19 @@ namespace wallet_public std::string comment; bool push_payer; bool hide_receiver; + std::vector service_entries; + bool service_entries_permanent; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(destinations) KV_SERIALIZE(fee) KV_SERIALIZE(mixin) - //KV_SERIALIZE(unlock_time) KV_SERIALIZE(payment_id) KV_SERIALIZE(comment) KV_SERIALIZE(push_payer) KV_SERIALIZE(hide_receiver) + KV_SERIALIZE(service_entries) + KV_SERIALIZE(service_entries_permanent) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 4f581e22..13b9834a 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -281,7 +281,18 @@ namespace tools return false; } - std::vector dsts; + construct_tx_param ctp = m_wallet.get_default_construct_tx_param_inital(); + if (req.service_entries_permanent) + { + //put it to extra + ctp.extra.insert(ctp.extra.end(), req.service_entries.begin(), req.service_entries.end()); + } + else + { + //put it to attachments + ctp.attachments.insert(ctp.extra.end(), req.service_entries.begin(), req.service_entries.end()); + } + std::vector& dsts = ctp.dsts; for (auto it = req.destinations.begin(); it != req.destinations.end(); it++) { currency::tx_destination_entry de; @@ -308,8 +319,8 @@ namespace tools } try { - std::vector attachments; - std::vector extra; + std::vector& attachments = ctp.attachments; + std::vector& extra = ctp.extra; if (!payment_id.empty() && !currency::set_payment_id_to_tx(attachments, payment_id)) { er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID; @@ -338,10 +349,11 @@ namespace tools } } - currency::transaction tx; - + currency::finalized_tx result = AUTO_VAL_INIT(result); std::string unsigned_tx_blob_str; - m_wallet.transfer(dsts, req.mixin, 0/*req.unlock_time*/, req.fee, extra, attachments, detail::ssi_digit, tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, CURRENCY_TO_KEY_OUT_RELAXED, true, 0, true, &unsigned_tx_blob_str); + ctp.fee = req.fee; + ctp.fake_outputs_count = 0; + m_wallet.transfer(ctp, result, true, &unsigned_tx_blob_str); if (m_wallet.is_watch_only()) { res.tx_unsigned_hex = epee::string_tools::buff_to_hex_nodelimer(unsigned_tx_blob_str); // watch-only wallets could not sign and relay transactions @@ -349,8 +361,8 @@ namespace tools } else { - res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(tx)); - res.tx_size = get_object_blobsize(tx); + res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(result.tx)); + res.tx_size = get_object_blobsize(result.tx); } return true; } diff --git a/src/wallet/wrap_service.h b/src/wallet/wrap_service.h index 852d60d7..52b288d4 100644 --- a/src/wallet/wrap_service.h +++ b/src/wallet/wrap_service.h @@ -6,7 +6,8 @@ #define BC_WRAP_SERVICE_ID "W" -#define BC_WRAP_SERVICE_INSTRUCTION_ERC20 "ERC20" //erc20 wrapped operation +#define BC_WRAP_SERVICE_INSTRUCTION_ERC20 "ERC20" //erc20 wrap operation +#define BC_WRAP_SERVICE_INSTRUCTION_UNWRAP "UNWRAP" //erc20 unwrap operation #define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxbJPXzkjCJDpGEVvkMir9B4fRKPo73r2e5D7nLHuVgEBXXQYc2Tk2hHroxVwiCDLDHZu215pgNocUsrchH4HHzWbHzL4nMfPq" \ No newline at end of file From 9d21077b5ecb720c4e44e78372b542efcf5b5dca Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 18 Jul 2021 01:57:45 +0200 Subject: [PATCH 15/37] Added green logs shortcut --- contrib/epee/include/misc_log_ex.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index e0a58617..1d54b6f9 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -183,7 +183,8 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_cyan) #define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_magenta) -#define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red) +#define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red) +#define LOG_PRINT_GREEN_L0(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_green) #define LOG_PRINT_L0(mess) LOG_PRINT(mess, LOG_LEVEL_0) #define LOG_PRINT_L1(mess) LOG_PRINT(mess, LOG_LEVEL_1) From fafdfd196a21984888aa5e0d1395995aee282374 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 19 Jul 2021 22:52:59 +0200 Subject: [PATCH 16/37] modified logging in wallet --- contrib/epee/include/misc_log_ex.h | 2 +- src/simplewallet/simplewallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 1d54b6f9..0b05d313 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -184,7 +184,7 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_magenta) #define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red) -#define LOG_PRINT_GREEN_L0(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_green) +#define LOG_PRINT_GREEN_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_green) #define LOG_PRINT_L0(mess) LOG_PRINT(mess, LOG_LEVEL_0) #define LOG_PRINT_L1(mess) LOG_PRINT(mess, LOG_LEVEL_1) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 654ec78d..bed7e83c 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -754,7 +754,7 @@ bool print_wti(const tools::wallet_public::wallet_transfer_info& wti) remote_side += remote_side.empty() ? it : (separator + it); } - message_writer(cl) << epee::misc_utils::get_time_str_v2(wti.timestamp) << " " + success_msg_writer(cl) << "[" << wti.transfer_internal_index << "]" << epee::misc_utils::get_time_str_v2(wti.timestamp) << " " << (wti.is_income ? "Received " : "Sent ") << print_money(wti.amount) << "(fee:" << print_money(wti.fee) << ") " << remote_side @@ -768,7 +768,7 @@ bool simple_wallet::list_recent_transfers(const std::vector& args) std::vector recent; uint64_t total = 0; uint64_t last_index = 0; - m_wallet->get_recent_transfers_history(recent, 0, 0, total, last_index, false); + m_wallet->get_recent_transfers_history(recent, std::stoll(args[0]), std::stoll(args[1]), total, last_index, false); m_wallet->get_unconfirmed_transfers(unconfirmed, false); //workaround for missed fee From d387ad91124acaa01eae6f1767cadef339f99a23 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 20 Jul 2021 15:36:47 +0200 Subject: [PATCH 17/37] extended api for wallet --- src/simplewallet/simplewallet.cpp | 2 +- src/wallet/wallet2.cpp | 40 ++++++++++++++++++------- src/wallet/wallet2.h | 2 +- src/wallet/wallet_public_structs_defs.h | 6 ++++ src/wallet/wallet_rpc_server.cpp | 7 ++++- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index bed7e83c..e83791e5 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -768,7 +768,7 @@ bool simple_wallet::list_recent_transfers(const std::vector& args) std::vector recent; uint64_t total = 0; uint64_t last_index = 0; - m_wallet->get_recent_transfers_history(recent, std::stoll(args[0]), std::stoll(args[1]), total, last_index, false); + m_wallet->get_recent_transfers_history(recent, std::stoll(args[0]), std::stoll(args[1]), total, last_index, false, false); m_wallet->get_unconfirmed_transfers(unconfirmed, false); //workaround for missed fee diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5801d511..21e49f5d 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3192,29 +3192,49 @@ uint64_t wallet2::get_transfer_entries_count() return m_transfers.size(); } //---------------------------------------------------------------------------------------------------- -void wallet2::get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs) + +template +bool enum_container(iterator_t it_begin, iterator_t it_end, callback_t cb) +{ + for (iterator_t it = it_begin; it != it_end; it++) + { + if (!cb(*it, it - it_begin)) + return true; + } + return true; +} +//---------------------------------------------------------------------------------------------------- +void wallet2::get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs, bool start_from_end) { if (!count || offset >= m_transfer_history.size()) return; - for (auto it = m_transfer_history.rbegin() + offset; it != m_transfer_history.rend(); it++) - { + auto cb = [&](wallet_public::wallet_transfer_info& wti, size_t local_offset) { + if (exclude_mining_txs) { - if(currency::is_coinbase(it->tx)) - continue; + if (currency::is_coinbase(wti.tx)) + return true; } - trs.push_back(*it); + trs.push_back(wti); load_wallet_transfer_info_flags(trs.back()); - last_item_index = it - m_transfer_history.rbegin(); + last_item_index = offset + local_offset; trs.back().transfer_internal_index = last_item_index; - + if (trs.size() >= count) { - break; + return false; } - } + return true; + }; + + if(start_from_end) + enum_container(m_transfer_history.rbegin() + offset, m_transfer_history.rend(), cb); + else + enum_container(m_transfer_history.begin() + offset, m_transfer_history.end(), cb); + total = m_transfer_history.size(); + } //---------------------------------------------------------------------------------------------------- bool wallet2::get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index b1281e08..10d79bf6 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -509,7 +509,7 @@ namespace tools currency::account_base& get_account() { return m_account; } const currency::account_base& get_account() const { return m_account; } - void get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs = false); + void get_recent_transfers_history(std::vector& trs, size_t offset, size_t count, uint64_t& total, uint64_t& last_item_index, bool exclude_mining_txs = false, bool start_from_end = true); uint64_t get_recent_transfers_total_count(); uint64_t get_transfer_entries_count(); void get_unconfirmed_transfers(std::vector& trs, bool exclude_mining_txs = false); diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 0084e418..d12d1367 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -318,6 +318,10 @@ namespace wallet_public END_KV_SERIALIZE_MAP() }; + +#define ORDER_FROM_BEGIN_TO_END "FROM_BEGIN_TO_END" +#define ORDER_FROM_FROM_END_TO_BEGIN "FROM_END_TO_BEGIN" + struct COMMAND_RPC_GET_RECENT_TXS_AND_INFO { struct request @@ -338,12 +342,14 @@ namespace wallet_public */ bool update_provision_info; bool exclude_mining_txs; + std::string order; // "FROM_BEGIN_TO_END" or "FROM_END_TO_BEGIN" BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(offset) KV_SERIALIZE(count) KV_SERIALIZE(update_provision_info) KV_SERIALIZE(exclude_mining_txs) + KV_SERIALIZE(order) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 13b9834a..fdfb6f20 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -252,7 +252,12 @@ namespace tools if (req.offset == 0) m_wallet.get_unconfirmed_transfers(res.transfers, req.exclude_mining_txs); - m_wallet.get_recent_transfers_history(res.transfers, req.offset, req.count, res.total_transfers, res.last_item_index, req.exclude_mining_txs); + bool start_from_end = true; + if (req.order == ORDER_FROM_BEGIN_TO_END) + { + start_from_end = false; + } + m_wallet.get_recent_transfers_history(res.transfers, req.offset, req.count, res.total_transfers, res.last_item_index, req.exclude_mining_txs, start_from_end); return true; } From 17056bdf444d6d69cd89603c9db31ed5cf6614fa Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 21 Jul 2021 00:25:12 +0200 Subject: [PATCH 18/37] More options on wallet API --- src/wallet/wallet2.cpp | 17 +++++++++-------- src/wallet/wallet_public_structs_defs.h | 2 ++ src/wallet/wallet_rpc_server.cpp | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 21e49f5d..10bb0475 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -709,20 +709,21 @@ void wallet2::prepare_wti_decrypted_attachments(wallet_public::wallet_transfer_i } get_payment_id_from_tx(decrypted_att, wti.payment_id); + for (const auto& item : decrypted_att) + { + if (item.type() == typeid(currency::tx_service_attachment)) + { + wti.service_entries.push_back(boost::get(item)); + } + } + + if (wti.is_income) { account_public_address sender_address = AUTO_VAL_INIT(sender_address); wti.show_sender = handle_2_alternative_types_in_variant_container(decrypted_att, [&](const tx_payer& p) { sender_address = p.acc_addr; return false; /* <- continue? */ } ); if (wti.show_sender) wti.remote_addresses.push_back(currency::get_account_address_as_str(sender_address)); - - for (const auto& item : decrypted_att) - { - if (item.type() == typeid(currency::tx_service_attachment)) - { - wti.service_entries.push_back(boost::get(item)); - } - } } else { diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index d12d1367..960516db 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -342,6 +342,7 @@ namespace wallet_public */ bool update_provision_info; bool exclude_mining_txs; + bool exclude_unconfirmed; std::string order; // "FROM_BEGIN_TO_END" or "FROM_END_TO_BEGIN" BEGIN_KV_SERIALIZE_MAP() @@ -349,6 +350,7 @@ namespace wallet_public KV_SERIALIZE(count) KV_SERIALIZE(update_provision_info) KV_SERIALIZE(exclude_mining_txs) + KV_SERIALIZE(exclude_unconfirmed) KV_SERIALIZE(order) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index fdfb6f20..aca13701 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -249,7 +249,7 @@ namespace tools res.pi.curent_height = m_wallet.get_top_block_height(); } - if (req.offset == 0) + if (req.offset == 0 && !req.exclude_unconfirmed) m_wallet.get_unconfirmed_transfers(res.transfers, req.exclude_mining_txs); bool start_from_end = true; From b1bb1f2ac134f45f90a8b4ce18a65b949124d3b4 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 22 Jul 2021 00:44:28 +0200 Subject: [PATCH 19/37] upgraded logs --- contrib/epee/include/misc_log_ex.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 0b05d313..b8749cd7 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -141,8 +141,10 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_CHANNEL_2_JORNAL(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);CATCH_ALL_DO_NOTHING();}} -#define LOG_ERROR2(log_name, x) { \ - TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::get_callstack() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL);CATCH_ALL_DO_NOTHING();} +#define LOG_ERROR2_CB(log_name, x, cb) { \ + TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::get_callstack() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL); cb(ss________.str()); CATCH_ALL_DO_NOTHING();} + +#define LOG_ERROR2(log_name, x) LOG_ERROR2_CB(log_name, x, epee::log_space::log_stub) #define LOG_FRAME2(log_name, x, y) epee::log_space::log_frame frame(x, y, log_name) @@ -194,6 +196,7 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_J(mess, level) LOG_PRINT2_JORNAL(LOG_DEFAULT_TARGET, mess, level) #define LOG_ERROR(mess) LOG_ERROR2(LOG_DEFAULT_TARGET, mess) +#define LOG_ERROR_CB(mess, cb) LOG_ERROR2_CB(LOG_DEFAULT_TARGET, mess, cb) #define LOG_FRAME(mess, level) LOG_FRAME2(LOG_DEFAULT_TARGET, mess, level) #define LOG_VALUE(mess, level) LOG_VALUE2(LOG_DEFAULT_TARGET, mess, level) #define LOG_ARRAY(mess, level) LOG_ARRAY2(LOG_DEFAULT_TARGET, mess, level) @@ -334,7 +337,8 @@ namespace log_space /* */ /************************************************************************/ #define CONSOLE_DEFAULT_STREAM std::cout - + + inline void log_stub(const std::string& /**/) {} struct delete_ptr { From 84d4af7c18ba4a077e6a36b2e92ee75e482b95fc Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Mon, 26 Jul 2021 16:17:13 +0200 Subject: [PATCH 20/37] fixed correct auditable address --- src/wallet/wrap_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wrap_service.h b/src/wallet/wrap_service.h index 52b288d4..0ca52d15 100644 --- a/src/wallet/wrap_service.h +++ b/src/wallet/wrap_service.h @@ -10,4 +10,4 @@ #define BC_WRAP_SERVICE_INSTRUCTION_UNWRAP "UNWRAP" //erc20 unwrap operation -#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxbJPXzkjCJDpGEVvkMir9B4fRKPo73r2e5D7nLHuVgEBXXQYc2Tk2hHroxVwiCDLDHZu215pgNocUsrchH4HHzWbHzL4nMfPq" \ No newline at end of file +#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxaszi4TaDCUqRCmqe23HASryshQNHmBSFnUN1pY8VsRfss2ZSMGBpLhdFtHgKmFr353NneaYRT6CpSz7zA3EC9bocQcq7m9nP" \ No newline at end of file From 4c01aec842911b069551e9b9c58d3c37e757814b Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 27 Jul 2021 22:45:06 +0200 Subject: [PATCH 21/37] fixed bug in list_recent_transfers --- src/simplewallet/simplewallet.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index e83791e5..c72242d3 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -192,7 +192,7 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("balance", boost::bind(&simple_wallet::show_balance, this, _1), "Show current wallet balance"); m_cmd_binder.set_handler("incoming_transfers", boost::bind(&simple_wallet::show_incoming_transfers, this, _1), "incoming_transfers [available|unavailable] - Show incoming transfers - all of them or filter them by availability"); m_cmd_binder.set_handler("incoming_counts", boost::bind(&simple_wallet::show_incoming_transfers_counts, this, _1), "incoming_transfers counts"); - m_cmd_binder.set_handler("list_recent_transfers", boost::bind(&simple_wallet::list_recent_transfers, this, _1), "list_recent_transfers - Show recent maximum 1000 transfers"); + m_cmd_binder.set_handler("list_recent_transfers", boost::bind(&simple_wallet::list_recent_transfers, this, _1), "list_recent_transfers [offset] [count] - Show recent maximum 1000 transfers, offset default = 0, count default = 100 "); m_cmd_binder.set_handler("export_recent_transfers", boost::bind(&simple_wallet::export_recent_transfers, this, _1), "list_recent_transfers_tx - Write recent transfer in json to wallet_recent_transfers.txt"); m_cmd_binder.set_handler("list_outputs", boost::bind(&simple_wallet::list_outputs, this, _1), "list_outputs [spent|unspent] - Lists all the outputs that have ever been sent to this wallet if called without arguments, otherwise it lists only the spent or unspent outputs"); m_cmd_binder.set_handler("dump_transfers", boost::bind(&simple_wallet::dump_trunsfers, this, _1), "dump_transfers - Write transfers in json to dump_transfers.txt"); @@ -766,9 +766,15 @@ bool simple_wallet::list_recent_transfers(const std::vector& args) { std::vector unconfirmed; std::vector recent; + uint64_t offset = 0; + if (args.size() > 0) + offset = std::stoll(args[0]); + uint64_t count = 1000; + if (args.size() > 1) + count = std::stoll(args[1]); uint64_t total = 0; uint64_t last_index = 0; - m_wallet->get_recent_transfers_history(recent, std::stoll(args[0]), std::stoll(args[1]), total, last_index, false, false); + m_wallet->get_recent_transfers_history(recent, offset, count, total, last_index, false, false); m_wallet->get_unconfirmed_transfers(unconfirmed, false); //workaround for missed fee From da7756c73aa2544455e438a8ce7ea8c697b5bf23 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 29 Jul 2021 22:32:46 +0200 Subject: [PATCH 22/37] improved json rpc lib and logging lib --- contrib/epee/include/misc_log_ex.h | 36 +++++++++++++------ .../include/storages/http_abstract_invoke.h | 21 ++++++++++- tests/performance_tests/main.cpp | 12 +++++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index b8749cd7..d7599ed2 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -132,11 +132,11 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_CHANNEL_NO_POSTFIX2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x; epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} -#define LOG_PRINT_CHANNEL2(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ - {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);CATCH_ALL_DO_NOTHING();}} +#define LOG_PRINT_CHANNEL2_CB(log_channel, log_name, x, y, cb) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ + {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, false, log_name);cb(ss________.str());CATCH_ALL_DO_NOTHING();}} -#define LOG_PRINT_CHANNEL_COLOR2(log_channel, log_name, x, y, color) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ - {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name);CATCH_ALL_DO_NOTHING();}} +#define LOG_PRINT_CHANNEL_COLOR2_CB(log_channel, log_name, x, y, color, cb) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ + {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, color, false, log_name); cb(ss________.str());CATCH_ALL_DO_NOTHING();}} #define LOG_PRINT_CHANNEL_2_JORNAL(log_channel, log_name, x, y) {if ( y <= epee::log_space::log_singletone::get_log_detalisation_level() && epee::log_space::log_singletone::channel_enabled(log_channel))\ {TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << x << std::endl;epee::log_space::log_singletone::do_log_message(ss________.str(), y, epee::log_space::console_color_default, true, log_name);CATCH_ALL_DO_NOTHING();}} @@ -145,6 +145,8 @@ DISABLE_VS_WARNINGS(4100) TRY_ENTRY();std::stringstream ss________; ss________ << epee::log_space::log_singletone::get_prefix_entry() << "[ERROR] Location: " << std::endl << LOCATION_SS << epee::misc_utils::get_callstack() << " Message:" << std::endl << x << std::endl; epee::log_space::log_singletone::do_log_message(ss________.str(), LOG_LEVEL_0, epee::log_space::console_color_red, true, log_name); LOCAL_ASSERT(0); epee::log_space::increase_error_count(LOG_DEFAULT_CHANNEL); cb(ss________.str()); CATCH_ALL_DO_NOTHING();} #define LOG_ERROR2(log_name, x) LOG_ERROR2_CB(log_name, x, epee::log_space::log_stub) +#define LOG_PRINT_CHANNEL2(log_channel, log_name, x, y) LOG_PRINT_CHANNEL2_CB(log_channel, log_name, x, y, epee::log_space::log_stub) +#define LOG_PRINT_CHANNEL_COLOR2(log_channel, log_name, x, y, color) LOG_PRINT_CHANNEL_COLOR2_CB(log_channel, log_name, x, y, color, epee::log_space::log_stub) #define LOG_FRAME2(log_name, x, y) epee::log_space::log_frame frame(x, y, log_name) @@ -165,7 +167,9 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_NO_PREFIX_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y) #define LOG_PRINT_NO_POSTFIX2(log_name, x, y) LOG_PRINT_CHANNEL_NO_POSTFIX2(LOG_DEFAULT_CHANNEL, log_name, x, y) #define LOG_PRINT2(log_name, x, y) LOG_PRINT_CHANNEL2(LOG_DEFAULT_CHANNEL, log_name, x, y) +#define LOG_PRINT2_CB(log_name, x, y, cb) LOG_PRINT_CHANNEL2_CB(LOG_DEFAULT_CHANNEL, log_name, x, y, cb) #define LOG_PRINT_COLOR2(log_name, x, y, color) LOG_PRINT_CHANNEL_COLOR2(LOG_DEFAULT_CHANNEL, log_name, x, y, color) +#define LOG_PRINT_COLOR2_CB(log_name, x, y, color, cb) LOG_PRINT_CHANNEL_COLOR2_CB(LOG_DEFAULT_CHANNEL, log_name, x, y, color, cb) #define LOG_PRINT2_JORNAL(log_name, x, y) LOG_PRINT_CHANNEL_2_JORNAL(LOG_DEFAULT_CHANNEL, log_name, x, y) #ifndef LOG_DEFAULT_TARGET @@ -175,15 +179,25 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_NO_POSTFIX(mess, level) LOG_PRINT_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level) #define LOG_PRINT_NO_PREFIX(mess, level) LOG_PRINT_NO_PREFIX2(LOG_DEFAULT_TARGET, mess, level) #define LOG_PRINT_NO_PREFIX_NO_POSTFIX(mess, level) LOG_PRINT_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level) -#define LOG_PRINT(mess, level) LOG_PRINT2(LOG_DEFAULT_TARGET, mess, level) +#define LOG_PRINT(mess, level) LOG_PRINT2(LOG_DEFAULT_TARGET, mess, level) +#define LOG_PRINT_CB(mess, level, cb) LOG_PRINT2_CB(LOG_DEFAULT_TARGET, mess, level, cb) +#define LOG_PRINT_COLOR_CB(mess, level, color, cb) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, color, cb) + +#define LOG_COLOR_RED epee::log_space::console_color_red +#define LOG_COLOR_GREEN epee::log_space::console_color_green +#define LOG_COLOR_BLUE epee::log_space::console_color_blue +#define LOG_COLOR_YELLOW epee::log_space::console_color_yellow +#define LOG_COLOR_CYAN epee::log_space::console_color_cyan +#define LOG_COLOR_MAGENTA epee::log_space::console_color_magenta + #define LOG_PRINT_COLOR(mess, level, color) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, color) -#define LOG_PRINT_RED(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_red) -#define LOG_PRINT_GREEN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_green) -#define LOG_PRINT_BLUE(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_blue) -#define LOG_PRINT_YELLOW(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_yellow) -#define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_cyan) -#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, epee::log_space::console_color_magenta) +#define LOG_PRINT_RED(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_RED) +#define LOG_PRINT_GREEN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_GREEN) +#define LOG_PRINT_BLUE(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_BLUE) +#define LOG_PRINT_YELLOW(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_YELLOW) +#define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_CYAN) +#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, ) #define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red) #define LOG_PRINT_GREEN_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_green) diff --git a/contrib/epee/include/storages/http_abstract_invoke.h b/contrib/epee/include/storages/http_abstract_invoke.h index 5305c543..0b6ef8e3 100644 --- a/contrib/epee/include/storages/http_abstract_invoke.h +++ b/contrib/epee/include/storages/http_abstract_invoke.h @@ -94,9 +94,28 @@ namespace epee return serialization::load_t_from_binary(result_struct, pri->m_body); } + + template + bool invoke_http_json_rpc(const std::string& url, const std::string& method_name, const t_request& out_struct, t_response& result_struct, t_transport& transport, epee::json_rpc::error& err, unsigned int timeout = 5000, const std::string& http_method = "GET", const std::string& req_id = "0") + { + epee::json_rpc::request req_t = AUTO_VAL_INIT(req_t); + req_t.jsonrpc = "2.0"; + req_t.id = req_id; + req_t.method = method_name; + req_t.params = out_struct; + epee::json_rpc::response resp_t = AUTO_VAL_INIT(resp_t); + if (!epee::net_utils::invoke_http_json_remote_command2(url, req_t, resp_t, transport, timeout, http_method)) + { + return false; + } + err = resp_t.error; + result_struct = resp_t.result; + return true; + } + template bool invoke_http_json_rpc(const std::string& url, const std::string& method_name, const t_request& out_struct, t_response& result_struct, t_transport& transport, unsigned int timeout = 5000, const std::string& http_method = "GET", const std::string& req_id = "0") - { + { epee::json_rpc::request req_t = AUTO_VAL_INIT(req_t); req_t.jsonrpc = "2.0"; req_t.id = req_id; diff --git a/tests/performance_tests/main.cpp b/tests/performance_tests/main.cpp index df60b58e..c3f0a77a 100644 --- a/tests/performance_tests/main.cpp +++ b/tests/performance_tests/main.cpp @@ -33,8 +33,20 @@ int main(int argc, char** argv) epee::log_space::log_singletone::get_default_log_file().c_str(), epee::log_space::log_singletone::get_default_log_folder().c_str()); + + std::string buf1 = tools::get_varint_data(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX); + std::string buf2 = tools::get_varint_data(CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX); + std::string buf3 = tools::get_varint_data(CURRENCY_PUBLIC_INTEG_ADDRESS_V2_BASE58_PREFIX); + std::string buf4 = tools::get_varint_data(CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX); + std::string buf5 = tools::get_varint_data(CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX); + std::cout << "Buf1: " << epee::string_tools::buff_to_hex_nodelimer(buf1) << ENDL; + std::cout << "Buf2: " << epee::string_tools::buff_to_hex_nodelimer(buf2) << ENDL; + std::cout << "Buf3: " << epee::string_tools::buff_to_hex_nodelimer(buf3) << ENDL; + std::cout << "Buf4: " << epee::string_tools::buff_to_hex_nodelimer(buf4) << ENDL; + std::cout << "Buf5: " << epee::string_tools::buff_to_hex_nodelimer(buf5) << ENDL; + do_htlc_hash_tests(); //run_serialization_performance_test(); //return 1; From 8d4f032d05f54a58273514406fdb8570323b4274 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 29 Jul 2021 22:35:36 +0200 Subject: [PATCH 23/37] forgoten magenta --- contrib/epee/include/misc_log_ex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index d7599ed2..64c2973d 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -197,7 +197,7 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT_BLUE(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_BLUE) #define LOG_PRINT_YELLOW(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_YELLOW) #define LOG_PRINT_CYAN(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_CYAN) -#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, ) +#define LOG_PRINT_MAGENTA(mess, level) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, LOG_COLOR_MAGENTA) #define LOG_PRINT_RED_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_red) #define LOG_PRINT_GREEN_L0(mess) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, LOG_LEVEL_0, epee::log_space::console_color_green) From bf43b41bddc5a9382769b8e748cda11ed9d6b046 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 29 Jul 2021 22:40:42 +0200 Subject: [PATCH 24/37] forgoten LOG_PRINT_COLOR2_CB --- contrib/epee/include/misc_log_ex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h index 64c2973d..0b957a5f 100644 --- a/contrib/epee/include/misc_log_ex.h +++ b/contrib/epee/include/misc_log_ex.h @@ -182,7 +182,7 @@ DISABLE_VS_WARNINGS(4100) #define LOG_PRINT(mess, level) LOG_PRINT2(LOG_DEFAULT_TARGET, mess, level) #define LOG_PRINT_CB(mess, level, cb) LOG_PRINT2_CB(LOG_DEFAULT_TARGET, mess, level, cb) -#define LOG_PRINT_COLOR_CB(mess, level, color, cb) LOG_PRINT_COLOR2(LOG_DEFAULT_TARGET, mess, level, color, cb) +#define LOG_PRINT_COLOR_CB(mess, level, color, cb) LOG_PRINT_COLOR2_CB(LOG_DEFAULT_TARGET, mess, level, color, cb) #define LOG_COLOR_RED epee::log_space::console_color_red #define LOG_COLOR_GREEN epee::log_space::console_color_green From 0d3682efdfda283509b66161c1f5c202c06e8aef Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 7 Aug 2021 22:01:00 +0200 Subject: [PATCH 25/37] address validation for wrap --- src/wallet/wallets_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index eb101997..0d3c9f6b 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1753,7 +1753,11 @@ std::string wallets_manager::get_offers_ex(const bc_services::core_offers_filter std::string wallets_manager::validate_address(const std::string& addr_str, std::string& payment_id) { currency::account_public_address acc = AUTO_VAL_INIT(acc); - if (currency::get_account_address_and_payment_id_from_str(acc, payment_id, addr_str)) + if (is_address_like_wrapped(addr_str)) + { + return API_RETURN_CODE_TRUE; + } + else if (currency::get_account_address_and_payment_id_from_str(acc, payment_id, addr_str)) return API_RETURN_CODE_TRUE; else return API_RETURN_CODE_FALSE; From 0f40aba1e690bd02fd03c02476a68254bedf9860 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 7 Aug 2021 22:16:12 +0200 Subject: [PATCH 26/37] fixed missing namespace --- src/wallet/wallets_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 0d3c9f6b..4dbba747 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1753,7 +1753,7 @@ std::string wallets_manager::get_offers_ex(const bc_services::core_offers_filter std::string wallets_manager::validate_address(const std::string& addr_str, std::string& payment_id) { currency::account_public_address acc = AUTO_VAL_INIT(acc); - if (is_address_like_wrapped(addr_str)) + if (currency::is_address_like_wrapped(addr_str)) { return API_RETURN_CODE_TRUE; } From abb9bb62804aaaf7fbab9b274d0399846d8b29b4 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 17 Aug 2021 12:12:20 +0200 Subject: [PATCH 27/37] added wrap address support in mobile wallet --- src/wallet/plain_wallet_api.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 4b8a8fd6..b2f31850 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -367,15 +367,30 @@ namespace plain_wallet currency::account_public_address apa = AUTO_VAL_INIT(apa); currency::payment_id_t pid = AUTO_VAL_INIT(pid); bool valid = false; - if(currency::get_account_address_and_payment_id_from_str(apa, pid, addr)) + bool wrap = false; + while (true) { - valid = true; + if (currency::is_address_like_wrapped(addr)) + { + wrap = true; + valid = true; + break; + } + + if (currency::get_account_address_and_payment_id_from_str(apa, pid, addr)) + { + valid = true; + } + break; } + //lazy to make struct for it std::stringstream res; res << "{ \"valid\": " << (valid?"true":"false") << ", \"auditable\": " << (apa.is_auditable() ? "true" : "false") - << ",\"payment_id\": " << (pid.size() ? "true" : "false") << "}"; + << ",\"payment_id\": " << (pid.size() ? "true" : "false") + << ",\"wrap\": " << (wrap ? "true" : "false") + << "}"; return res.str(); } From 9447de6c963bdc6c08e68938ebb304823bb00482 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 25 Aug 2021 20:39:33 +0200 Subject: [PATCH 28/37] added proper handling of wrpa transactions in simplewallet --- src/common/general_purpose_commands_defs.h | 40 ++++++++++++ src/simplewallet/simplewallet.cpp | 74 +++++++++++++++++++--- src/simplewallet/simplewallet.h | 1 + 3 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 src/common/general_purpose_commands_defs.h diff --git a/src/common/general_purpose_commands_defs.h b/src/common/general_purpose_commands_defs.h new file mode 100644 index 00000000..f9da9968 --- /dev/null +++ b/src/common/general_purpose_commands_defs.h @@ -0,0 +1,40 @@ +// Copyright (c) 2014-2018 Zano Project +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once +#include "serialization/keyvalue_hexemizer.h" +#include "currency_core/currency_basic.h" +#include "storages/portable_storage_base.h" +#include "currency_core/basic_api_response_codes.h" +#include "common/error_codes.h" +namespace currency +{ + //----------------------------------------------- + + + struct tx_cost_struct + { + std::string usd_needed_for_erc20; + std::string zano_needed_for_erc20; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(usd_needed_for_erc20) + KV_SERIALIZE(zano_needed_for_erc20) + END_KV_SERIALIZE_MAP() + }; + + struct rpc_get_wrap_info_response + { + std::string unwraped_coins_left; + tx_cost_struct tx_cost; + + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(unwraped_coins_left) + KV_SERIALIZE(tx_cost) + END_KV_SERIALIZE_MAP() + }; + + +} + diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index c72242d3..5ca38d56 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -21,7 +21,7 @@ #include "version.h" #include "string_coding.h" #include "wallet/wrap_service.h" - +#include "common/general_purpose_commands_defs.h" #include #if defined(WIN32) @@ -1176,6 +1176,52 @@ bool simple_wallet::show_wallet_bcheight(const std::vector& args) return true; } //---------------------------------------------------------------------------------------------------- +bool simple_wallet::validate_wrap_status(uint64_t amount) +{ + //check if amount is fit erc20 fees and amount left in circulation + epee::net_utils::http::http_simple_client http_client; + + currency::void_struct req = AUTO_VAL_INIT(req); + currency::rpc_get_wrap_info_response res = AUTO_VAL_INIT(res); + bool r = epee::net_utils::invoke_http_json_remote_command2("http://wrapped.zano.org/api/get_wrap_info", req, res, http_client, 10000); + if (!r) + { + fail_msg_writer() << "Failed to request wrap status from server, check internet connection"; + return false; + } + //check if amount is bigger then erc20 fee + uint64_t zano_needed_for_wrap = std::stoll(res.tx_cost.zano_needed_for_erc20); + if (amount <= zano_needed_for_wrap) + { + fail_msg_writer() << "Too small amount to cover ERC20 fee. ERC20 cost is: " + << print_money(zano_needed_for_wrap) << " Zano" << + "($" << res.tx_cost.usd_needed_for_erc20 << ")"; + return false; + } + uint64_t unwrapped_coins_left = std::stoll(res.unwraped_coins_left); + if (amount > unwrapped_coins_left) + { + fail_msg_writer() << "Amount is bigger than ERC20 tokens left available: " + << print_money(unwrapped_coins_left) << " wZano"; + return false; + } + + success_msg_writer(false) << "You'll receive estimate " << print_money(amount - zano_needed_for_wrap) << " wZano (" << print_money(zano_needed_for_wrap)<< " Zano will be used to cover ERC20 fee)"; + success_msg_writer(false) << "Proceed? (yes/no)"; + while (true) + { + std::string user_response; + std::getline(std::cin, user_response); + if (user_response == "yes" || user_response == "y") + return true; + else if (user_response == "no" || user_response == "n") + return false; + else { + success_msg_writer(false) << "Wrong response, can be \"yes\" or \"no\""; + } + } +} +//---------------------------------------------------------------------------------------------------- bool simple_wallet::transfer(const std::vector &args_) { if (!try_connect_to_daemon()) @@ -1223,10 +1269,26 @@ bool simple_wallet::transfer(const std::vector &args_) std::string integrated_payment_id; currency::tx_destination_entry de; de.addr.resize(1); + + bool ok = currency::parse_amount(de.amount, local_args[i + 1]); + if (!ok || 0 == de.amount) + { + fail_msg_writer() << "amount is wrong: " << local_args[i] << ' ' << local_args[i + 1] << + ", expected number from 0 to " << print_money(std::numeric_limits::max()); + return true; + } + //check if address looks like wrapped address if (is_address_like_wrapped(local_args[i])) { - success_msg_writer(true) << "Address " << local_args[i] << " recognized as wrapped address, creating wrapping transaction..."; + + success_msg_writer(false) << "Address " << local_args[i] << " recognized as wrapped address, creating wrapping transaction."; + success_msg_writer(false) << "This transaction will create wZano (\"Wrapped Zano\") which will be sent to the specified address on the Ethereum network."; + + if (!validate_wrap_status(de.amount)) + { + return true; + } //put into service attachment specially encrypted entry which will contain wrap address and network tx_service_attachment sa = AUTO_VAL_INIT(sa); sa.service_id = BC_WRAP_SERVICE_ID; @@ -1252,14 +1314,6 @@ bool simple_wallet::transfer(const std::vector &args_) return true; } - bool ok = currency::parse_amount(de.amount, local_args[i + 1]); - if(!ok || 0 == de.amount) - { - fail_msg_writer() << "amount is wrong: " << local_args[i] << ' ' << local_args[i + 1] << - ", expected number from 0 to " << print_money(std::numeric_limits::max()); - return true; - } - if (integrated_payment_id.size() != 0) { if (payment_id.size() != 0) diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 156da7c8..35f99128 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -86,6 +86,7 @@ namespace currency bool sign_transfer(const std::vector &args); bool submit_transfer(const std::vector &args); bool sweep_below(const std::vector &args); + bool validate_wrap_status(uint64_t amount); bool get_alias_from_daemon(const std::string& alias_name, currency::extra_alias_entry_base& ai); bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr); From 8a0bbf785456503fe12649540cc793f8960935b2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 26 Aug 2021 15:03:42 +0200 Subject: [PATCH 29/37] Fixed bug with amount parsing --- src/wallet/wallets_manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 86856d90..ce29590e 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1359,7 +1359,9 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par { return API_RETURN_CODE_BAD_ARG_INVALID_ADDRESS; } - else if(!currency::parse_amount(dsts.back().amount, d.amount)) + + + if(!currency::parse_amount(dsts.back().amount, d.amount)) { return API_RETURN_CODE_BAD_ARG_WRONG_AMOUNT; } From d7d955c67e87d1d8d81f6a3ecdc4edaf5c5c2570 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Thu, 26 Aug 2021 16:04:42 +0300 Subject: [PATCH 30/37] === build number: 124 -> 125 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index cfee72bd..af5e45d6 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "1" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 124 +#define PROJECT_VERSION_BUILD_NO 125 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 48b4b78e6a094ddd60ecbec5446d71716e7313a2 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 27 Aug 2021 08:38:17 +0200 Subject: [PATCH 31/37] moved UI to wrap --- src/gui/qt-daemon/layout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index 0d3831a3..9614d4e5 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit 0d3831a3e4c13ab3016aca26d40d01f9e87c7282 +Subproject commit 9614d4e5f758d3d5ea305ea0c5417ede5863c306 From c44972102e9c560e61711b662a0857d67423a464 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Fri, 27 Aug 2021 09:40:20 +0300 Subject: [PATCH 32/37] === build number: 125 -> 126 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index af5e45d6..4034021d 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "1" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 125 +#define PROJECT_VERSION_BUILD_NO 126 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 1e0a58097ac20ed659c6cd825afa26ac168cfbad Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 27 Aug 2021 20:16:59 +0200 Subject: [PATCH 33/37] moved layout to latest commit with fixes --- src/gui/qt-daemon/layout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index 9614d4e5..62be79e2 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit 9614d4e5f758d3d5ea305ea0c5417ede5863c306 +Subproject commit 62be79e2acf4b39f30e88a32d1cd0438fb278c1d From 067d7ff1b2f1e52d7e26d374747ad17ec2c30f58 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Fri, 27 Aug 2021 21:17:44 +0300 Subject: [PATCH 34/37] === build number: 126 -> 127 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index 4034021d..b7c74bc7 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "1" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 126 +#define PROJECT_VERSION_BUILD_NO 127 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From cc985ca710b03920fc90fe0f7d1787246945a0fa Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 28 Aug 2021 10:39:26 +0200 Subject: [PATCH 35/37] moved layout to latest commit with fixes: forgotten html --- src/gui/qt-daemon/layout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/layout b/src/gui/qt-daemon/layout index 62be79e2..fd506b56 160000 --- a/src/gui/qt-daemon/layout +++ b/src/gui/qt-daemon/layout @@ -1 +1 @@ -Subproject commit 62be79e2acf4b39f30e88a32d1cd0438fb278c1d +Subproject commit fd506b5669624c8deeab901347228c400d9dc89d From 49c05b7158f2a78a1c2c573c6f60b21c1429a8a8 Mon Sep 17 00:00:00 2001 From: zano build machine Date: Sat, 28 Aug 2021 11:42:01 +0300 Subject: [PATCH 36/37] === build number: 127 -> 128 === --- src/version.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h.in b/src/version.h.in index b7c74bc7..0b5627f2 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -8,6 +8,6 @@ #define PROJECT_REVISION "1" #define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION -#define PROJECT_VERSION_BUILD_NO 127 +#define PROJECT_VERSION_BUILD_NO 128 #define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO) #define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]" From 9202483ee1d0304b4d6ef865488c35b66a9da62d Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Thu, 2 Sep 2021 20:09:35 +0300 Subject: [PATCH 37/37] switched to production custody wallet --- src/wallet/wrap_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wrap_service.h b/src/wallet/wrap_service.h index 0ca52d15..cefbfe6f 100644 --- a/src/wallet/wrap_service.h +++ b/src/wallet/wrap_service.h @@ -10,4 +10,4 @@ #define BC_WRAP_SERVICE_INSTRUCTION_UNWRAP "UNWRAP" //erc20 unwrap operation -#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxaszi4TaDCUqRCmqe23HASryshQNHmBSFnUN1pY8VsRfss2ZSMGBpLhdFtHgKmFr353NneaYRT6CpSz7zA3EC9bocQcq7m9nP" \ No newline at end of file +#define BC_WRAP_SERVICE_CUSTODY_WALLET "aZxb34VSFPwPJMHReeD4FEhrkUtCgZPQ3aXpMkgFuw6sdSWtph298W55Tn68pkRVFKEx2Kq7rKxyuSqntY8BDrRm8fxyMzVjyYj" \ No newline at end of file