本文整理汇总了C++中fc::ecc::public_key::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ public_key::valid方法的具体用法?C++ public_key::valid怎么用?C++ public_key::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fc::ecc::public_key
的用法示例。
在下文中一共展示了public_key::valid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matchContact
bool matchContact(const fc::ecc::public_key& pk, bts::addressbook::wallet_contact* matchedContact)
{
assert(pk.valid());
auto address_book = bts::get_profile()->get_addressbook();
try
{
auto c = address_book->get_contact_by_public_key(pk);
if(c)
{
*matchedContact = *c;
return true;
}
else
{
*matchedContact = bts::addressbook::wallet_contact();
matchedContact->public_key = pk;
return false;
}
}
catch (const fc::exception&)
{
*matchedContact = bts::addressbook::wallet_contact();
matchedContact->public_key = pk;
return false;
}
}
示例2: toString
QString toString(const fc::ecc::public_key& pk, TContactTextFormatting contactFormatting,
bts::addressbook::contact* matchingContact /*= nullptr*/, bool* isKnownContact /*= nullptr*/)
{
assert(pk.valid());
auto address_book = bts::get_profile()->get_addressbook();
auto c = address_book->get_contact_by_public_key(pk);
if (c)
{
if(matchingContact != nullptr)
*matchingContact = *c;
if(isKnownContact != nullptr)
*isKnownContact = true;
switch(contactFormatting)
{
case KEYHOTEE_IDENTIFIER:
return QString(c->dac_id_string.c_str());
case CONTACT_ALIAS_FULL_NAME:
return QString(std::string(c->first_name + " " + c->last_name).c_str());
case FULL_CONTACT_DETAILS:
return QString(c->get_display_name().c_str());
default:
assert(false);
return QString();
}
}
else
{
auto profile = bts::get_profile();
/// If no contact found try one of registered identities.
std::vector<bts::addressbook::wallet_identity> identities = profile->identities();
for(const auto& identity : identities)
{
assert(identity.public_key.valid());
if(identity.public_key == pk)
{
if(matchingContact != nullptr)
*matchingContact = identity;
if(isKnownContact != nullptr)
*isKnownContact = true;
switch(contactFormatting)
{
case KEYHOTEE_IDENTIFIER:
return QString::fromStdString(identity.dac_id_string);
case CONTACT_ALIAS_FULL_NAME:
return QString::fromStdString(std::string(identity.first_name + " " + identity.last_name));
case FULL_CONTACT_DETAILS:
return QString::fromStdString(identity.get_display_name());
default:
assert(false);
return QString();
}
break;
}
}
if(matchingContact != nullptr)
{
*matchingContact = bts::addressbook::wallet_contact();
matchingContact->public_key = pk;
}
if(isKnownContact != nullptr)
*isKnownContact = false;
/// If code reached this point the publick key is unknown - lets display it as base58
return QString::fromStdString(pk.to_base58());
}
}