当前位置: 首页>>代码示例>>C++>>正文


C++ public_key::to_base58方法代码示例

本文整理汇总了C++中fc::ecc::public_key::to_base58方法的典型用法代码示例。如果您正苦于以下问题:C++ public_key::to_base58方法的具体用法?C++ public_key::to_base58怎么用?C++ public_key::to_base58使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fc::ecc::public_key的用法示例。


在下文中一共展示了public_key::to_base58方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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());
    }
  }
开发者ID:BrownBear2,项目名称:keyhotee,代码行数:72,代码来源:utils.cpp


注:本文中的fc::ecc::public_key::to_base58方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。