1
0
Fork 0
forked from lthn/blockchain

Merge branch 'master' into develop

This commit is contained in:
crypro.zoidberg 2019-05-08 19:49:34 +02:00
commit 40921f7c69
46 changed files with 437 additions and 228 deletions

View file

@ -400,6 +400,7 @@ bool generate_genesis(const std::string& path_config, uint64_t premine_split_amo
ss.str("");
ss.clear();
std::cout << ENDL << "PROOF PHRASE: " << gcp.proof_string << ENDL;
construct_miner_tx(0, 0, 0, 0, 0, destinations, bl.miner_tx, gcp.proof_string, CURRENCY_MINER_TX_MAX_OUTS);
currency::blobdata txb = tx_to_blob(bl.miner_tx);

View file

@ -304,7 +304,7 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
<< "last block: " << m_db_blocks.size() - 1 << ", " << misc_utils::get_time_interval_string(timestamp_diff) << " time ago" << ENDL
<< "current pos difficulty: " << get_next_diff_conditional(true) << ENDL
<< "current pow difficulty: " << get_next_diff_conditional(false) << ENDL
<< "total tansactions: " << m_db_transactions.size(),
<< "total transactions: " << m_db_transactions.size(),
LOG_LEVEL_0);

View file

@ -7,8 +7,9 @@
#pragma once
#define CURRENCY_FORMATION_VERSION 81
#define CURRENCY_FORMATION_VERSION 84
#define CURRENCY_GENESIS_NONCE (CURRENCY_FORMATION_VERSION + some_number_here)// <-- will be changed to another nightmare*/; //bender's nightmare
#define CURRENCY_MAX_BLOCK_NUMBER 500000000
#define CURRENCY_MAX_BLOCK_SIZE 500000000 // block header blob limit, never used!
@ -53,7 +54,7 @@
// #define CURRENCY_FIXED_REWARD_ZONE_REWARD_AMOUNT ((uint64_t)100000000) // should be TX_MINIMUM_FEE * CURRENCY_FIXED_REWARD_ZONE_FEE_MULTIPLIER
// #define CURRENCY_FIXED_REWARD_ZONE_FEE_MULTIPLIER 1000 // reward in minimum fees for a block in the zone
#define CURRENCY_BLOCK_REWARD 1000000000000 // 1.0 coin
#define CURRENCY_BLOCK_REWARD 1000000000000 // 1.0 coin
#define WALLET_MAX_ALLOWED_OUTPUT_AMOUNT ((uint64_t)0xffffffffffffffffLL)
@ -99,12 +100,12 @@
#define CURRENCY_MEMPOOL_TX_LIVETIME 345600 //seconds, 4 days
#ifndef TESTNET
#define P2P_DEFAULT_PORT (CURRENCY_FORMATION_VERSION+11121)
#define P2P_DEFAULT_PORT ---
#define RPC_DEFAULT_PORT 11211
#define STRATUM_DEFAULT_PORT 11777
#define P2P_NETWORK_ID_TESTNET_FLAG 0
#else
#define P2P_DEFAULT_PORT (CURRENCY_FORMATION_VERSION+11112)
#define P2P_DEFAULT_PORT (11112)
#define RPC_DEFAULT_PORT 12111
#define STRATUM_DEFAULT_PORT 11888
#define STRARUM_DEFAULT_PORT 51113
@ -126,7 +127,7 @@
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
#define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
#define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 10000 //10 seconds
#define P2P_MAINTAINERS_PUB_KEY "888db12b7e0cd325880c815ea13d7062f4c4a89dafc355f4d7b93a7f18342df3"
#define P2P_MAINTAINERS_PUB_KEY "8f138bb73f6d663a3746a542770781a09579a7b84cb4125249e95530824ee607"
#define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
#define P2P_FAILED_ADDR_FORGET_SECONDS (60*5) //5 minutes
@ -162,7 +163,7 @@
#define CURRENCY_NAME_ABR "ZAN"
#define CURRENCY_NAME_ABR "ZANO"
#define CURRENCY_NAME_BASE "Zano"
#define CURRENCY_NAME_SHORT_BASE "Zano"
#ifndef TESTNET
@ -182,7 +183,7 @@
#define ALIAS_REWARDS_ACCOUNT_VIEW_SEC_KEY "0000000000000000000000000000000000000000000000000000000000000000" //burn alias money
#define ALIAS_MINIMUM_PUBLIC_SHORT_NAME_ALLOWED 6
#define ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY "3b63cb2f3d425053f4120b10bced73d87e98c27b6e4bcfd123a5cfac688c551f"
#define ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY "37947f7b6a5268c5d0a48bde73d7a426f0b5f24648f74024279540207dc70031"
#define ALIAS_NAME_MAX_LEN 255
@ -212,7 +213,7 @@
#define BC_OFFERS_CURRENCY_MARKET_FILENAME "market.bin"
#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+63)
#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+64)
#define CURRENT_MEMPOOL_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+31)
@ -221,4 +222,4 @@
static_assert(CURRENCY_MINER_TX_MAX_OUTS <= CURRENCY_TX_MAX_ALLOWED_OUTS, "Miner tx must obey normal tx max outs limit");
static_assert(PREMINE_AMOUNT / WALLET_MAX_ALLOWED_OUTPUT_AMOUNT < CURRENCY_MINER_TX_MAX_OUTS, "Premine can't be divided into reasonable number of outs");
//static_assert(CURRENCY_FIXED_REWARD_ZONE_REWARD_AMOUNT == TX_MINIMUM_FEE * CURRENCY_FIXED_REWARD_ZONE_FEE_MULTIPLIER, "CURRENCY_FIXED_REWARD_ZONE_REWARD_AMOUNT is incorrect with regard to TX_MINIMUM_FEE");

View file

