Exemple #1
0
void OTStash::Serialize(Tag& parent) const
{
    uint32_t sizeMapStashItems = m_mapStashItems.size();

    TagPtr pTag(new Tag("stash"));

    pTag->add_attribute("name", m_str_stash_name);
    pTag->add_attribute("count", formatUint(sizeMapStashItems));

    for (auto& it : m_mapStashItems) {
        const std::string str_instrument_definition_id = it.first;
        OTStashItem* pStashItem = it.second;
        OT_ASSERT((str_instrument_definition_id.size() > 0) &&
                  (nullptr != pStashItem));

        TagPtr pTagItem(new Tag("stashItem"));

        pTagItem->add_attribute("instrumentDefinitionID",
                                pStashItem->GetInstrumentDefinitionID().Get());
        pTagItem->add_attribute("balance", formatLong(pStashItem->GetAmount()));

        pTag->add_tag(pTagItem);
    }

    parent.add_tag(pTag);
}
void OTClause::Serialize(Tag& parent) const
{
    OTASCIIArmor ascCode;

    if (m_strCode.GetLength() > 2)
        ascCode.SetString(m_strCode);
    else
        otErr << "Empty script code in OTClause::Serialize()\n";

    TagPtr pTag(new Tag("clause", ascCode.Get()));

    pTag->add_attribute("name", m_strName.Get());

    parent.add_tag(pTag);
}
void OTClause::Serialize(Tag& parent) const
{
    auto ascCode = Armored::Factory();

    if (m_strCode->GetLength() > 2)
        ascCode->SetString(m_strCode);
    else
        otErr << "Empty script code in OTClause::Serialize()\n";

    TagPtr pTag(new Tag("clause", ascCode->Get()));

    pTag->add_attribute("name", m_strName->Get());

    parent.add_tag(pTag);
}
Exemple #4
0
void Nym::SerializeNymIDSource(Tag& parent) const
{
    // We encode these before storing.
    if (source_) {

        TagPtr pTag(new Tag("nymIDSource", source_->asString()->Get()));

        if (m_strDescription->Exists()) {
            auto ascDescription = Armored::Factory();
            ascDescription->SetString(
                m_strDescription,
                false);  // bLineBreaks=true by default.

            pTag->add_attribute("Description", ascDescription->Get());
        }
        parent.add_tag(pTag);
    }
}
Exemple #5
0
void Nym::SaveCredentialsToTag(
    Tag& parent,
    String::Map* pmapPubInfo,
    String::Map* pmapPriInfo) const
{
    // IDs for revoked child credentials are saved here.
    for (auto& it : m_listRevokedIDs) {
        std::string str_revoked_id = it;
        TagPtr pTag(new Tag("revokedCredential"));
        pTag->add_attribute("ID", str_revoked_id);
        parent.add_tag(pTag);
    }

    // Serialize master and sub-credentials here.
    for (auto& it : m_mapCredentialSets) {
        CredentialSet* pCredential = it.second;
        OT_ASSERT(nullptr != pCredential);

        pCredential->SerializeIDs(
            parent,
            m_listRevokedIDs,
            pmapPubInfo,
            pmapPriInfo,
            true);  // bShowRevoked=false by default (true here), bValid=true
    }

    // Serialize Revoked master credentials here, including their child key
    // credentials.
    for (auto& it : m_mapRevokedSets) {
        CredentialSet* pCredential = it.second;
        OT_ASSERT(nullptr != pCredential);

        pCredential->SerializeIDs(
            parent,
            m_listRevokedIDs,
            pmapPubInfo,
            pmapPriInfo,
            true,
            false);  // bShowRevoked=false by default. (Here it's true.)
                     // bValid=true by default. Here is for revoked, so false.
    }
}
bool AssetContract::SaveContractWallet(Tag& parent) const
{
    const String strID(m_ID);

    // Name is in the clear in memory,
    // and base64 in storage.
    OTASCIIArmor ascName;
    if (m_strName.Exists()) {
        ascName.SetString(m_strName, false); // linebreaks == false
    }

    TagPtr pTag(new Tag("assetType"));

    pTag->add_attribute("name", m_strName.Exists() ? ascName.Get() : "");
    pTag->add_attribute("instrumentDefinitionID", strID.Get());

    parent.add_tag(pTag);

    return true;
}
Exemple #7
0
bool Nym::SavePseudonymWallet(Tag& parent) const
{
    sLock lock(shared_lock_);

    auto nymID = String::Factory(m_nymID);

    // Name is in the clear in memory,
    // and base64 in storage.
    auto ascName = Armored::Factory();
    if (!alias_.empty()) {
        auto temp = String::Factory(alias_);
        ascName->SetString(temp, false);  // linebreaks == false
    }

    TagPtr pTag(new Tag("pseudonym"));

    pTag->add_attribute("name", !alias_.empty() ? ascName->Get() : "");
    pTag->add_attribute("nymID", nymID->Get());

    parent.add_tag(pTag);

    return true;
}