diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index a90db4cfc6c2ec65697a7cb7cd5d1bdeb686b764..0e627edfa1221fc0ed8c95d015cb3b41b3bbc5ca 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -1642,13 +1642,19 @@ using Blob = std::vector<uint8_t>; void JamiAccount::registerName(const std::string& password, const std::string& name) { - auto privateKey = readArchive(password).id.first; - - std::string signedName = base64::encode(privateKey->sign(Blob(name.begin(), name.end()))); - auto publickey = privateKey->getPublicKey().toString(); - auto acc = getAccountID(); + std::string signedName; + std::string publickey; + try { + auto privateKey = readArchive(password).id.first; + signedName = base64::encode(privateKey->sign(Blob(name.begin(), name.end()))); + publickey = privateKey->getPublicKey().toString(); + } catch (const std::exception& e) { + JAMI_ERR("[Account %s] can't export account: %s", getAccountID().c_str(), e.what()); + emitSignal<DRing::ConfigurationSignal::NameRegistrationEnded>(getAccountID(), 1, name); + return; + } - nameDir_.get().registerName(ringAccountId_, name, ethAccount_, [acc,name,w=weak()](NameDirectory::RegistrationResponse response){ + nameDir_.get().registerName(ringAccountId_, name, ethAccount_, [acc=getAccountID(), name, w=weak()](NameDirectory::RegistrationResponse response){ int res = (response == NameDirectory::RegistrationResponse::success) ? 0 : ( (response == NameDirectory::RegistrationResponse::invalidName) ? 2 : ( (response == NameDirectory::RegistrationResponse::alreadyTaken) ? 3 : 4));