1
0
Fork 0
forked from lthn/blockchain

Merge branch 'develop' into wallet_busy_core

This commit is contained in:
cryptozoidberg 2020-07-17 20:19:58 +02:00
commit 540da93eae
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
10 changed files with 74 additions and 106 deletions

View file

@ -305,12 +305,19 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
LOG_PRINT_MAGENTA("Migrating DB: " << m_db_storage_major_compatibility_version << " -> " << BLOCKCHAIN_STORAGE_MAJOR_COMPATIBILITY_VERSION, LOG_LEVEL_0);
res = m_db_aliases.deinit();
CHECK_AND_ASSERT_MES(res, false, "Unable to deinit db container");
CHECK_AND_ASSERT_MES(res, false, "Unable to deinit m_db_aliases");
res = m_db_addr_to_alias.deinit();
CHECK_AND_ASSERT_MES(res, false, "Unable to deinit m_db_addr_to_alias");
typedef tools::db::cached_key_value_accessor<std::string, std::list<extra_alias_entry_base_old>, true, true> aliases_container_old;
aliases_container_old db_aliases_old(m_db);
res = db_aliases_old.init(BLOCKCHAIN_STORAGE_CONTAINER_ALIASES);
CHECK_AND_ASSERT_MES(res, false, "Unable to init db container");
CHECK_AND_ASSERT_MES(res, false, "Unable to init db_aliases_old");
typedef tools::db::cached_key_value_accessor<account_public_address_old, std::set<std::string>, true, false> address_to_aliases_container_old;
address_to_aliases_container_old db_addr_to_alias_old(m_db);
res = db_addr_to_alias_old.init(BLOCKCHAIN_STORAGE_CONTAINER_ADDR_TO_ALIAS);
CHECK_AND_ASSERT_MES(res, false, "Unable to init db_addr_to_alias_old");
// temporary set db compatibility version to zero during migration in order to trigger db reinit on the next lanunch in case the process stops in the middle
m_db.begin_transaction();
@ -329,19 +336,33 @@ bool blockchain_storage::init(const std::string& config_folder, const boost::pro
return true;
});
typedef std::vector<std::pair<account_public_address, std::set<std::string>>> add_to_alias_container_t;
add_to_alias_container_t addr_to_alias_container;
db_addr_to_alias_old.enumerate_items([&addr_to_alias_container](uint64_t n, const account_public_address_old& addr_old, const std::set<std::string>& aliases){
addr_to_alias_container.emplace_back(std::make_pair(account_public_address::from_old(addr_old), aliases));
return true;
});
// clear and close old format container
m_db.begin_transaction();
db_aliases_old.clear();
db_addr_to_alias_old.clear();
m_db.commit_transaction();
db_aliases_old.deinit();
db_addr_to_alias_old.deinit();
res = m_db_aliases.init(BLOCKCHAIN_STORAGE_CONTAINER_ALIASES);
CHECK_AND_ASSERT_MES(res, false, "Unable to init db container");
CHECK_AND_ASSERT_MES(res, false, "Unable to init m_db_aliases");
res = m_db_addr_to_alias.init(BLOCKCHAIN_STORAGE_CONTAINER_ADDR_TO_ALIAS);
CHECK_AND_ASSERT_MES(res, false, "Unable to init m_db_addr_to_alias");
// re-populate all alias entries back
m_db.begin_transaction();
for(auto& el : temp_container)
m_db_aliases.set(el.first, el.second);
for(auto& el : addr_to_alias_container)
m_db_addr_to_alias.set(el.first, el.second);
m_db.commit_transaction();
// restore db maj compartibility
@ -3511,6 +3532,20 @@ bool blockchain_storage::put_alias_info(const transaction & tx, extra_alias_entr
else
{
LOG_ERROR("Wrong m_addr_to_alias state: address not found " << get_account_address_as_str(local_alias_history.back().m_address));
std::stringstream ss;
ss << "History for alias " << ai.m_alias << ":" << ENDL;
size_t i = 0;
for (auto el : local_alias_history)
{
ss << std::setw(2) << i++ << " "
<< get_account_address_as_str(el.m_address) << " "
<< (el.m_sign.empty() ? " no sig " : " SIGNED ") << " "
<< el.m_text_comment << ENDL;
}
LOG_PRINT_L0(ss.str());
}
//update alias db

View file

@ -711,6 +711,7 @@ namespace currency
} // namespace currency
POD_MAKE_HASHABLE(currency, account_public_address);
POD_MAKE_HASHABLE(currency, account_public_address_old);
BLOB_SERIALIZER(currency::txout_to_key);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,3 @@
export const MIXIN: number = 10;
export const AUDITABLE_WALLET_HELP_PAGE: string = 'zano.org';
export const AUDITABLE_WALLET_HELP_PAGE: string = 'docs.zano.org/docs/auditable-wallets';
export const RCV_ADDR_QR_SCALE: number = 2;