@ -1865,6 +1865,11 @@ namespace currency
std::string genesis_coinbase_tx_hex = "";
#endif
//genesis proof phrase: "Liverpool beat Barcelona: Greatest Champions League comebacks of all time"
//taken from: https://www.bbc.com/sport/football/48163330
//sha3-256 from proof phrase: a074236b1354901d5dbc029c0ac4c05c948182c34f3030f32b0c93aee7ba275c (included in genesis block)
blobdata tx_bl((const char*)&ggenesis_tx_raw, sizeof(ggenesis_tx_raw));
//string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
@ -1872,12 +1877,10 @@ namespace currency
bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
bl.timestamp = 0;
bl.nonce = 101010121 + CURRENCY_FORMATION_VERSION; //bender's nightmare
//miner::find_nonce_for_given_block(bl, 1, 0,);
bl.nonce = CURRENCY_GENESIS_NONCE;
LOG_PRINT_GREEN("Generated genesis: " << get_block_hash(bl), LOG_LEVEL_0);
return true;
}
//---------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
const crypto::hash& get_genesis_hash(bool need_to_set, const crypto::hash& h)
{

View file

@ -8,7 +8,8 @@
namespace currency
{
const genesis_tx_raw_data ggenesis_tx_raw = { {
0xa080801700000101,0xf30326b0b4a0f2fd,0x46fe96860beb01ea,0x01323293f642c7c6,0x80e8a7730e20c142,0x00cb08b2016bbccc,0xb0b4a0f2fda08080,0xb67d52cae50e0326,0x71bb6e75bf256319,0x76dd703cec5e8f40,0xfca18c41540510b9,0xf2fda080800070f3,0xeea9320326b0b4a0,0xb5d90ea5fe49c4cb,0x3f1e5ca079fe6ebb,0x2f73ac1012e243d0,0x808000887086f29b,0x0326b0b4a0f2fda0,0x44f1a1dfe16379f9,0x50d93954cca94108,0x9ac47bb379e6f074,0xb44bdb69a986211e,0xb4f89aecdce08000,0x88b82d0dc60326b0,0x4e995861a27c03ae,0xdf48c9c97c449f1d,0xdd2ea49c4ecdcbdf,0x93dc80800046f5dc,0xedff0307d0ffc2e0,0x4a8442409d3719b1,0x2e385d03544c8122,0x0c592cfad6e8e900,0x8000ed0b32aa07c6,0x05c6c5bc97b1a080,0xa5d7620e38d8ef03,0x1c68e9cfd35cc1e5,0xbdba8ea5fb49f375,0x7fb77cff80f31c9e,0xbc97b1a080800040,0xd15b16b60305c6c5,0x7af40193ad86f123,0x5ba33fd12279af67,0x0db572d11ea1ad96,0xa080800024fc1fde,0x460305c6c5bc97b1,0x444d02aa28a539b9,0x9846386a58c71f35,0x27fd9af12bd3710a,0x0004b2acf589ce8d,0xc6c5bc97b1a08080,0x610c62c125e80305,0x44217ee86d4ed16f,0x5f27600912875c5f,0x51f2fbfd2b30ff54,0x97b1a08080002698,0x8180fc0305c6c5bc,0xaeb4bfd37d282432,0x10a11a1c799b6165,0x9c69b9b6aac75596,0x8080009c5a6d5e15,0x0305c6c5bc97b1a0,0xbf9f36e03f56393a,0x0a74acb0775f0e02,0x97665a42cb477844,0xff01a0c03c43df12,0xc5bc97b1a0808000,0xd5066341560305c6,0x5aa8c1962a148222,0xf83737ab96d43653,0x4b5007cf8fd4a1e2,0xd2dc808000565d84,0xa6a8030398c7f980,0x32c08d3989aa7f91,0xe4b5de74db34eb45,0xf2bd313bdefdfcba,0x80007e3bb1b21fd2,0x018e8df2b7f0a080,0xb2fe8efdeb17a903,0xe7f89d45d4b05be9,0x96f5300e672fd804,0xbd82737c2ce8c3cf,0xef93bf82808000c2,0x816c799a1f0308f0,0x98bd1487b0e05122,0x044d8ffd583693ba,0x1c954a13f5425015,0xfe848080007c6407,0xcde2510311e1dea6,0x3c62da3d50c8a8ee,0xa3acc1ed75d470b1,0xa479c78eecc2f96c,0x8080005f7388cbcb,0xbd0308f0ef93bf82,0xb5a5cca060105de4,0x92cf66a16d3b4d6b,0x5ca92a654f5a8400,0x00df465ad6e8d895,0x08f0ef93bf828080,0x2ce3338452319303,0xecc7b1c056651998,0xc3696cf2fb2fe9b9,0x69b4edf21f2bdaae,0xafeaa69a808000b8,0x1052e2e6de0301e3,0xa06855ba0d7eaab2,0x344998a33e968f15,0xa8a00006653f7005,0xa69a808000a95440,0x58e0580301e3afea,0xc0524c1a0a1d4b5f,0xad37550b686c838b,0x0eb1ef4a20771a79,0x80800080516862ab,0xa30301e3afeaa69a,0xda2b32dbac7f88cc,0x965536648651d1a2,0xbbe22f6bdc320069,0x00a8ea3fddccf16d,0x03c6dfd4ccb48080,0x9921a91a97490603,0x57ceadcb0611b6de,0xa53cee6b71e61ecb,0x0e56262c5e13302f,0x04ee9ff0161a000a,0xa43f85172baeb3d9,0x782309f5ee0a02f0,0x5d187fedafdfae4f,0x971700150f26e04b,0x17482917b0a717cb,0x1fe617c89e1725b4,0x4017c6e317a97217,0x17a7ca178e6117c1,0xd24717fd3917aa53,0xd217b83c178b9b17,0x17d92517d51c17d4,0xda9d17154f17f6fc },
{ 0x17,0x41,0x0a,0x0e,0x0a,0x00,0x00 } };
0xa080801a00000101,0x800326b0b4a0f2fd,0xeebe5a6d44a03ed5,0x0e146a5322076dcf,0x992269ec1e34796e,0x003b14d1fe6c757e,0xb0b4a0f2fda08080,0xfd92adf982e70326,0xd8d4b6458b60e1a4,0xa69adb9475e808ed,0x4c383fcedfb6e20a,0xf2fda08080003458,0x8b177f0326b0b4a0,0xef9769ed70d152cd,0x04097d0daa65d123,0x9cd9f8e708f25bbc,0x8080005dfb23beac,0x0326b0b4a0f2fda0,0x6752077f8e75fc8a,0x437f68e0bf774836,0x5a38b52ff21c01c0,0x2d3727ec82ce1425,0xb4f89aecdce08000,0xa07d9fe35f0326b0,0x6c742533eb3b4261,0xfc2ed631332e5e16,0x3d025449393e538b,0x93dc80800015e433,0x70a20307d0ffc2e0,0xb81808dc5029bd46,0x04129413283e31f1,0x143e631cc81020b0,0x80008519d1377ae3,0x05c6c5bc97b1a080,0xf71887a841a72a03,0x681b659b8d2832d4,0x5677f9b15d11d1e6,0xffb2ad80c02a341c,0xbc97b1a08080003f,0xf9cebe7c0305c6c5,0xee223954dc682820,0x8194d2bac0dff6d6,0x86d8a55a30e30183,0xa08080006775f5f0,0x220305c6c5bc97b1,0x3c36e1ebdcee584a,0x4e9ed1a89532ef46,0xf0cb8b411bf6d579,0x00d0e6392ada64d4,0xc6c5bc97b1a08080,0x2fc2b05779450305,0xc9cf47618cc5283e,0xa9e088224807a77e,0xda854e29d2f49646,0x97b1a08080002e74,0xed35180305c6c5bc,0xa78d5545117b8293,0x5c3f8babc16e7062,0xef9324ecd7f86e39,0x808000231900ee9c,0x0305c6c5bc97b1a0,0x0c5bfd9450e89e30,0x194b86e8316970bc,0x5dd8c2e3c2af6ff1,0x4d2ba46f683df89c,0xc5bc97b1a0808000,0xc7cc22ad390305c6,0x891b500cb0799642,0xf5884473a7c01f07,0xeb88d74972d8e36f,0x91ed808000b5d239,0x535a0302fddecd95,0x791c7275cd15d685,0xc2536511d4132e01,0x0c9ad1ee9196aa77,0x80002d55a4efc7d3,0x018e8df2b7f0a080,0x0848b53f974a6a03,0x96b2572cb6015b7d,0xa71b18d2755de52c,0x075e4ca4bd0e4487,0xef93bf82808000ca,0xe23077bc730308f0,0x266a622b7bd9de26,0x4b80410b36c32203,0xb3026d0a2610916c,0xfe8480800084746d,0x6f34b90311e1dea6,0xeb38aee70a8febba,0x8b45df519f0df12e,0x258f0a71e83385da,0x8080000b85701a76,0xdf0308f0ef93bf82,0xb3170ab580f881a3,0x07f0a33f0756a3f4,0xf0721645b2b2bd7b,0x00b0077e03f43a85,0x08f0ef93bf828080,0xf91c1f6308c00f03,0x901a68f4adcc918b,0xad0346f5b7869662,0xd3ed49961fccd915,0xafeaa69a808000f0,0x2c99a01fe90301e3,0xd28642bcae6728d9,0xa6f38c4c630c2b6c,0x2c8a361de6b9294f,0xa69a8080002191e8,0xe134670301e3afea,0x6cf0798aeae985c8,0x4c9b90e1ff211b81,0xc32a954ce05a738b,0x8080009fd2412c6f,0x790301e3afeaa69a,0xb3b0062d6c27a6bb,0x12e133832172b705,0xf3f7d1dfdf336fb8,0x00922d0a879c6027,0x03c6dfd4ccb48080,0x7aa13f278feecf03,0x464f78f86a3e4553,0xa5a464e65c4cf651,0x18f07e7ed8bdd351,0xef93bf82808000dd,0x70b4e3ebae0308f0,0x74c452ecdce312d9,0xca3fb591982461fc,0x3e01aaf9b53ede69,0xfe84808000a4fa65,0x20e5ba0311e1dea6,0xb3e07ec0aabd06a5,0x7bf14a03bf83ccfd,0x6024154f95fd3220,0x808000c13077fa8b,0x5c580316deb183e9,0xc2c948248ab422c3,0xebd3db36bad27d52,0x5fe30392c1525a4e,0x1e00952287d66a6d,0x163df474d5ba8816,0x86f8892015449a71,0x22c93333d9ecb472,0x64fa5516bddfebb3,0x3234373061401303,0x3934353331623633,0x3063626435643130,0x6334636130633932,0x3831383439633530,0x3330336634336332,0x3963306232336630,0x3261623765656133,0x80c9170015633537,0x4c17fba117829117,0x17624a17d2f21711,0xfec81731f9178ced,0x9c17624117a36017,0x1786df17edda1708,0x9ffa17d6e1171b42,0x8b17aa69177ff417,0x179815170a83170c,0xc7e8171ce317da27 },
{ 0x17,0x86,0xd6,0x0e,0x0a,0x00,0x00 } };
}

