Example #1
0
/// Transaction numbers are now stored in the nym file (on client and server
/// side) for whichever nym
/// they were issued to. This function verifies whether or not the transaction
/// number is present and valid
/// for any specific nym (i.e. for the nym passed in.)
bool Transactor::verifyTransactionNumber(
    Nym& theNym, const int64_t& lTransactionNumber) // passed by
                                                    // reference for
                                                    // speed, but not a
                                                    // return value.
{
    Identifier NYM_ID(theNym), NOTARY_NYM_ID(server_->m_nymServer);

    // If theNym has the same ID as server_->m_nymServer, then we'll use
    // server_->m_nymServer
    // instead of theNym.  (Since it's the same nym anyway, we'll stick to the
    // one we already loaded so any changes don't get overwritten later.)
    Nym* pNym = nullptr;

    if (NYM_ID == NOTARY_NYM_ID)
        pNym = &server_->m_nymServer;
    else
        pNym = &theNym;
    if (pNym->VerifyTransactionNum(server_->m_strNotaryID, lTransactionNumber))
        return true;
    else {
        const String strNymID(NYM_ID);
        const String strIssued(
            pNym->VerifyIssuedNum(server_->m_strNotaryID, lTransactionNumber)
                ? "(However, that number IS issued to that Nym... He must have "
                  "already used it.)\n"
                : "(In fact, that number isn't even issued to that Nym, though "
                  "perhaps it was at some time in the past?)\n");

        Log::vError("%s: %" PRId64 " not available for Nym %s to use. \n%s",
                    __FUNCTION__,
                    //                    " Oh, and FYI, tangentially, the
                    // current Trns# counter is: %ld\n",
                    lTransactionNumber, strNymID.Get(), strIssued.Get());
        //                    transactionNumber_);
    }

    return false;
}