View file

@ -5,19 +5,14 @@
<div class="sidebar-accounts-list scrolled-content">
<div class="sidebar-account" *ngFor="let wallet of variablesService.wallets" [class.active]="wallet?.wallet_id === walletActive" [routerLink]="['/wallet/' + wallet.wallet_id + '/history']">
<div class="wallet-type" (click)="goToAuditableWalletHelpPage($event)">
<div class="auditable" *ngIf="wallet.is_auditable && !wallet.is_watch_only">
<div class="content">Auditable</div>
<div class="content auditable" *ngIf="wallet.is_auditable && !wallet.is_watch_only">
Auditable
</div>
<div class="watch-only" *ngIf="!wallet.is_auditable && wallet.is_watch_only">
<div class="content">Watch-only</div>
<div class="content watch-only" *ngIf="!wallet.is_auditable && wallet.is_watch_only">
Watch-only
</div>
<div class="auditable-watch-only" *ngIf="wallet.is_auditable && wallet.is_watch_only">
<div>
<div class="content">Auditable</div>
</div>
<div>
<div class="content">Watch-only</div>
</div>
<div class="content auditable-watch-only" *ngIf="wallet.is_auditable && wallet.is_watch_only">
Auditable Watch-Only
</div>
</div>
<div class="close-wallet-wrapper">

View file