View file

@ -8,11 +8,10 @@
#include <string>
namespace currency
{
#pragma pack(push, 1)
#pragma pack(push, 1)
struct genesis_tx_raw_data
{
uint64_t const v[136];
uint64_t const v[161];
uint8_t const r[7];
};
#pragma pack(pop)

View file

@ -9,10 +9,9 @@
namespace currency
{
const std::string ggenesis_tx_pub_key_str = "f09fee04d9b3ae2b17853fa4f0020aeef50923784faedfafed7f185d4be0260f";
const std::string ggenesis_tx_pub_key_str = "88bad574f43d16719a44152089f88672b4ecd93333c922b3ebdfbd1655fa6403";
const crypto::public_key ggenesis_tx_pub_key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>(ggenesis_tx_pub_key_str);
const genesis_tx_dictionary_entry ggenesis_dict[23] = {
const genesis_tx_dictionary_entry ggenesis_dict[26] = {
{ 898363347618325980ULL,7 },
{ 1234271292339965434ULL,1 },
{ 2785329203593578547ULL,12 },
@ -20,7 +19,7 @@ namespace currency
{ 3515932779881697835ULL,17 },
{ 4955366495399988463ULL,11 },
{ 5233257582118330150ULL,5 },
{ 5511617689742669301ULL,22 },
{ 5931539148443336682ULL,24 },
{ 6436517662239927298ULL,19 },
{ 6604452700210763953ULL,13 },
{ 7200550178847042641ULL,15 },
@ -30,13 +29,17 @@ namespace currency
{ 9527474759752332295ULL,2 },
{ 9647541513390373765ULL,20 },
{ 9921730437908704447ULL,8 },
{ 10751885755236960099ULL,25 },
{ 11032572278436047420ULL,22 },
{ 11109691972771859220ULL,0 },
{ 13554174209305230569ULL,23 },
{ 14297297752337562678ULL,3 },
{ 15636081871140663679ULL,21 },
{ 15951161519112687845ULL,6 },
{ 17146058209502212345ULL,14 },
{ 17472133472787764818ULL,10 }
};
}

View file

@ -24,7 +24,7 @@ namespace currency
}
};
#pragma pack(pop)
extern const genesis_tx_dictionary_entry ggenesis_dict[23];
extern const genesis_tx_dictionary_entry ggenesis_dict[26];
extern const crypto::public_key ggenesis_tx_pub_key;

View file

