Repository: rotki/rotki

Issue:
Sign In Failed - Need default main_currency
Running from source with latest on osx. 
Getting "Sign In Failed" "main_currency not returned from db_settings"
but - the sign in is actually successful and I get logged in.


Discussion:
It seems [this block of code](https://github.com/rotkehlchenio/rotkehlchen/blob/b2addfdb1cee4e96630a48cd49eb24abcfb5e4ed/ui/userunlock.js#L166) is keeping me from signing in successfully. This is probably the cause of #122 
To initialize the value in my db so that I could achieve a successful sign-in - I commented [this block](https://github.com/rotkehlchenio/rotkehlchen/blob/b2addfdb1cee4e96630a48cd49eb24abcfb5e4ed/ui/userunlock.js#L166-L172) and added this block:
```
client.invoke("set_main_currency", "USD", (error, res) => {
    if(error) {
        showError('Error', 'Error at setting main currency: ' + error);
    } else {
        set_ui_main_currency("USD");
    }
});
```

I only needed this for one execution. After a successful login, I closed rotkehlchen, reverted my changes, restarted the application, and had a successful sign-on.
Thank you for the report @kascheri12 

Once your DB data are initialized rotkehlchen always expects it to be there. Do you have any idea how this situation happened? I would like to understand how you ended up in this situation to see what the proper way to fix this would be.
Whenever I create a new account, I receive the Sign In Failed message like above.

Resolving patch:
diff --git a/rotkehlchen/db/dbhandler.py b/rotkehlchen/db/dbhandler.py
--- a/rotkehlchen/db/dbhandler.py
+++ b/rotkehlchen/db/dbhandler.py
@@ -26,6 +26,7 @@
 DEFAULT_START_DATE = "01/08/2015"
 DEFAULT_UI_FLOATING_PRECISION = 2
 DEFAULT_BALANCE_SAVE_FREQUENCY = 24
+DEFAULT_MAIN_CURRENCY = S_USD
 KDF_ITER = 64000
 
 
@@ -239,6 +240,8 @@ def get_settings(self) -> DBSettings:
             settings['taxfree_after_period'] = DEFAULT_TAXFREE_AFTER_PERIOD
         if 'balance_save_frequency' not in settings:
             settings['balance_save_frequency'] = DEFAULT_BALANCE_SAVE_FREQUENCY
+        if 'main_currency' not in settings:
+            settings['main_currency'] = DEFAULT_MAIN_CURRENCY
 
         # populate values that are not saved in the setting but computed and returned
         # as part of the get_settings call


Test patch:
diff --git a/rotkehlchen/tests/test_db.py b/rotkehlchen/tests/test_db.py
--- a/rotkehlchen/tests/test_db.py
+++ b/rotkehlchen/tests/test_db.py
@@ -8,6 +8,7 @@
 from rotkehlchen.db.dbhandler import (
     ROTKEHLCHEN_DB_VERSION,
     DEFAULT_START_DATE,
+    DEFAULT_MAIN_CURRENCY,
     DEFAULT_UI_FLOATING_PRECISION,
     DEFAULT_BALANCE_SAVE_FREQUENCY,
 )
@@ -134,6 +135,7 @@ def test_writting_fetching_data(data_dir, username):
         'taxfree_after_period': YEAR_IN_SECONDS,
         'balance_save_frequency': DEFAULT_BALANCE_SAVE_FREQUENCY,
         'last_balance_save': 0,
+        'main_currency': DEFAULT_MAIN_CURRENCY,
     }
 
     # Check setting non-existing settings. Should be ignored
@@ -294,6 +296,7 @@ def test_settings_entry_types(data_dir, username):
     assert isinstance(res['eth_rpc_port'], str)
     assert isinstance(res['balance_save_frequency'], int)
     assert isinstance(res['last_balance_save'], int)
+    assert isinstance(res['main_currency'], str)
 
 
 def test_balance_save_frequency_check(data_dir, username):