@ -27,73 +27,31 @@
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 7px;
width: 7px;
height: 100%;
background-color: transparent;
transition: all ease .3s;
> div {
height: 100%;
width: 100%;
}
overflow: hidden;
&:hover {
height: auto;
.content {
opacity: 1;
}
.auditable {
background-color: transparent;
.content {
margin: 0 3rem;
background-color: #5cda9d;
}
}
.watch-only {
background-color: transparent;
.content {
margin: 0 3rem;
background-color: #8686ff;
}
}
.auditable-watch-only {
> div:first-child {
margin-right: 10px;
margin-left: 3rem;
}
> div:last-child {
margin-right: 3rem;
}
}
width: 28px;
}
.content {
padding: 5px;
height: 100%;
padding: 7px;
font-size: 12px;
text-align: center;
color: #000000;
line-height: 14px;
font-weight: 500;
color: #ffffff;
text-decoration: none;
text-transform: capitalize;
transition: all ease .3s;
opacity: 0;
}
.auditable {
background-color: #5cda9d;
}
.watch-only {
background-color: #8686ff;
}
.auditable-watch-only {
display: flex;
> div {
transition: all ease .3s;
width: 100%;
.content {
transition: none;
}
&:first-child {
background-color: #5cda9d;
}
&:last-child {
background-color: #8686ff;
}
writing-mode: vertical-rl;
text-orientation: mixed;
&.auditable {
background-color: #5cda9d;
}
&.watch-only, &.auditable-watch-only {
background-color: #8686ff;
}
}
}
@ -135,7 +93,7 @@
flex-direction: column;
flex-shrink: 0;
cursor: pointer;
padding: 2rem 3rem;
padding: 2.5rem 3rem;
.close-wallet-wrapper {
display: flex;
@ -144,8 +102,8 @@
button {
display: flex;
position: absolute;
top: 6px;
right: -20px;
top: -12px;
right: -18px;
padding: 0;
height: auto;
background: transparent;

View file

@ -52,7 +52,6 @@ namespace
const command_line::arg_descriptor<bool> arg_do_pos_mining = { "do-pos-mining", "Do PoS mining", false, false };
const command_line::arg_descriptor<std::string> arg_pos_mining_reward_address = { "pos-mining-reward-address", "Block reward will be sent to the giving address if specified", "" };
const command_line::arg_descriptor<std::string> arg_restore_wallet = { "restore-wallet", "Restore wallet from the seed phrase and save it to <arg>", "" };
const command_line::arg_descriptor<std::string> arg_restore_awo_wallet = { "restore-awo-wallet", "Restore auditable watch-only wallet from address and view key. Use \"address:viewkey\" as argument", "" };
const command_line::arg_descriptor<bool> arg_offline_mode = { "offline-mode", "Don't connect to daemon, work offline (for cold-signing process)", false, true };
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
@ -274,7 +273,7 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
return false;
}
if (m_wallet_file.empty() && m_generate_new.empty() && m_restore_wallet.empty() && m_restore_awo_wallet.empty() && m_generate_new_aw.empty())
if (m_wallet_file.empty() && m_generate_new.empty() && m_restore_wallet.empty() && m_generate_new_aw.empty())
{
fail_msg_writer() << "you must specify --wallet-file, --generate-new-wallet, --generate-new-auditable-wallet, --restore-wallet or --restore-awo-wallet";
return false;
@ -332,31 +331,14 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm)
}
tools::password_container restore_seed_container;
if (!restore_seed_container.read_password("please, enter wallet seed phrase:\n"))
{
fail_msg_writer() << "failed to read seed phrase";
return false;
}
bool r = restore_wallet(m_restore_wallet, restore_seed_container.password(), pwd_container.password(), false);
CHECK_AND_ASSERT_MES(r, false, "wallet restoring failed");
}
else if (!m_restore_awo_wallet.empty())
{
if (boost::filesystem::exists(m_restore_awo_wallet))
{
fail_msg_writer() << "file " << m_restore_awo_wallet << " already exists";
return false;
}
tools::password_container restore_addr_and_viewkey_container;
if (!restore_addr_and_viewkey_container.read_password("please, enter wallet auditable address, viewkey and timestamp, separated by a colon (\"address:viewkey:timestamp\"):\n"))
if (!restore_seed_container.read_password("please, enter wallet seed phrase or an auditable wallet tracking key:\n"))
{
fail_msg_writer() << "failed to read seed phrase";
return false;
}
bool r = restore_wallet(m_restore_awo_wallet, restore_addr_and_viewkey_container.password(), pwd_container.password(), true);
bool looks_like_tracking_seed = restore_seed_container.password().find(':') != std::string::npos;
bool r = restore_wallet(m_restore_wallet, restore_seed_container.password(), pwd_container.password(), looks_like_tracking_seed);
CHECK_AND_ASSERT_MES(r, false, "wallet restoring failed");
}
else
@ -387,7 +369,6 @@ void simple_wallet::handle_command_line(const boost::program_options::variables_
m_do_not_set_date = command_line::get_arg(vm, arg_dont_set_date);
m_do_pos_mining = command_line::get_arg(vm, arg_do_pos_mining);
m_restore_wallet = command_line::get_arg(vm, arg_restore_wallet);
m_restore_awo_wallet = command_line::get_arg(vm, arg_restore_awo_wallet);
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::try_connect_to_daemon()
@ -1778,7 +1759,6 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_params, arg_do_pos_mining);
command_line::add_arg(desc_params, arg_pos_mining_reward_address);
command_line::add_arg(desc_params, arg_restore_wallet);
command_line::add_arg(desc_params, arg_restore_awo_wallet);
command_line::add_arg(desc_params, arg_offline_mode);
command_line::add_arg(desc_params, command_line::arg_log_file);
command_line::add_arg(desc_params, command_line::arg_log_level);

View file

@ -167,7 +167,6 @@ namespace currency
bool m_do_pos_mining;
bool m_offline_mode;
std::string m_restore_wallet;
std::string m_restore_awo_wallet;
epee::console_handlers_binder m_cmd_binder;

View file

@ -8,6 +8,6 @@
#define PROJECT_REVISION "7"
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
#define PROJECT_VERSION_BUILD_NO 94
#define PROJECT_VERSION_BUILD_NO 95
#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 "]"