@ -146,7 +146,8 @@
"PASS_NOT_MATCH": "Old password not match.",
"CONFIRM_NOT_MATCH": "Confirm password not match."
},
"LAST_BUILD": "Current build: {{value}}"
"LAST_BUILD": "Current build: {{value}}",
"APP_LOG_TITLE": "Log level:"
},
"WALLET": {
"REGISTER_ALIAS": "Register an alias",
@ -249,6 +250,7 @@
"DETAILS": "Additional details",
"MIXIN": "Mixin",
"FEE": "Fee",
"HIDE": "Hide your wallet address from receiver",
"BUTTON": "Send",
"SUCCESS_SENT": "Transaction sent",
"FORM_ERRORS": {
@ -511,7 +513,7 @@
"MINED": "Mined",
"LOCKED": "Blocked",
"IS_MINIMIZE": "Zano application is minimized to the system tray",
"RESTORE": "You can recover it by double-clicking or using the context menu",
"RESTORE": "You can recover it by clicking or using the context menu",
"TRAY_MENU_SHOW": "Resize",
"TRAY_MENU_MINIMIZE": "Minimize"
}

View file

@ -1,7 +1,7 @@
$themes: (
dark: (
bodyBackgroundColor: #131921,
sidebarBackgroundColor: rgba(23, 31, 39, 0.5),
sidebarBackgroundColor: rgba(23, 31, 39, 1),
sidebarBorderColor: #1f2833,
onlineColor: #5cda9d,
offlineColor: #ff5252,
@ -52,7 +52,7 @@ $themes: (
),
gray: (
bodyBackgroundColor: #101417,
sidebarBackgroundColor: rgba(28, 30, 33, 0.5),
sidebarBackgroundColor: rgba(28, 30, 33, 1),
sidebarBorderColor: #2e3337,
onlineColor: #47cf8d,
offlineColor: #ff5252,
@ -103,7 +103,7 @@ $themes: (
),
white: (
bodyBackgroundColor: #eeeeee,
sidebarBackgroundColor: rgba(255, 255, 255, 0.5),
sidebarBackgroundColor: rgba(255, 255, 255, 1),
sidebarBorderColor: #ebebeb,
onlineColor: #46c172,
offlineColor: #ff5252,

View file

@ -67,7 +67,7 @@ app-sidebar {
.fill {
@include themify($themes) {
background-color: themed(progressBarFullBackgroundColor);
background-color: themed(blueTextColor);
}
}
}
@ -130,6 +130,13 @@ app-sidebar {
}
}
}
&:after {
@include themify($themes) {
background: linear-gradient(to bottom, transparent 0%, themed(sidebarBackgroundColor) 100%);
}
}
}
.sidebar-settings {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -387,7 +387,7 @@ export class BackendService {
this.runCommand('restore_wallet', params, callback);
}
sendMoney(from_wallet_id, to_address, amount, fee, mixin, comment, callback) {
sendMoney(from_wallet_id, to_address, amount, fee, mixin, comment, hide, callback) {
const params = {
wallet_id: parseInt(from_wallet_id, 10),
destinations: [
@ -400,7 +400,7 @@ export class BackendService {
lock_time: 0,
fee: this.moneyToIntPipe.transform(fee),
comment: comment,
push_payer: true
push_payer: !hide
};
this.runCommand('transfer', params, callback);
}
@ -604,6 +604,10 @@ export class BackendService {
});
}
setLogLevel(level) {
return this.runCommand('set_log_level', {v: level});
}
}
@ -629,10 +633,6 @@ export class BackendService {
});
},
setLogLevel: function (level) {
return this.runCommand('set_log_level', asVal(level))
},
resetWalletPass: function (wallet_id, pass, callback) {
this.runCommand('reset_wallet_password', {wallet_id: wallet_id, pass: pass}, callback);
},

View file

@ -16,12 +16,12 @@ export class VariablesService {
public appLogin = false;
public moneyEquivalent = 0;
public defaultTheme = 'dark';
public defaultCurrency = 'ZAN';
public defaultCurrency = 'ZANO';
public opening_wallet: Wallet;
public exp_med_ts = 0;
public height_app = 0;
public last_build_available = '';
public daemon_state = 0;
public daemon_state = 3;
public sync = {
progress_value: 0,
progress_value_text: '0'
@ -31,6 +31,7 @@ export class VariablesService {
public settings = {
appLockTime: 15,
appLog: 0,
theme: '',
scale: 10,
language: 'en',

View file

@ -20,6 +20,7 @@ export class AppComponent implements OnInit, OnDestroy {
expMedTsEvent;
onQuitRequest = false;
firstOnlineState = false;
translateUsed = false;
needOpenWallets = [];
@ -32,7 +33,7 @@ export class AppComponent implements OnInit, OnDestroy {
public translate: TranslateService,
private backend: BackendService,
private router: Router,
private variablesService: VariablesService,
public variablesService: VariablesService,
private ngZone: NgZone,
private intToMoneyPipe: IntToMoneyPipe,
private modalService: ModalService
@ -41,23 +42,33 @@ export class AppComponent implements OnInit, OnDestroy {
translate.setDefaultLang('en');
// const browserLang = translate.getBrowserLang();
// translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
translate.use('en').subscribe(() => {
this.translateUsed = true;
});
}
setBackendLocalization() {
const stringsArray = [
this.translate.instant('BACKEND_LOCALIZATION.QUIT'),
this.translate.instant('BACKEND_LOCALIZATION.IS_RECEIVED'),
this.translate.instant('BACKEND_LOCALIZATION.IS_CONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.INCOME_TRANSFER_UNCONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.INCOME_TRANSFER_CONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.MINED'),
this.translate.instant('BACKEND_LOCALIZATION.LOCKED'),
this.translate.instant('BACKEND_LOCALIZATION.IS_MINIMIZE'),
this.translate.instant('BACKEND_LOCALIZATION.RESTORE'),
this.translate.instant('BACKEND_LOCALIZATION.TRAY_MENU_SHOW'),
this.translate.instant('BACKEND_LOCALIZATION.TRAY_MENU_MINIMIZE')
];
this.backend.setBackendLocalization(stringsArray, 'en');
if (this.translateUsed) {
const stringsArray = [
this.translate.instant('BACKEND_LOCALIZATION.QUIT'),
this.translate.instant('BACKEND_LOCALIZATION.IS_RECEIVED'),
this.translate.instant('BACKEND_LOCALIZATION.IS_CONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.INCOME_TRANSFER_UNCONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.INCOME_TRANSFER_CONFIRMED'),
this.translate.instant('BACKEND_LOCALIZATION.MINED'),
this.translate.instant('BACKEND_LOCALIZATION.LOCKED'),
this.translate.instant('BACKEND_LOCALIZATION.IS_MINIMIZE'),
this.translate.instant('BACKEND_LOCALIZATION.RESTORE'),
this.translate.instant('BACKEND_LOCALIZATION.TRAY_MENU_SHOW'),
this.translate.instant('BACKEND_LOCALIZATION.TRAY_MENU_MINIMIZE')
];
this.backend.setBackendLocalization(stringsArray, 'en');
} else {
console.warn('wait translate use');
setTimeout(() => {
this.setBackendLocalization();
}, 10000);
}
}
ngOnInit() {
@ -141,7 +152,7 @@ export class AppComponent implements OnInit, OnDestroy {
const wallet = this.variablesService.getWallet(data.wallet_id);
if (wallet) {
this.ngZone.run(() => {
wallet.progress = data.progress;
wallet.progress = (data.progress < 0) ? 0 : ((data.progress > 100) ? 100 : data.progress);
if (wallet.progress === 0) {
wallet.loaded = false;
} else if (wallet.progress === 100) {
@ -506,6 +517,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.setBackendLocalization();
this.backend.setLogLevel(this.variablesService.settings.appLog);
if (this.router.url !== '/login') {
this.backend.haveSecureAppData((statusPass) => {
if (statusPass) {

View file

@ -14,7 +14,7 @@
<form class="form-assign" [formGroup]="assignForm">
<div class="input-block alias-name">
<label for="alias-name" tooltip="{{ 'ASSIGN_ALIAS.NAME.TOOLTIP' | translate }}" placement="bottom-left" tooltipClass="table-tooltip assign-alias-tooltip" [delay]="500">
<label for="alias-name" tooltip="{{ 'ASSIGN_ALIAS.NAME.TOOLTIP' | translate }}" placement="bottom-left" tooltipClass="table-tooltip assign-alias-tooltip" [delay]="50">
{{ 'ASSIGN_ALIAS.NAME.LABEL' | translate }}
</label>
<input type="text" id="alias-name" formControlName="name" placeholder="{{ 'ASSIGN_ALIAS.NAME.PLACEHOLDER' | translate }}" (contextmenu)="variablesService.onContextMenu($event)">
@ -42,7 +42,7 @@
</div>
<div class="input-block textarea">
<label for="alias-comment" tooltip="{{ 'ASSIGN_ALIAS.COMMENT.TOOLTIP' | translate }}" placement="bottom-left" tooltipClass="table-tooltip assign-alias-tooltip" [delay]="500">
<label for="alias-comment" tooltip="{{ 'ASSIGN_ALIAS.COMMENT.TOOLTIP' | translate }}" placement="bottom-left" tooltipClass="table-tooltip assign-alias-tooltip" [delay]="50">
{{ 'ASSIGN_ALIAS.COMMENT.LABEL' | translate }}
</label>
<textarea id="alias-comment"

View file

@ -32,6 +32,12 @@ export class ContractsComponent implements OnInit, OnDestroy {
if (a.timestamp > b.timestamp) {
return -1;
}
if (a.contract_id < b.contract_id) {
return 1;
}
if (a.contract_id > b.contract_id) {
return -1;
}
return 0;
});
}

View file

@ -1,5 +1,5 @@
import {Component, NgZone, OnInit, OnDestroy} from '@angular/core';
import {FormGroup, FormControl, Validators} from '@angular/forms';
import {FormGroup, FormControl} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router';
import {BackendService} from '../_helpers/services/backend.service';
import {VariablesService} from '../_helpers/services/variables.service';

View file

@ -1,5 +1,5 @@
import {Component, NgZone, OnInit} from '@angular/core';
import {Location} from "@angular/common";
import {Location} from '@angular/common';
import {BackendService} from '../_helpers/services/backend.service';
import {VariablesService} from '../_helpers/services/variables.service';
import {Router} from '@angular/router';
@ -19,9 +19,11 @@ export class MainComponent implements OnInit {
private variablesService: VariablesService,
private ngZone: NgZone,
private translate: TranslateService
) {}
) {
}
ngOnInit() {}
ngOnInit() {
}
openWallet() {
this.backend.openFileDialog(this.translate.instant('MAIN.CHOOSE_PATH'), '*', this.variablesService.settings.default_path, (file_status, file_data) => {
@ -37,11 +39,11 @@ export class MainComponent implements OnInit {
}
openInBrowser() {
this.backend.openUrlInBrowser('docs.zano.org/v1.0/docs/how-to-create-wallet');
this.backend.openUrlInBrowser('docs.zano.org/docs/getting-started-1#section-create-new-wallet');
}
back() {
this.location.back()
this.location.back();
}
}

View file

@ -79,7 +79,7 @@ export class OpenWalletComponent implements OnInit, OnDestroy {
if (exists) {
this.modalService.prepareModal('error', 'OPEN_WALLET.WITH_ADDRESS_ALREADY_OPEN');
this.backend.closeWallet(open_data.wallet_id, (close_status, close_data) => {
this.backend.closeWallet(open_data.wallet_id, () => {
this.ngZone.run(() => {
this.router.navigate(['/']);
});

View file

@ -247,9 +247,8 @@
</div>
<div class="time-cancel-block-row" *ngIf="showTimeSelect && !newPurchase && currentContract.is_a && (currentContract.state == 201 || currentContract.state == 2 || currentContract.state == 120 || currentContract.state == 130)">
<div>{{ 'PURCHASE.WAITING_TIME_QUESTION' | translate }}</div>
<div class="time-cancel-block-question">{{ 'PURCHASE.WAITING_TIME_QUESTION' | translate }}</div>
<div class="input-block">
<label for="purchase-timeCancel">{{ 'PURCHASE.WAITING_TIME' | translate }}</label>
<ng-select id="purchase-timeCancel" class="lock-selection-select"
[clearable]="false"
[searchable]="false"
@ -260,6 +259,7 @@
</ng-option>
</ng-select>
</div>
<label for="purchase-timeCancel">{{ 'PURCHASE.WAITING_TIME' | translate }}</label>
<div class="time-cancel-block-buttons">
<button type="button" class="blue-button" (click)="showTimeSelect = false;">{{ 'PURCHASE.CANCEL' | translate }}</button>
<button type="button" class="blue-button" (click)="dealsDetailsCancel();">{{ 'PURCHASE.BUTTON_CANCEL_BUYER' | translate }}</button>

View file

@ -136,10 +136,18 @@
align-items: center;
justify-content: center;
.time-cancel-block-question {
margin-bottom: 1rem;
}
.input-block {
width: 25%;
}
label {
margin-bottom: 1rem;
}
.time-cancel-block-buttons {
display: flex;
align-items: center;

View file

@ -6,7 +6,6 @@ import {VariablesService} from '../_helpers/services/variables.service';
import {ModalService} from '../_helpers/services/modal.service';
import {Location} from '@angular/common';
import {IntToMoneyPipe} from '../_helpers/pipes/int-to-money.pipe';
import {TranslateService} from '@ngx-translate/core';
import {BigNumber} from 'bignumber.js';
@Component({
@ -60,9 +59,12 @@ export class PurchaseComponent implements OnInit, OnDestroy {
if (!(/^@?[a-z0-9\.\-]{6,25}$/.test(g.value))) {
g.setErrors(Object.assign({'alias_not_valid': true}, g.errors));
} else {
this.backend.getAliasByName(g.value.replace('@', ''), (alias_status) => {
this.backend.getAliasByName(g.value.replace('@', ''), (alias_status, alias_data) => {
this.ngZone.run(() => {
if (alias_status) {
if (alias_data.address === this.variablesService.currentWallet.address) {
g.setErrors(Object.assign({'address_same': true}, g.errors));
}
if (g.hasError('alias_not_valid')) {
delete g.errors['alias_not_valid'];
if (Object.keys(g.errors).length === 0) {
@ -107,7 +109,8 @@ export class PurchaseComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
private location: Location,
private intToMoneyPipe: IntToMoneyPipe
) {}
) {
}
checkAndChangeHistory() {
if (this.currentContract.state === 201) {
@ -166,7 +169,6 @@ export class PurchaseComponent implements OnInit, OnDestroy {
if (this.currentContract.state === 130 && this.currentContract.cancel_expiration_time !== 0 && this.currentContract.cancel_expiration_time < this.variablesService.exp_med_ts) {
this.currentContract.state = 2;
}
this.variablesService.settings.viewedContracts = (this.variablesService.settings.viewedContracts) ? this.variablesService.settings.viewedContracts : [];
let findViewedCont = false;
for (let j = 0; j < this.variablesService.settings.viewedContracts.length; j++) {
@ -184,13 +186,11 @@ export class PurchaseComponent implements OnInit, OnDestroy {
});
}
this.currentContract.is_new = false;
setTimeout(() => {
this.variablesService.currentWallet.recountNewContracts();
}, 0);
}
this.checkAndChangeHistory();
} else {
this.newPurchase = true;
}
@ -205,7 +205,6 @@ export class PurchaseComponent implements OnInit, OnDestroy {
this.currentContract.is_new = true;
this.variablesService.currentWallet.recountNewContracts();
}
});
}
@ -381,7 +380,6 @@ export class PurchaseComponent implements OnInit, OnDestroy {
this.currentContract.is_new = true;
this.currentContract.state = 130;
this.currentContract.time = this.currentContract.cancel_expiration_time;
this.variablesService.currentWallet.recountNewContracts();
this.modalService.prepareModal('info', 'PURCHASE.IGNORED_CANCEL');
this.back();

View file

@ -76,6 +76,11 @@
</div>
</div>
<div class="checkbox-block">
<input type="checkbox" id="send-hide" class="style-checkbox" formControlName="hide">
<label for="send-hide">{{ 'SEND.HIDE' | translate }}</label>
</div>
</div>
<button type="submit" class="blue-button" [disabled]="!sendForm.valid || !variablesService.currentWallet.loaded">{{ 'SEND.BUTTON' | translate }}</button>

View file

@ -66,6 +66,14 @@
padding-right: 1.5rem;
}
}
.checkbox-block {
flex-basis: 50%;
> label {
top: 3.5rem;
}
}
}
button {

View file

@ -86,7 +86,8 @@ export class SendComponent implements OnInit, OnDestroy {
return {'less_min': true};
}
return null;
}])
}]),
hide: new FormControl(false)
});
additionalOptions = false;
@ -146,6 +147,7 @@ export class SendComponent implements OnInit, OnDestroy {
this.sendForm.get('fee').value,
this.sendForm.get('mixin').value,
this.sendForm.get('comment').value,
this.sendForm.get('hide').value,
(send_status) => {
if (send_status) {
this.modalService.prepareModal('success', 'SEND.SUCCESS_SENT');
@ -170,6 +172,7 @@ export class SendComponent implements OnInit, OnDestroy {
this.sendForm.get('fee').value,
this.sendForm.get('mixin').value,
this.sendForm.get('comment').value,
this.sendForm.get('hide').value,
(send_status) => {
if (send_status) {
this.modalService.prepareModal('success', 'SEND.SUCCESS_SENT');

View file

@ -50,6 +50,19 @@
</ng-select>
</div>
<div class="lock-selection">
<label class="lock-selection-title">{{ 'SETTINGS.APP_LOG_TITLE' | translate }}</label>
<ng-select class="lock-selection-select"
[items]="appLogOptions"
bindValue="id"
bindLabel="id"
[(ngModel)]="variablesService.settings.appLog"
[clearable]="false"
[searchable]="false"
(change)="onLogChange()">
</ng-select>
</div>
<form class="master-password" [formGroup]="changeForm" (ngSubmit)="onSubmitChangePass()">
<span class="master-password-title">{{ 'SETTINGS.MASTER_PASSWORD.TITLE' | translate }}</span>

View file

@ -50,6 +50,26 @@ export class SettingsComponent implements OnInit {
name: '150% scale'
}
];
appLogOptions = [
{
id: -1
},
{
id: 0
},
{
id: 1
},
{
id: 2
},
{
id: 3
},
{
id: 4
}
];
currentBuild = '';
@ -118,6 +138,11 @@ export class SettingsComponent implements OnInit {
this.backend.storeAppData();
}
onLogChange() {
this.backend.setLogLevel(this.variablesService.settings.appLog);
this.backend.storeAppData();
}
back() {
this.location.back();
}

View file

@ -8,6 +8,7 @@
}
.sidebar-accounts {
position: relative;
display: flex;
flex-direction: column;
flex: 1 1 auto;
@ -168,6 +169,15 @@
}
}
}
&:after {
content: '';
position: absolute;
bottom: 0;
left: -3rem;
width: calc(100% + 6rem);
height: 5rem;
}
}
.sidebar-settings {

View file

@ -45,12 +45,14 @@
}
.chart {
position: relative;
display: flex;
align-items: center;
flex: 1 1 auto;
min-height: 40rem;
> div {
position: absolute;
width: 100%;
height: 100%;
}

View file

@ -31,7 +31,7 @@
<div class="tabs">
<div class="tabs-header">
<ng-container *ngFor="let tab of tabs; let index = index">
<div class="tab" [class.active]="tab.active" [class.disabled]="(tab.link === '/send' || tab.link === '/contracts' || tab.link === '/staking') && variablesService.daemon_state !== 2" (click)="changeTab(index)">
<div class="tab" [class.active]="tab.active" [class.disabled]="(tab.link === '/send' || tab.link === '/contracts' || tab.link === '/staking') && (variablesService.daemon_state !== 2 || !variablesService.currentWallet.loaded)" (click)="changeTab(index)">
<i class="icon" [ngClass]="tab.icon"></i>
<span>{{ tab.title | translate }}</span>
<span class="indicator" *ngIf="tab.indicator">{{variablesService.currentWallet.new_contracts}}</span>

View file

@ -104,7 +104,7 @@ export class WalletComponent implements OnInit, OnDestroy {
}
changeTab(index) {
if ((this.tabs[index].link === '/send' || this.tabs[index].link === '/contracts' || this.tabs[index].link === '/staking') && this.variablesService.daemon_state !== 2) {
if ((this.tabs[index].link === '/send' || this.tabs[index].link === '/contracts' || this.tabs[index].link === '/staking') && (this.variablesService.daemon_state !== 2 || !this.variablesService.currentWallet.loaded)) {
return;
}
this.tabs.forEach((tab) => {

View file

@ -146,7 +146,8 @@
"PASS_NOT_MATCH": "Old password not match.",
"CONFIRM_NOT_MATCH": "Confirm password not match."
},
"LAST_BUILD": "Current build: {{value}}"
"LAST_BUILD": "Current build: {{value}}",
"APP_LOG_TITLE": "Log level:"
},
"WALLET": {
"REGISTER_ALIAS": "Register an alias",
@ -249,6 +250,7 @@
"DETAILS": "Additional details",
"MIXIN": "Mixin",
"FEE": "Fee",
"HIDE": "Hide your wallet address from receiver",
"BUTTON": "Send",
"SUCCESS_SENT": "Transaction sent",
"FORM_ERRORS": {
@ -511,7 +513,7 @@
"MINED": "Mined",
"LOCKED": "Blocked",
"IS_MINIMIZE": "Zano application is minimized to the system tray",
"RESTORE": "You can recover it by double-clicking or using the context menu",
"RESTORE": "You can recover it by clicking or using the context menu",
"TRAY_MENU_SHOW": "Resize",
"TRAY_MENU_MINIMIZE": "Minimize"
}

View file

@ -1,7 +1,7 @@
$themes: (
dark: (
bodyBackgroundColor: #131921,
sidebarBackgroundColor: rgba(23, 31, 39, 0.5),
sidebarBackgroundColor: rgba(23, 31, 39, 1),
sidebarBorderColor: #1f2833,
onlineColor: #5cda9d,
offlineColor: #ff5252,
@ -52,7 +52,7 @@ $themes: (
),
gray: (
bodyBackgroundColor: #101417,
sidebarBackgroundColor: rgba(28, 30, 33, 0.5),
sidebarBackgroundColor: rgba(28, 30, 33, 1),
sidebarBorderColor: #2e3337,
onlineColor: #47cf8d,
offlineColor: #ff5252,
@ -103,7 +103,7 @@ $themes: (
),
white: (
bodyBackgroundColor: #eeeeee,
sidebarBackgroundColor: rgba(255, 255, 255, 0.5),
sidebarBackgroundColor: rgba(255, 255, 255, 1),
sidebarBorderColor: #ebebeb,
onlineColor: #46c172,
offlineColor: #ff5252,

View file

@ -67,7 +67,7 @@ app-sidebar {
.fill {
@include themify($themes) {
background-color: themed(progressBarFullBackgroundColor);
background-color: themed(blueTextColor);
}
}
}
@ -130,6 +130,13 @@ app-sidebar {
}
}
}
&:after {
@include themify($themes) {
background: linear-gradient(to bottom, transparent 0%, themed(sidebarBackgroundColor) 100%);
}
}
}
.sidebar-settings {

View file

@ -821,7 +821,7 @@ namespace
}
m_json_helper.feed(str, data_size);
LP_CC_WORKER(m_context, "DATA received <<<<<<<<<<<<< " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_0);
LP_CC_WORKER(m_context, "DATA received <<<<<<<<<<<<< " << data_size << " bytes:" << ENDL << std::string(str, data_size), LOG_LEVEL_4);
if (m_json_helper.has_objects())
{
@ -975,7 +975,7 @@ namespace
void send(const std::string& data)
{
static_cast<epee::net_utils::i_service_endpoint*>(m_p_connection)->do_send(data.c_str(), data.size());
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_0);
LOG_PRINT_CC(m_context, "DATA sent >>>>>>>>>>>>> " << ENDL << data, LOG_LEVEL_4);
}
void send_notification(const std::string& json)

View file

@ -2,6 +2,6 @@
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "1.0"
#define PROJECT_VERSION_BUILD_NO 18
#define PROJECT_VERSION_BUILD_NO 24
#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 "]"

View file

@ -2102,53 +2102,26 @@ uint64_t wallet2::balance(uint64_t& unloked) const
return balance(unloked, fake, fake, fake);
}
//----------------------------------------------------------------------------------------------------
uint64_t wallet2::balance(uint64_t& unloked, uint64_t& awaiting_in, uint64_t& awaiting_out, uint64_t& mined) const
uint64_t wallet2::balance(uint64_t& unlocked, uint64_t& awaiting_in, uint64_t& awaiting_out, uint64_t& mined) const
{
unloked = 0;
unlocked = 0;
uint64_t balance_total = 0;
awaiting_in = 0;
awaiting_out = 0;
mined = 0;
// struct pos_coinbase_tx_t
// {
// pos_coinbase_tx_t() : tx(nullptr), unspent_sum(0) {}
// const currency::transaction* tx;
// uint64_t unspent_sum;
// };
// std::unordered_map<crypto::hash, pos_coinbase_tx_t> pos_coinbase_txs;
for(auto& td : m_transfers)
{
if (td.is_spendable() || td.is_reserved_for_escrow())
{
balance_total += td.amount();
if (is_transfer_unlocked(td))
unloked += td.amount();
unlocked += td.amount();
if (td.m_flags & WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER)
mined += td.amount();
// bool pos_coinbase = false;
// if (is_coinbase(td.m_ptx_wallet_info->m_tx, pos_coinbase))
// mined += td.amount();
// if (pos_coinbase)
// {
// auto& el = pos_coinbase_txs[get_transaction_hash(td.m_ptx_wallet_info->m_tx)];
// el.tx = &td.m_ptx_wallet_info->m_tx;
// el.unspent_sum += td.amount();
// }
}
}
// for(auto pt : pos_coinbase_txs)
// {
// uint64_t mined_prev = mined;
// THROW_IF_FALSE_WALLET_INT_ERR_EX(pt.second.tx->vin.size() == 2, "Invalid coinbase tx in the container");
// uint64_t coinbase_stake_amount = boost::get<txin_to_key>(pt.second.tx->vin[1]).amount;
// if (coinbase_stake_amount <= pt.second.unspent_sum)
// mined -= coinbase_stake_amount;
// THROW_IF_FALSE_WALLET_INT_ERR_EX(mined <= mined_prev, "");
// }
for(auto& utx : m_unconfirmed_txs)
{
if (utx.second.is_income)
@ -2165,11 +2138,6 @@ uint64_t wallet2::balance(uint64_t& unloked, uint64_t& awaiting_in, uint64_t& aw
awaiting_out += utx.second.amount;
}
}
//collect escrow proposals change
// for (auto& exp: m_money_expirations)
// {
// balance_total += exp.change_amount;
// }
return balance_total;
}
@ -4082,16 +4050,24 @@ void wallet2::transfer(const std::vector<currency::tx_destination_entry>& dsts,
return;
}
TIME_MEASURE_START(finalize_transaction_time);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
finalize_transaction(ftp, tx, sk, send_to_network);
TIME_MEASURE_FINISH(finalize_transaction_time);
// unlock transfers at the very end
TIME_MEASURE_START(mark_transfers_as_spent_time);
mark_transfers_as_spent(ftp.selected_transfers, std::string("money transfer, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(tx)));
TIME_MEASURE_FINISH(mark_transfers_as_spent_time);
TIME_MEASURE_START(finalize_transaction_time);
try
{
crypto::secret_key sk = AUTO_VAL_INIT(sk);
finalize_transaction(ftp, tx, sk, send_to_network);
}
catch (...)
{
clear_transfers_from_flag(ftp.selected_transfers, WALLET_TRANSFER_DETAIL_FLAG_SPENT, std::string("exception on money transfer, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(tx)));
throw;
}
TIME_MEASURE_FINISH(finalize_transaction_time);
WLT_LOG_GREEN("[wallet::transfer]"
<< " precalculation_time: " << print_fixed_decimal_point(precalculation_time, 3)
<< ", prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3)

View file

@ -368,7 +368,7 @@ namespace tools
uint64_t amount() const { return m_ptx_wallet_info->m_tx.vout[m_internal_output_index].amount; }
bool is_spent() const { return m_flags & WALLET_TRANSFER_DETAIL_FLAG_SPENT; }
bool is_spendable() const { return (m_flags & (~WALLET_TRANSFER_DETAIL_FLAG_MINED_TRANSFER)) == 0; } // spenable = has no flags or mined flag only
bool is_spendable() const { return (m_flags & (WALLET_TRANSFER_DETAIL_FLAG_SPENT | WALLET_TRANSFER_DETAIL_FLAG_BLOCKED | WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION | WALLET_TRANSFER_DETAIL_FLAG_COLD_SIG_RESERVATION)) == 0; }
bool is_reserved_for_escrow() const { return ( (m_flags & WALLET_TRANSFER_DETAIL_FLAG_ESCROW_PROPOSAL_RESERVATION) != 0 ); }
BEGIN_KV_SERIALIZE_MAP()
@ -610,30 +610,46 @@ namespace tools
{
// do not load wallet if data version is greather than the code version
if (ver > WALLET_FILE_SERIALIZATION_VERSION)
{
LOG_PRINT_MAGENTA("Wallet file truncated due to WALLET_FILE_SERIALIZATION_VERSION is more then curren build", LOG_LEVEL_0);
return;
}
if (ver < 147)
{
LOG_PRINT_MAGENTA("Wallet file truncated due to old version", LOG_LEVEL_0);
return;
}
if (t_archive::is_saving::value)
{
uint64_t formation_ver = CURRENCY_FORMATION_VERSION;
a & formation_ver;
}
else
{
uint64_t formation_ver = 0;
a & formation_ver;
if (formation_ver != CURRENCY_FORMATION_VERSION)
{
LOG_PRINT_MAGENTA("Wallet file truncated due to mismatch CURRENCY_FORMATION_VERSION", LOG_LEVEL_0);
return;
}
}
a & m_blockchain;
a & m_transfers;
a & m_multisig_transfers;
a & m_key_images;
a & m_key_images;
a & m_unconfirmed_txs;
if (ver < 144) //reset unconfirmed due to "coinbase relay bug"
{
m_unconfirmed_txs.clear();
}
a & m_unconfirmed_multisig_transfers;
a & m_payments;
a & m_transfer_history;
a & m_unconfirmed_in_transfers;
a & m_contracts;
a & m_money_expirations;
if (ver >= 144)
{
a & m_pending_key_images;
a & m_tx_keys;
}
a & m_pending_key_images;
a & m_tx_keys;
}

View file

@ -809,6 +809,7 @@ int main(int argc, char* argv[])
GENERATE_AND_PLAY(mined_balance_wallet_test);
GENERATE_AND_PLAY(wallet_outputs_with_same_key_image);
GENERATE_AND_PLAY(wallet_unconfirmed_tx_expiration);
GENERATE_AND_PLAY(wallet_unconfimed_tx_balance);
GENERATE_AND_PLAY(wallet_rpc_integrated_address);
GENERATE_AND_PLAY(wallet_rpc_integrated_address_transfer);

View file

@ -24,11 +24,11 @@ const currency::account_base null_account = AUTO_VAL_INIT(null_account);
struct wlt_lambda_on_transfer2_wrapper : public tools::i_wallet2_callback
{
typedef std::function<bool(const tools::wallet_rpc::wallet_transfer_info&)> Func;
typedef std::function<bool(const tools::wallet_rpc::wallet_transfer_info&, uint64_t, uint64_t, uint64_t)> Func;
wlt_lambda_on_transfer2_wrapper(Func callback) : m_result(false), m_callback(callback) {}
virtual void on_transfer2(const tools::wallet_rpc::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) override
{
m_result = m_callback(wti);
m_result = m_callback(wti, balance, unlocked_balance, total_mined);
}
bool m_result;
Func m_callback;
@ -1777,7 +1777,7 @@ bool gen_wallet_alias_via_special_wallet_funcs::c1(currency::core& c, size_t ev_
uint64_t biggest_alias_reward = get_alias_coast_from_fee("a", TESTS_DEFAULT_FEE);
std::shared_ptr<wlt_lambda_on_transfer2_wrapper> l(new wlt_lambda_on_transfer2_wrapper(
[biggest_alias_reward](const tools::wallet_rpc::wallet_transfer_info& wti) -> bool {
[biggest_alias_reward](const tools::wallet_rpc::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) -> bool {
return std::count(wti.recipients_aliases.begin(), wti.recipients_aliases.end(), "minerminer") == 1 &&
wti.amount == biggest_alias_reward;
}
@ -3214,3 +3214,86 @@ bool wallet_chain_switch_with_spending_the_same_ki::c1(currency::core& c, size_t
return true;
}
//------------------------------------------------------------------------------
wallet_unconfimed_tx_balance::wallet_unconfimed_tx_balance()
{
REGISTER_CALLBACK_METHOD(wallet_unconfimed_tx_balance, c1);
}
bool wallet_unconfimed_tx_balance::generate(std::vector<test_event_entry>& events) const
{
// Test outline:
// 1. Miner sends 100 coins to Alice (50 + 50)
// 2. Alice sends 30 back to Miner (tx is unconfirmed)
// 3. Make sure Alice's wallet has correct balance, when it is checked from wallet's callback
// 4. Few blocks are mined so the tx is get confirmed
// 5. Make sure Alice's balance has changed correctly
m_accounts.resize(TOTAL_ACCS_COUNT);
account_base& miner_acc = m_accounts[MINER_ACC_IDX]; miner_acc.generate();
account_base& alice_acc = m_accounts[ALICE_ACC_IDX]; alice_acc.generate();
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
REWIND_BLOCKS_N(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
MAKE_TX(events, tx_0, miner_acc, alice_acc, MK_TEST_COINS(50), blk_0r);
MAKE_TX(events, tx_1, miner_acc, alice_acc, MK_TEST_COINS(50), blk_0r);
MAKE_NEXT_BLOCK_TX_LIST(events, blk_1, blk_0r, miner_acc, std::list<transaction>({ tx_0, tx_1 }));
REWIND_BLOCKS_N(events, blk_1r, blk_1, miner_acc, WALLET_DEFAULT_TX_SPENDABLE_AGE);
DO_CALLBACK(events, "c1");
return true;
}
bool wallet_unconfimed_tx_balance::c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
bool r = false;
std::shared_ptr<tools::wallet2> alice_wlt = init_playtime_test_wallet(events, c, ALICE_ACC_IDX);
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Alice", alice_wlt, MK_TEST_COINS(100), false, UINT64_MAX, MK_TEST_COINS(100)), false, "");
bool callback_is_ok = false;
// this callback will ba called from within wallet2::transfer() below
std::shared_ptr<wlt_lambda_on_transfer2_wrapper> l(new wlt_lambda_on_transfer2_wrapper(
[&callback_is_ok](const tools::wallet_rpc::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) -> bool
{
CHECK_AND_ASSERT_MES(balance == MK_TEST_COINS(70), false, "invalid balance: " << print_money_brief(balance));
CHECK_AND_ASSERT_MES(unlocked_balance == MK_TEST_COINS(50), false, "invalid unlocked_balance: " << print_money_brief(unlocked_balance));
CHECK_AND_ASSERT_MES(total_mined == 0, false, "invalid total_mined: " << print_money_brief(total_mined));
callback_is_ok = true;
return true;
}
));
alice_wlt->callback(l);
uint64_t fee = TESTS_DEFAULT_FEE * 3;
std::vector<tx_destination_entry> destinations{ tx_destination_entry(MK_TEST_COINS(30) - fee, m_accounts[MINER_ACC_IDX].get_public_address()) };
try
{
alice_wlt->transfer(destinations, 0, 0, fee, empty_extra, empty_attachment);
}
catch (std::exception &e)
{
CHECK_AND_ASSERT_MES(false, false, "alice_wlt->transfer() caused an exception: " << e.what());
}
CHECK_AND_NO_ASSERT_MES(callback_is_ok, false, "callback failed");
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Tx pool has incorrect number of txs: " << c.get_pool_transactions_count());
// 50 coins should be locked and 50 - unlocked
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Alice", alice_wlt, MK_TEST_COINS(70), false, UINT64_MAX, MK_TEST_COINS(50), 0, 0, MK_TEST_COINS(30) - fee), false, "");
// mine WALLET_DEFAULT_TX_SPENDABLE_AGE blocks so the tx get confirmed and coins get unlocked
CHECK_AND_ASSERT_MES(mine_next_pow_blocks_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c, WALLET_DEFAULT_TX_SPENDABLE_AGE), false, "");
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 0, false, "Tx pool has incorrect number of txs: " << c.get_pool_transactions_count());
CHECK_AND_ASSERT_MES(refresh_wallet_and_check_balance("", "Alice", alice_wlt, MK_TEST_COINS(70), false, UINT64_MAX, MK_TEST_COINS(70), 0, 0, 0), false, "");
return true;
}

View file

@ -244,3 +244,10 @@ struct wallet_chain_switch_with_spending_the_same_ki : public wallet_test
bool generate(std::vector<test_event_entry>& events) const;
bool c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
};
struct wallet_unconfimed_tx_balance : public wallet_test
{
wallet_unconfimed_tx_balance();
bool generate(std::vector<test_event_entry>& events) const;
bool c1(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
};

View file

@ -599,50 +599,6 @@ bool transactions_flow_test(
w1.store();
LOG_PRINT_GREEN("Wallet stored OK", LOG_LEVEL_0);
//
//
// LOG_PRINT_L0( "waiting some new blocks...");
// misc_utils::sleep_no_w(DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN*20*1000);//wait two blocks before sync on another wallet on another daemon
// LOG_PRINT_L0( "Refreshing...");
// bool recvd_money = false;
// while(w2.refresh(blocks_fetched, recvd_money, ok, stop) && ( (blocks_fetched && recvd_money) || !blocks_fetched ) )
// {
// misc_utils::sleep_no_w(DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN*1000);//wait two blocks before sync on another wallet on another daemon
// }
//
// uint64_t money_2 = w2.balance();
// if(money_2 == transfered_money)
// {
// LOG_PRINT_GREEN("-----------------------FINISHING TRANSACTIONS FLOW TEST OK-----------------------", LOG_LEVEL_0);
// LOG_PRINT_GREEN("transferred " << print_money(transfered_money) << " via " << i << " transactions" , LOG_LEVEL_0);
// return true;
// }else
// {
// tools::wallet2::transfer_container tc;
// w2.get_transfers(tc);
// BOOST_FOREACH(tools::wallet2::transfer_details& td, tc)
// {
// auto it = txs.find(get_transaction_hash(td.m_ptx_wallet_info->m_tx));
// CHECK_AND_ASSERT_MES(it != txs.end(), false, "transaction not found in local cache");
// it->second.m_received_count += 1;
// }
//
// BOOST_FOREACH(auto& tx_pair, txs)
// {
// if(tx_pair.second.m_received_count != 1)
// {
// LOG_PRINT_RED_L0("Transaction lost: " << get_transaction_hash(tx_pair.second.tx));
// }
//
// }
//
// LOG_PRINT_RED_L0("-----------------------FINISHING TRANSACTIONS FLOW TEST FAILED-----------------------" );
// LOG_PRINT_RED_L0("income " << print_money(money_2) << " via " << i << " transactions, expected money = " << print_money(transfered_money) );
// LOCAL_ASSERT(false);
// return false;
// }
return true;
}