MCPcopy Create free account
hub / github.com/cryptonomex/graphene / setKeyLabel

Method setKeyLabel

programs/light_client/Wallet.cpp:335–358  ·  view source on GitHub ↗

* The same label may not be assigned to more than one key, this method will * fail if a key with the same label already exists. * * @return true if the label was set */

Source from the content-addressed store, hash-verified

333 * @return true if the label was set
334 */
335bool Wallet::setKeyLabel(QString pubkey, QString label)
336{
337 if( label == QString() ) // clear the label
338 {
339 auto pub = fc::variant(pubkey.toStdString()).as<public_key_type>();
340 auto old_label = _data.encrypted_private_keys[pub].label;
341 _data.encrypted_private_keys[pub].label = string();
342 if( old_label.size() )
343 _label_to_key.erase(QString::fromStdString(old_label));
344
345 return true;
346 }
347
348 auto itr = _label_to_key.find(label);
349 if( itr != _label_to_key.end() )
350 return false;
351
352 _label_to_key[label] = pubkey;
353
354 auto pub = fc::variant(pubkey.toStdString()).as<public_key_type>();
355 _data.encrypted_private_keys[pub].label = label.toStdString();
356
357 return true;
358}
359
360
361QList<QPair<QString,QString>> Wallet::getAllPublicKeys(bool only_if_private)const

Callers

nothing calls this directly

Calls 5

variantClass · 0.85
eraseMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected