Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::Mint Class Referenceabstract

#include <Mint.hpp>

Inheritance diagram for opentxs::Mint:
Collaboration diagram for opentxs::Mint:

Public Member Functions

int32_t GetSeries () const
 
time64_t GetValidFrom () const
 
time64_t GetValidTo () const
 
time64_t GetExpiration () const
 
EXPORT bool Expired () const
 
OTAccountGetCashReserveAccount () const
 
virtual EXPORT ~Mint ()
 
virtual void Release ()
 
void Release_Mint ()
 
void ReleaseDenominations ()
 
EXPORT bool LoadMint (const char *szAppend=nullptr)
 
EXPORT bool SaveMint (const char *szAppend=nullptr)
 
virtual bool LoadContract ()
 
void SetSavePrivateKeys (bool bDoIt=true)
 
bool GetPrivate (OTASCIIArmor &theArmor, int64_t lDenomination)
 
bool GetPublic (OTASCIIArmor &theArmor, int64_t lDenomination)
 
int64_t GetDenomination (int32_t nIndex)
 
EXPORT int64_t GetLargestDenomination (int64_t lAmount)
 
virtual bool AddDenomination (OTPseudonym &theNotary, int64_t lDenomination, int32_t nPrimeLength=1024)=0
 
int32_t GetDenominationCount () const
 
virtual bool VerifyContractID () const
 
EXPORT bool VerifyMint (const OTPseudonym &theOperator)
 
virtual void UpdateContents ()
 
void SetAssetID (const OTIdentifier &newID)
 
EXPORT void GenerateNewMint (int32_t nSeries, time64_t VALID_FROM, time64_t VALID_TO, time64_t MINT_EXPIRATION, const OTIdentifier &theAssetID, const OTIdentifier &theServerID, OTPseudonym &theNotary, int64_t nDenom1=0, int64_t nDenom2=0, int64_t nDenom3=0, int64_t nDenom4=0, int64_t nDenom5=0, int64_t nDenom6=0, int64_t nDenom7=0, int64_t nDenom8=0, int64_t nDenom9=0, int64_t nDenom10=0)
 
virtual EXPORT bool SignToken (OTPseudonym &theNotary, Token &theToken, OTString &theOutput, int32_t nTokenIndex)=0
 
virtual EXPORT bool VerifyToken (OTPseudonym &theNotary, OTString &theCleartextToken, int64_t lDenomination)=0
 
virtual bool SaveContractWallet (std::ofstream &ofs) const
 
- Public Member Functions inherited from opentxs::OTContract
const char * GetHashType () const
 
void SetIdentifier (const OTIdentifier &theID)
 
EXPORT OTContract ()
 
EXPORT OTContract (const OTString &name, const OTString &foldername, const OTString &filename, const OTString &strID)
 
EXPORT OTContract (const OTString &strID)
 
EXPORT OTContract (const OTIdentifier &theID)
 
void Initialize ()
 
virtual EXPORT ~OTContract ()
 
EXPORT void Release_Contract ()
 
EXPORT void ReleaseSignatures ()
 
virtual EXPORT bool CreateContract (const OTString &strContract, const OTPseudonym &theSigner)
 
EXPORT bool InsertNym (const OTString &strKeyName, const OTString &strKeyValue)
 
EXPORT void GetName (OTString &strName) const
 
EXPORT void SetName (const OTString &strName)
 
virtual EXPORT bool VerifyContract ()
 
virtual EXPORT void GetIdentifier (OTIdentifier &theIdentifier) const
 
virtual EXPORT void GetIdentifier (OTString &theIdentifier) const
 
EXPORT void GetFilename (OTString &strFilename) const
 
EXPORT void GetFoldername (OTString &strFoldername) const
 
EXPORT bool LoadContract (const char *szFoldername, const char *szFilename)
 
EXPORT bool LoadContractFromString (const OTString &theStr)
 
bool LoadContractRawFile ()
 
EXPORT bool ParseRawFile ()
 
EXPORT bool SaveToContractFolder ()
 
EXPORT bool SaveContractRaw (OTString &strOutput) const
 
EXPORT bool RewriteContract (OTString &strOutput) const
 
EXPORT bool SaveContract ()
 
EXPORT bool SaveContract (const char *szFoldername, const char *szFilename)
 
virtual EXPORT void CreateContents ()
 
EXPORT void CreateInnerContents ()
 
virtual EXPORT bool SaveContents (std::ofstream &ofs) const
 
virtual EXPORT bool SaveContractWallet (OTString &strContents) const
 
virtual EXPORT bool DisplayStatistics (OTString &strContents) const
 
virtual EXPORT bool SaveContents (OTString &strContents) const
 
virtual EXPORT bool SignContract (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContractAuthent (const OTPseudonym &theNym, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const OTAsymmetricKey &theKey, OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr)
 
EXPORT bool SignContract (const char *szFoldername, const char *szFilename, OTSignature &theSignature, const OTPasswordData *pPWData=nullptr)
 
virtual EXPORT void CalculateContractID (OTIdentifier &newID) const
 
virtual EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
virtual EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifyWithKey (const OTAsymmetricKey &theKey, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySigAuthent (const OTPseudonym &theNym, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const OTAsymmetricKey &theKey, const OTSignature &theSignature, const OTString &strHashType, const OTPasswordData *pPWData=nullptr) const
 
EXPORT bool VerifySignature (const char *szFoldername, const char *szFilename, const OTSignature &theSignature, const OTPasswordData *pPWData=nullptr) const
 
EXPORT const OTAsymmetricKeyGetContractPublicKey () const
 
EXPORT const OTPseudonymGetContractPublicNym () const
 

Static Public Member Functions

static EXPORT MintMintFactory ()
 
static EXPORT MintMintFactory (const OTString &strServerID, const OTString &strAssetTypeID)
 
static EXPORT MintMintFactory (const OTString &strServerID, const OTString &strServerNymID, const OTString &strAssetTypeID)
 
- Static Public Member Functions inherited from opentxs::OTContract
static EXPORT bool DearmorAndTrim (const OTString &strInput, OTString &strOutput, OTString &strFirstLine)
 
static bool AddBookendsAroundContent (OTString &strOutput, const OTString &strContents, const OTString &strContractType, const OTString &strHashType, const listOfSignatures &listSignatures)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
 
static EXPORT bool LoadEncodedTextField (irr::io::IrrXMLReader *&xml, OTString &strOutput)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool LoadEncodedTextFieldByName (irr::io::IrrXMLReader *&xml, OTString &strOutput, const char *&szName, OTString::Map *pmapExtraVars=nullptr)
 
static bool SkipToElement (irr::io::IrrXMLReader *&xml)
 
static bool SkipToTextField (irr::io::IrrXMLReader *&xml)
 
static bool SkipAfterLoadingField (irr::io::IrrXMLReader *&xml)
 
static EXPORT bool SignFlatText (OTString &strFlatText, const OTString &strContractType, const OTPseudonym &theSigner, OTString &strOutput)
 

Protected Member Functions

virtual int32_t ProcessXMLNode (irr::io::IrrXMLReader *&xml)
 
void InitMint ()
 
 Mint ()
 
EXPORT Mint (const OTString &strServerID, const OTString &strAssetTypeID)
 
EXPORT Mint (const OTString &strServerID, const OTString &strServerNymID, const OTString &strAssetTypeID)
 
- Protected Member Functions inherited from opentxs::OTContract
bool LoadContractXML ()
 

Protected Attributes

mapOfArmor m_mapPrivate
 
mapOfArmor m_mapPublic
 
OTIdentifier m_ServerID
 
OTIdentifier m_ServerNymID
 
OTAsymmetricKeym_pKeyPublic
 
OTIdentifier m_AssetID
 
int32_t m_nDenominationCount
 
bool m_bSavePrivateKeys
 
int32_t m_nSeries
 
time64_t m_VALID_FROM
 
time64_t m_VALID_TO
 
time64_t m_EXPIRATION
 
OTIdentifier m_CashAccountID
 
OTAccountm_pReserveAcct
 
- Protected Attributes inherited from opentxs::OTContract
OTString m_strName
 
OTString m_strFoldername
 
OTString m_strFilename
 
OTIdentifier m_ID
 
OTStringXML m_xmlUnsigned
 
OTString m_strRawFile
 
OTString m_strSigHashType
 
OTString m_strContractType
 
mapOfNyms m_mapNyms
 
listOfSignatures m_listSignatures
 
OTString m_strVersion
 
OTString m_strEntityShortName
 
OTString m_strEntityLongName
 
OTString m_strEntityEmail
 
OTString::Map m_mapConditions
 

Detailed Description

Definition at line 150 of file Mint.hpp.

Constructor & Destructor Documentation

opentxs::Mint::Mint ( )
protected

Definition at line 358 of file Mint.cpp.

359  : ot_super()
362  , m_bSavePrivateKeys(false)
363  , m_nSeries(0)
367  , m_pReserveAcct(nullptr)
368 {
369  InitMint();
370 }
int32_t m_nSeries
Definition: Mint.hpp:186
static EXPORT OTAsymmetricKey * KeyFactory()
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
void InitMint()
Definition: Mint.cpp:296
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t m_VALID_FROM
Definition: Mint.hpp:192
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
#define OT_TIME_ZERO
Definition: Common.hpp:180
time64_t m_VALID_TO
Definition: Mint.hpp:194
opentxs::Mint::Mint ( const OTString strServerID,
const OTString strAssetTypeID 
)
protected

Definition at line 338 of file Mint.cpp.

339  : ot_super(strAssetTypeID)
340  , m_ServerID(strServerID)
342  , m_AssetID(strAssetTypeID)
344  , m_bSavePrivateKeys(false)
345  , m_nSeries(0)
349  , m_pReserveAcct(nullptr)
350 {
352  m_strFilename.Format("%s%s%s", strServerID.Get(), OTLog::PathSeparator(),
353  strAssetTypeID.Get());
354 
355  InitMint();
356 }
static EXPORT const OTString & Mint()
Definition: OTFolders.cpp:323
int32_t m_nSeries
Definition: Mint.hpp:186
static EXPORT OTAsymmetricKey * KeyFactory()
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
static EXPORT const char * PathSeparator()
Definition: OTLog.cpp:408
void InitMint()
Definition: Mint.cpp:296
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
OTIdentifier m_ServerID
Definition: Mint.hpp:167
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTIdentifier m_AssetID
Definition: Mint.hpp:174
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t m_VALID_FROM
Definition: Mint.hpp:192
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
#define OT_TIME_ZERO
Definition: Common.hpp:180
time64_t m_VALID_TO
Definition: Mint.hpp:194
OTString m_strFoldername
Definition: OTContract.hpp:169
opentxs::Mint::Mint ( const OTString strServerID,
const OTString strServerNymID,
const OTString strAssetTypeID 
)
protected

Definition at line 316 of file Mint.cpp.

318  : ot_super(strAssetTypeID)
319  , m_ServerID(strServerID)
320  , m_ServerNymID(strServerNymID)
322  , m_AssetID(strAssetTypeID)
324  , m_bSavePrivateKeys(false)
325  , m_nSeries(0)
329  , m_pReserveAcct(nullptr)
330 {
332  m_strFilename.Format("%s%s%s", strServerID.Get(), OTLog::PathSeparator(),
333  strAssetTypeID.Get());
334 
335  InitMint();
336 }
static EXPORT const OTString & Mint()
Definition: OTFolders.cpp:323
int32_t m_nSeries
Definition: Mint.hpp:186
static EXPORT OTAsymmetricKey * KeyFactory()
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
static EXPORT const char * PathSeparator()
Definition: OTLog.cpp:408
void InitMint()
Definition: Mint.cpp:296
OTIdentifier m_ServerNymID
Definition: Mint.hpp:169
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
OTIdentifier m_ServerID
Definition: Mint.hpp:167
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTIdentifier m_AssetID
Definition: Mint.hpp:174
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t m_VALID_FROM
Definition: Mint.hpp:192
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
#define OT_TIME_ZERO
Definition: Common.hpp:180
time64_t m_VALID_TO
Definition: Mint.hpp:194
OTString m_strFoldername
Definition: OTContract.hpp:169
opentxs::Mint::~Mint ( )
virtual

Definition at line 282 of file Mint.cpp.

283 {
284  Release_Mint();
285 
286  if (nullptr != m_pKeyPublic) {
287  delete m_pKeyPublic;
288  m_pKeyPublic = nullptr;
289  }
290  else
291  otErr << __FUNCTION__ << ": the logic: if (nullptr != m_pKeyPublic) "
292  "failed, though it NEVER should. "
293  "(That pointer should never be nullptr.)\n";
294 }
void Release_Mint()
Definition: Mint.cpp:260
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
OTLOG_IMPORT OTLogStream otErr

Member Function Documentation

virtual bool opentxs::Mint::AddDenomination ( OTPseudonym theNotary,
int64_t  lDenomination,
int32_t  nPrimeLength = 1024 
)
pure virtual

Implemented in opentxs::MintLucre.

bool opentxs::Mint::Expired ( ) const

Definition at line 227 of file Mint.cpp.

228 {
229  const time64_t CURRENT_TIME = OTTimeGetCurrentTime();
230 
231  if ((CURRENT_TIME >= m_VALID_FROM) && (CURRENT_TIME <= m_EXPIRATION))
232  return false;
233  else
234  return true;
235 }
time64_t m_EXPIRATION
Definition: Mint.hpp:196
int64_t time64_t
Definition: Common.hpp:209
time64_t OTTimeGetCurrentTime()
Definition: Common.hpp:211
time64_t m_VALID_FROM
Definition: Mint.hpp:192
void opentxs::Mint::GenerateNewMint ( int32_t  nSeries,
time64_t  VALID_FROM,
time64_t  VALID_TO,
time64_t  MINT_EXPIRATION,
const OTIdentifier theAssetID,
const OTIdentifier theServerID,
OTPseudonym theNotary,
int64_t  nDenom1 = 0,
int64_t  nDenom2 = 0,
int64_t  nDenom3 = 0,
int64_t  nDenom4 = 0,
int64_t  nDenom5 = 0,
int64_t  nDenom6 = 0,
int64_t  nDenom7 = 0,
int64_t  nDenom8 = 0,
int64_t  nDenom9 = 0,
int64_t  nDenom10 = 0 
)

Definition at line 879 of file Mint.cpp.

887 {
888  Release();
889 
890  m_AssetID = theAssetID;
891  m_ServerID = theServerID;
892 
893  OTIdentifier SERVER_NYM_ID(theNotary);
894  m_ServerNymID = SERVER_NYM_ID;
895 
896  m_nSeries = nSeries;
897  m_VALID_FROM = VALID_FROM;
898  m_VALID_TO = VALID_TO;
899  m_EXPIRATION = MINT_EXPIRATION;
900 
901  // Normally asset accounts are created based on an incoming message,
902  // so I'm just simulating that in order to make sure it gets its
903  // necessary input values, such as asset type, server ID, etc.
904  OTMessage theMessage;
905  SERVER_NYM_ID.GetString(theMessage.m_strNymID);
906  theAssetID.GetString(theMessage.m_strAssetID);
907  theServerID.GetString(theMessage.m_strServerID);
908 
909  /* OTAccount::
910  GenerateNewAccount(const OTIdentifier & theUserID, const OTIdentifier &
911  theServerID,
912  const OTPseudonym & theServerNym, const OTMessage &
913  theMessage,
914  const AccountType eAcctType=simple);
915  */
917  SERVER_NYM_ID, theServerID, theNotary, theMessage, OTAccount::mint);
918 
919  if (m_pReserveAcct) {
921  otOut << "Successfully created cash reserve account for new mint.\n";
922  }
923  else {
924  otErr << "Error creating cash reserve account for new mint.\n";
925  }
926 
927  if (nDenom1) {
928  AddDenomination(theNotary,
929  nDenom1); // int32_t nPrimeLength default = 1024
930  }
931  if (nDenom2) {
932  AddDenomination(theNotary,
933  nDenom2); // int32_t nPrimeLength default = 1024
934  }
935  if (nDenom3) {
936  AddDenomination(theNotary,
937  nDenom3); // int32_t nPrimeLength default = 1024
938  }
939  if (nDenom4) {
940  AddDenomination(theNotary,
941  nDenom4); // int32_t nPrimeLength default = 1024
942  }
943  if (nDenom5) {
944  AddDenomination(theNotary,
945  nDenom5); // int32_t nPrimeLength default = 1024
946  }
947  if (nDenom6) {
948  AddDenomination(theNotary,
949  nDenom6); // int32_t nPrimeLength default = 1024
950  }
951  if (nDenom7) {
952  AddDenomination(theNotary,
953  nDenom7); // int32_t nPrimeLength default = 1024
954  }
955  if (nDenom8) {
956  AddDenomination(theNotary,
957  nDenom8); // int32_t nPrimeLength default = 1024
958  }
959  if (nDenom9) {
960  AddDenomination(theNotary,
961  nDenom9); // int32_t nPrimeLength default = 1024
962  }
963  if (nDenom10) {
964  AddDenomination(theNotary,
965  nDenom10); // int32_t nPrimeLength default = 1024
966  }
967 }
int32_t m_nSeries
Definition: Mint.hpp:186
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
virtual bool AddDenomination(OTPseudonym &theNotary, int64_t lDenomination, int32_t nPrimeLength=1024)=0
static EXPORT OTAccount * GenerateNewAccount(const OTIdentifier &userId, const OTIdentifier &serverId, const OTPseudonym &serverNym, const OTMessage &message, AccountType acctType=simple, int64_t stashTransNum=0)
Definition: OTAccount.cpp:531
OTLOG_IMPORT OTLogStream otOut
virtual void Release()
Definition: Mint.cpp:272
OTIdentifier m_ServerNymID
Definition: Mint.hpp:169
OTIdentifier m_ServerID
Definition: Mint.hpp:167
OTIdentifier m_CashAccountID
Definition: Mint.hpp:199
OTIdentifier m_AssetID
Definition: Mint.hpp:174
virtual EXPORT void GetIdentifier(OTIdentifier &theIdentifier) const
Definition: OTContract.cpp:317
OTLOG_IMPORT OTLogStream otErr
time64_t m_VALID_FROM
Definition: Mint.hpp:192
time64_t m_VALID_TO
Definition: Mint.hpp:194
OTAccount* opentxs::Mint::GetCashReserveAccount ( ) const
inline

Definition at line 234 of file Mint.hpp.

235  {
236  return m_pReserveAcct;
237  }
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
int64_t opentxs::Mint::GetDenomination ( int32_t  nIndex)

Definition at line 610 of file Mint.cpp.

611 {
612  // index out of bounds.
613  if (nIndex > (m_nDenominationCount - 1)) {
614  return 0;
615  }
616 
617  int32_t nIterateIndex = 0;
618 
619  for (auto it = m_mapPublic.begin(); it != m_mapPublic.end();
620  ++it, nIterateIndex++) {
621  OTASCIIArmor* pArmor = it->second;
622  OT_ASSERT_MSG(nullptr != pArmor,
623  "nullptr mint pointer in Mint::GetDenomination.\n");
624 
625  if (nIndex == nIterateIndex) return it->first;
626  }
627 
628  return 0;
629 }
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
int32_t m_nDenominationCount
Definition: Mint.hpp:176
mapOfArmor m_mapPublic
Definition: Mint.hpp:164
int32_t opentxs::Mint::GetDenominationCount ( ) const
inline

Definition at line 282 of file Mint.hpp.

283  {
284  return m_nDenominationCount;
285  }
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t opentxs::Mint::GetExpiration ( ) const
inline

Definition at line 226 of file Mint.hpp.

227  {
228  return m_EXPIRATION;
229  } // The date the mint expires (should be halfway
time64_t m_EXPIRATION
Definition: Mint.hpp:196
int64_t opentxs::Mint::GetLargestDenomination ( int64_t  lAmount)

Definition at line 596 of file Mint.cpp.

597 {
598  for (int32_t nIndex = GetDenominationCount() - 1; nIndex >= 0; nIndex--) {
599  int64_t lDenom = GetDenomination(nIndex);
600 
601  if (lDenom <= lAmount) return lDenom;
602  }
603 
604  return 0;
605 }
int32_t GetDenominationCount() const
Definition: Mint.hpp:282
int64_t GetDenomination(int32_t nIndex)
Definition: Mint.cpp:610
bool opentxs::Mint::GetPrivate ( OTASCIIArmor theArmor,
int64_t  lDenomination 
)

Definition at line 557 of file Mint.cpp.

558 {
559  for (auto& it : m_mapPrivate) {
560  OTASCIIArmor* pArmor = it.second;
561  OT_ASSERT_MSG(nullptr != pArmor,
562  "nullptr mint pointer in Mint::GetPrivate.\n");
563  // if this denomination (say, 50) matches the one passed in
564  if (it.first == lDenomination) {
565  theArmor.Set(*pArmor);
566  return true;
567  }
568  }
569  return false;
570 }
mapOfArmor m_mapPrivate
Definition: Mint.hpp:160
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
bool opentxs::Mint::GetPublic ( OTASCIIArmor theArmor,
int64_t  lDenomination 
)

Definition at line 574 of file Mint.cpp.

575 {
576  for (auto& it : m_mapPublic) {
577  OTASCIIArmor* pArmor = it.second;
578  OT_ASSERT_MSG(nullptr != pArmor,
579  "nullptr mint pointer in Mint::GetPublic.\n");
580  // if this denomination (say, 50) matches the one passed in
581  if (it.first == lDenomination) {
582  theArmor.Set(*pArmor);
583  return true;
584  }
585  }
586 
587  return false;
588 }
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
mapOfArmor m_mapPublic
Definition: Mint.hpp:164
int32_t opentxs::Mint::GetSeries ( ) const
inline

Definition at line 214 of file Mint.hpp.

215  {
216  return m_nSeries;
217  } // The series ID
int32_t m_nSeries
Definition: Mint.hpp:186
time64_t opentxs::Mint::GetValidFrom ( ) const
inline

Definition at line 218 of file Mint.hpp.

219  {
220  return m_VALID_FROM;
221  } // The token "valid from" date for this series
time64_t m_VALID_FROM
Definition: Mint.hpp:192
time64_t opentxs::Mint::GetValidTo ( ) const
inline

Definition at line 222 of file Mint.hpp.

223  {
224  return m_VALID_TO;
225  } // The token "valid until" date for this series
time64_t m_VALID_TO
Definition: Mint.hpp:194
void opentxs::Mint::InitMint ( )
protected

Definition at line 296 of file Mint.cpp.

297 {
298  m_strContractType.Set("MINT");
299 
301 
303  false; // Determines whether it serializes private keys (no if false)
304 
305  // Mints expire and new ones are rotated in.
306  // All tokens have the same series, and validity dates,
307  // of the mint that created them.
308  m_nSeries = 0;
312 
313  m_pReserveAcct = nullptr;
314 }
int32_t m_nSeries
Definition: Mint.hpp:186
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTString m_strContractType
Definition: OTContract.hpp:178
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t m_VALID_FROM
Definition: Mint.hpp:192
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
#define OT_TIME_ZERO
Definition: Common.hpp:180
time64_t m_VALID_TO
Definition: Mint.hpp:194
bool opentxs::Mint::LoadContract ( )
virtual

Reimplemented from opentxs::OTContract.

Definition at line 372 of file Mint.cpp.

373 {
374  otOut << "Mint::LoadContract OVERRIDE.\n";
375  return LoadMint();
376 }
OTLOG_IMPORT OTLogStream otOut
EXPORT bool LoadMint(const char *szAppend=nullptr)
Definition: Mint.cpp:378
bool opentxs::Mint::LoadMint ( const char *  szAppend = nullptr)

Definition at line 378 of file Mint.cpp.

382 {
384 
385  const OTString strServerID(m_ServerID), strAssetTypeID(m_AssetID);
386 
387  if (!m_strFilename.Exists()) {
388  if (nullptr != szAppend)
389  m_strFilename.Format("%s%s%s%s", strServerID.Get(),
390  OTLog::PathSeparator(), // server appends ".1"
391  // or ".PUBLIC" here.
392  strAssetTypeID.Get(), szAppend);
393  else
395  "%s%s%s", strServerID.Get(), OTLog::PathSeparator(),
396  strAssetTypeID.Get()); // client uses only asset ID, no append.
397  }
398 
399  OTString strFilename;
400  if (nullptr != szAppend)
401  strFilename.Format("%s%s", strAssetTypeID.Get(),
402  szAppend); // server side
403  else
404  strFilename = strAssetTypeID.Get(); // client side
405 
406  const char* szFolder1name = OTFolders::Mint().Get(); // "mints"
407  const char* szFolder2name = strServerID.Get(); // "mints/SERVER_ID"
408  const char* szFilename =
409  strFilename.Get(); // "mints/SERVER_ID/ASSET_TYPE_ID<szAppend>"
410 
411  if (!OTDB::Exists(szFolder1name, szFolder2name, szFilename)) {
412  otOut << "Mint::LoadMint: File does not exist: " << szFolder1name
413  << OTLog::PathSeparator() << szFolder2name
414  << OTLog::PathSeparator() << szFilename << "\n";
415  return false;
416  }
417 
418  std::string strFileContents(
419  OTDB::QueryPlainString(szFolder1name, szFolder2name,
420  szFilename)); // <=== LOADING FROM DATA STORE.
421 
422  if (strFileContents.length() < 2) {
423  otErr << "Mint::LoadMint: Error reading file: " << szFolder1name
424  << OTLog::PathSeparator() << szFolder2name
425  << OTLog::PathSeparator() << szFilename << "\n";
426  return false;
427  }
428 
429  // NOTE: No need to worry about the OT ARMORED file format, since
430  // LoadContractFromString already handles that internally.
431 
432  OTString strRawFile(strFileContents.c_str());
433 
434  bool bSuccess = LoadContractFromString(
435  strRawFile); // Note: This handles OT ARMORED file format.
436 
437  return bSuccess;
438 }
static EXPORT const OTString & Mint()
Definition: OTFolders.cpp:323
static EXPORT const char * PathSeparator()
Definition: OTLog.cpp:408
OTLOG_IMPORT OTLogStream otOut
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
OTIdentifier m_ServerID
Definition: Mint.hpp:167
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:728
OTIdentifier m_AssetID
Definition: Mint.hpp:174
EXPORT const char * Get() const
Definition: OTString.cpp:1045
OTLOG_IMPORT OTLogStream otErr
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:584
EXPORT bool LoadContractFromString(const OTString &theStr)
OTString m_strFoldername
Definition: OTContract.hpp:169
Mint * opentxs::Mint::MintFactory ( )
static

Definition at line 154 of file Mint.cpp.

155 {
156  Mint* pMint = nullptr;
157 
158 #if defined(OT_CASH_USING_LUCRE)
159  pMint = new MintLucre;
160 #elif defined(OT_CASH_USING_MAGIC_MONEY)
161  // pMint = new Mint_MagicMoney;
162  otErr << __FUCNTION__ << ": Open-Transactions doesn't support Magic Money "
163  "by Pr0duct Cypher (yet), "
164  << "so it's impossible to instantiate a mint.\n";
165 #else
166  otErr
167  << __FUNCTION__
168  << ": Open-Transactions isn't built with any digital cash algorithms, "
169  << "so it's impossible to instantiate a mint.\n";
170 #endif
171  return pMint;
172 }
OTLOG_IMPORT OTLogStream otErr
Mint * opentxs::Mint::MintFactory ( const OTString strServerID,
const OTString strAssetTypeID 
)
static

Definition at line 175 of file Mint.cpp.

177 {
178  Mint* pMint = nullptr;
179 
180 #if defined(OT_CASH_USING_LUCRE)
181  pMint = new MintLucre(strServerID, strAssetTypeID);
182 #elif defined(OT_CASH_USING_MAGIC_MONEY)
183  // pMint = new OTMint_MagicMoney;
184  otErr << __FUNCTION__ << ": Open-Transactions doesn't support Magic Money "
185  "by Pr0duct Cypher (yet), "
186  << "so it's impossible to instantiate a mint.\n";
187 #else
188  otErr
189  << __FUNCTION__
190  << ": Open-Transactions isn't built with any digital cash algorithms, "
191  << "so it's impossible to instantiate a mint.\n";
192 #endif
193  return pMint;
194 }
OTLOG_IMPORT OTLogStream otErr
Mint * opentxs::Mint::MintFactory ( const OTString strServerID,
const OTString strServerNymID,
const OTString strAssetTypeID 
)
static

Definition at line 197 of file Mint.cpp.

200 {
201  Mint* pMint = nullptr;
202 
203 #if defined(OT_CASH_USING_LUCRE)
204  pMint = new MintLucre(strServerID, strServerNymID, strAssetTypeID);
205 #elif defined(OT_CASH_USING_MAGIC_MONEY)
206  // pMint = new OTMint_MagicMoney;
207  otErr << __FUNCTION__ << ": Open-Transactions doesn't support Magic Money "
208  "by Pr0duct Cypher (yet), "
209  << "so it's impossible to instantiate a mint.\n";
210 #else
211  otErr
212  << __FUNCTION__
213  << ": Open-Transactions isn't built with any digital cash algorithms, "
214  << "so it's impossible to instantiate a mint.\n";
215 #endif
216  return pMint;
217 }
OTLOG_IMPORT OTLogStream otErr
int32_t opentxs::Mint::ProcessXMLNode ( irr::io::IrrXMLReader *&  xml)
protectedvirtual

Reimplemented from opentxs::OTContract.

Definition at line 704 of file Mint.cpp.

705 {
706  OT_ASSERT(nullptr != m_pKeyPublic);
707 
708  int32_t nReturnVal = 0;
709 
710  const OTString strNodeName(xml->getNodeName());
711 
712  // Here we call the parent class first.
713  // If the node is found there, or there is some error,
714  // then we just return either way. But if it comes back
715  // as '0', then nothing happened, and we'll continue executing.
716  //
717  // -- Note you can choose not to call the parent if
718  // you don't want to use any of those xml tags.
719  // As I do below, in the case of OTAccount.
720  // if (nReturnVal = ot_super::ProcessXMLNode(xml))
721  // return nReturnVal;
722 
723  if (strNodeName.Compare("mint")) {
724  OTString strServerID, strServerNymID, strAssetID, strCashAcctID;
725 
726  m_strVersion = xml->getAttributeValue("version");
727  strServerID = xml->getAttributeValue("serverID");
728  strServerNymID = xml->getAttributeValue("serverNymID");
729  strAssetID = xml->getAttributeValue("assetTypeID");
730  strCashAcctID = xml->getAttributeValue("cashAcctID");
731 
732  m_nSeries = atoi(xml->getAttributeValue("series"));
733  m_EXPIRATION =
734  OTTimeGetTimeFromSeconds(xml->getAttributeValue("expiration"));
735 
736  const OTString str_valid_from = xml->getAttributeValue("validFrom");
737  const OTString str_valid_to = xml->getAttributeValue("validTo");
738 
739  m_VALID_FROM = OTTimeGetTimeFromSeconds(str_valid_from.ToLong());
740  m_VALID_TO = OTTimeGetTimeFromSeconds(str_valid_to.ToLong());
741 
742  m_ServerID.SetString(strServerID);
743  m_ServerNymID.SetString(strServerNymID);
744  m_AssetID.SetString(strAssetID);
745  m_CashAccountID.SetString(strCashAcctID);
746 
747  if (m_pReserveAcct) {
748  delete m_pReserveAcct;
749  m_pReserveAcct = nullptr;
750  }
751 
752  // Every Mint has its own cash account. Here we load ours so it's ready
753  // for transactions.
754  if (strCashAcctID.Exists())
757 
758  int64_t nValidFrom = OTTimeGetSecondsFromTime(m_VALID_FROM);
759  int64_t nValidTo = OTTimeGetSecondsFromTime(m_VALID_TO);
760  int64_t nExpiration = OTTimeGetSecondsFromTime(m_EXPIRATION);
761 
762  otWarn <<
763  // "\n===> Loading XML for mint into memory structures..."
764  "\n\nMint version: " << m_strVersion
765  << "\n Server ID: " << strServerID
766  << "\n Asset Type ID: " << strAssetID
767  << "\n Cash Acct ID: " << strCashAcctID << "\n"
768  ""
769  << ((m_pReserveAcct != nullptr) ? "SUCCESS" : "FAILURE")
770  << " loading Cash Account into memory for pointer: "
771  "Mint::m_pReserveAcct\n"
772  " Series: " << m_nSeries << "\n Expiration: " << nExpiration
773  << "\n Valid From: " << nValidFrom << "\n Valid To: " << nValidTo
774  << "\n";
775 
776  nReturnVal = 1;
777  }
778  else if (strNodeName.Compare("mintPublicKey")) {
779  OTASCIIArmor armorPublicKey;
780 
781  if (!OTContract::LoadEncodedTextField(xml, armorPublicKey) ||
782  !armorPublicKey.Exists()) {
783  otErr << "Error in Mint::ProcessXMLNode: mintPublicKey field "
784  "without value.\n";
785  return (-1); // error condition
786  }
787  else {
789  armorPublicKey); // todo check this for failure.
790  }
791 
792  return 1;
793  }
794  else if (strNodeName.Compare("mintPrivateInfo")) {
795  int64_t lDenomination = atol(xml->getAttributeValue("denomination"));
796 
797  OTASCIIArmor* pArmor = new OTASCIIArmor;
798 
799  OT_ASSERT(nullptr != pArmor);
800 
801  if (!OTContract::LoadEncodedTextField(xml, *pArmor) ||
802  !pArmor->Exists()) {
803  otErr << "Error in Mint::ProcessXMLNode: mintPrivateInfo field "
804  "without value.\n";
805 
806  delete pArmor;
807  pArmor = nullptr;
808 
809  return (-1); // error condition
810  }
811  else {
812  m_mapPrivate[lDenomination] = pArmor;
813  }
814 
815  return 1;
816  }
817  else if (strNodeName.Compare("mintPublicInfo")) {
818  int64_t lDenomination = atol(xml->getAttributeValue("denomination"));
819 
820  OTASCIIArmor* pArmor = new OTASCIIArmor;
821 
822  OT_ASSERT(nullptr != pArmor);
823 
824  if (!OTContract::LoadEncodedTextField(xml, *pArmor) ||
825  !pArmor->Exists()) {
826  otErr << "Error in Mint::ProcessXMLNode: mintPublicInfo field "
827  "without value.\n";
828 
829  delete pArmor;
830  pArmor = nullptr;
831 
832  return (-1); // error condition
833  }
834  else {
835  m_mapPublic[lDenomination] = pArmor;
836  m_nDenominationCount++; // Whether client or server, both sides have
837  // public. Each public denomination should
838  // increment this count.
839  }
840 
841  return 1;
842  }
843 
844  return nReturnVal;
845 }
int32_t m_nSeries
Definition: Mint.hpp:186
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
time64_t OTTimeGetTimeFromSeconds(int64_t seconds)
Definition: Common.hpp:215
OTIdentifier m_ServerNymID
Definition: Mint.hpp:169
EXPORT void SetString(const char *szString)
EXPORT bool SetPublicKey(const OTASCIIArmor &strKey)
OTIdentifier m_ServerID
Definition: Mint.hpp:167
static EXPORT bool LoadEncodedTextField(irr::io::IrrXMLReader *&xml, OTASCIIArmor &ascOutput)
OTIdentifier m_CashAccountID
Definition: Mint.hpp:199
mapOfArmor m_mapPrivate
Definition: Mint.hpp:160
#define OT_ASSERT(x)
Definition: Assert.hpp:150
OTIdentifier m_AssetID
Definition: Mint.hpp:174
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
OTLOG_IMPORT OTLogStream otWarn
int32_t m_nDenominationCount
Definition: Mint.hpp:176
OTLOG_IMPORT OTLogStream otErr
time64_t m_VALID_FROM
Definition: Mint.hpp:192
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
mapOfArmor m_mapPublic
Definition: Mint.hpp:164
static EXPORT OTAccount * LoadExistingAccount(const OTIdentifier &accountId, const OTIdentifier &serverId)
Definition: OTAccount.cpp:480
time64_t m_VALID_TO
Definition: Mint.hpp:194
void opentxs::Mint::Release ( )
virtual

Reimplemented from opentxs::OTContract.

Definition at line 272 of file Mint.cpp.

273 {
274  Release_Mint();
275 
276  ot_super::Release(); // I overrode the parent, so now I give him a chance to
277  // clean up.
278 
279  InitMint();
280 }
void Release_Mint()
Definition: Mint.cpp:260
void InitMint()
Definition: Mint.cpp:296
virtual EXPORT void Release()
Definition: OTContract.cpp:277
void opentxs::Mint::Release_Mint ( )

Definition at line 260 of file Mint.cpp.

261 {
263 
265 
266  if (m_pReserveAcct) {
267  delete m_pReserveAcct;
268  m_pReserveAcct = nullptr;
269  }
270 }
void ReleaseDenominations()
Definition: Mint.cpp:237
OTAccount * m_pReserveAcct
Definition: Mint.hpp:202
OTIdentifier m_CashAccountID
Definition: Mint.hpp:199
virtual EXPORT void Release()
Definition: OTData.cpp:257
void opentxs::Mint::ReleaseDenominations ( )

Definition at line 237 of file Mint.cpp.

238 {
239  while (!m_mapPublic.empty()) {
240  OTASCIIArmor* pArmor = m_mapPublic.begin()->second;
241  m_mapPublic.erase(m_mapPublic.begin());
242  delete pArmor;
243  pArmor = nullptr;
244  }
245  while (!m_mapPrivate.empty()) {
246  OTASCIIArmor* pArmor = m_mapPrivate.begin()->second;
247  m_mapPrivate.erase(m_mapPrivate.begin());
248  delete pArmor;
249  pArmor = nullptr;
250  }
251 }
mapOfArmor m_mapPrivate
Definition: Mint.hpp:160
mapOfArmor m_mapPublic
Definition: Mint.hpp:164
bool opentxs::Mint::SaveContractWallet ( std::ofstream &  ofs) const
virtual

Implements opentxs::OTContract.

Definition at line 969 of file Mint.cpp.

970 {
971  return true;
972 }
bool opentxs::Mint::SaveMint ( const char *  szAppend = nullptr)

Definition at line 440 of file Mint.cpp.

441 {
443 
444  const OTString strServerID(m_ServerID), strAssetTypeID(m_AssetID);
445 
446  if (!m_strFilename.Exists()) {
447  if (nullptr != szAppend)
448  m_strFilename.Format("%s%s%s%s", strServerID.Get(),
449  OTLog::PathSeparator(), // server side
450  strAssetTypeID.Get(), szAppend);
451  else
452  m_strFilename.Format("%s%s%s", strServerID.Get(),
454  strAssetTypeID.Get()); // client side
455  }
456 
457  OTString strFilename;
458  if (nullptr != szAppend)
459  strFilename.Format("%s%s", strAssetTypeID.Get(), szAppend);
460  else
461  strFilename = strAssetTypeID.Get();
462 
463  const char* szFolder1name = OTFolders::Mint().Get();
464  const char* szFolder2name = strServerID.Get();
465  const char* szFilename = strFilename.Get();
466 
467  OTString strRawFile;
468 
469  if (!SaveContractRaw(strRawFile)) {
470  otErr << "Mint::SaveMint: Error saving Mintfile (to string):\n"
471  << szFolder1name << OTLog::PathSeparator() << szFolder2name
472  << OTLog::PathSeparator() << szFilename << "\n";
473  return false;
474  }
475 
476  OTString strFinal;
477  OTASCIIArmor ascTemp(strRawFile);
478 
479  if (false ==
480  ascTemp.WriteArmoredString(strFinal, m_strContractType.Get())) {
481  otErr << "Mint::SaveMint: Error saving mint (failed writing armored "
482  "string):\n" << szFolder1name << OTLog::PathSeparator()
483  << szFolder2name << OTLog::PathSeparator() << szFilename << "\n";
484  return false;
485  }
486 
487  bool bSaved =
488  OTDB::StorePlainString(strFinal.Get(), szFolder1name, szFolder2name,
489  szFilename); // <=== SAVING TO LOCAL DATA STORE.
490  if (!bSaved) {
491  if (nullptr != szAppend)
492  otErr << "Mint::SaveMint: Error writing to file: " << szFolder1name
493  << OTLog::PathSeparator() << szFolder2name
494  << OTLog::PathSeparator() << szFilename << szAppend << "\n";
495  else
496  otErr << "Mint::SaveMint: Error writing to file: " << szFolder1name
497  << OTLog::PathSeparator() << szFolder2name
498  << OTLog::PathSeparator() << szFilename << "\n";
499 
500  return false;
501  }
502 
503  return true;
504 }
static EXPORT const OTString & Mint()
Definition: OTFolders.cpp:323
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
Definition: OTStorage.cpp:698
static EXPORT const char * PathSeparator()
Definition: OTLog.cpp:408
EXPORT bool SaveContractRaw(OTString &strOutput) const
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT void Format(const char *fmt,...)
Definition: OTString.cpp:1319
OTIdentifier m_ServerID
Definition: Mint.hpp:167
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
OTIdentifier m_AssetID
Definition: Mint.hpp:174
OTString m_strContractType
Definition: OTContract.hpp:178
EXPORT const char * Get() const
Definition: OTString.cpp:1045
OTLOG_IMPORT OTLogStream otErr
OTString m_strFoldername
Definition: OTContract.hpp:169
void opentxs::Mint::SetAssetID ( const OTIdentifier newID)
inline

Definition at line 294 of file Mint.hpp.

295  {
296  m_AssetID = newID;
297  }
OTIdentifier m_AssetID
Definition: Mint.hpp:174
void opentxs::Mint::SetSavePrivateKeys ( bool  bDoIt = true)
inline

Definition at line 267 of file Mint.hpp.

268  {
269  m_bSavePrivateKeys = bDoIt;
270  }
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
virtual EXPORT bool opentxs::Mint::SignToken ( OTPseudonym theNotary,
Token theToken,
OTString theOutput,
int32_t  nTokenIndex 
)
pure virtual

Implemented in opentxs::MintLucre.

void opentxs::Mint::UpdateContents ( )
virtual

Reimplemented from opentxs::OTContract.

Definition at line 635 of file Mint.cpp.

636 {
637  OT_ASSERT(nullptr != m_pKeyPublic);
638 
639  OTString SERVER_ID(m_ServerID), SERVER_NYM_ID(m_ServerNymID),
640  ASSET_ID(m_AssetID), CASH_ACCOUNT_ID(m_CashAccountID);
641 
642  int64_t lFrom = OTTimeGetSecondsFromTime(m_VALID_FROM);
643  int64_t lTo = OTTimeGetSecondsFromTime(m_VALID_TO);
644  int64_t lExpiration = OTTimeGetSecondsFromTime(m_EXPIRATION);
645 
646  // I release this because I'm about to repopulate it.
648 
649  m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");
650 
651  m_xmlUnsigned.Concatenate("<mint version=\"%s\"\n"
652  " serverID=\"%s\"\n"
653  " serverNymID=\"%s\"\n"
654  " assetTypeID=\"%s\"\n"
655  " cashAcctID=\"%s\"\n"
656  " series=\"%d\"\n"
657  " expiration=\"%" PRId64 "\"\n"
658  " validFrom=\"%" PRId64 "\"\n"
659  " validTo=\"%" PRId64 "\""
660  " >\n\n",
661  m_strVersion.Get(), SERVER_ID.Get(),
662  SERVER_NYM_ID.Get(), ASSET_ID.Get(),
663  CASH_ACCOUNT_ID.Get(), m_nSeries, lExpiration,
664  lFrom, lTo);
665 
666  OTASCIIArmor armorPublicKey;
667  m_pKeyPublic->GetPublicKey(armorPublicKey);
668  m_xmlUnsigned.Concatenate("<mintPublicKey>\n%s</mintPublicKey>\n\n",
669  armorPublicKey.Get());
670 
671  if (m_nDenominationCount) {
672  if (m_bSavePrivateKeys) {
673  m_bSavePrivateKeys = false; // reset this back to false again. Use
674  // SetSavePrivateKeys() to set it true.
675 
676  for (auto& it : m_mapPrivate) {
677  OTASCIIArmor* pArmor = it.second;
678  OT_ASSERT_MSG(nullptr != pArmor, "nullptr private mint pointer "
679  "in "
680  "Mint::UpdateContents.\n");
681 
683  "<mintPrivateInfo denomination=\"%lld\">\n"
684  "%s</mintPrivateInfo>\n\n",
685  it.first, pArmor->Get());
686  }
687  }
688  for (auto& it : m_mapPublic) {
689  OTASCIIArmor* pArmor = it.second;
691  nullptr != pArmor,
692  "nullptr public mint pointer in Mint::UpdateContents.\n");
693 
694  m_xmlUnsigned.Concatenate("<mintPublicInfo denomination=\"%lld\">\n"
695  "%s</mintPublicInfo>\n\n",
696  it.first, pArmor->Get());
697  }
698  }
699 
700  m_xmlUnsigned.Concatenate("</mint>\n");
701 }
int32_t m_nSeries
Definition: Mint.hpp:186
time64_t m_EXPIRATION
Definition: Mint.hpp:196
OTIdentifier m_ServerNymID
Definition: Mint.hpp:169
EXPORT void Concatenate(const char *arg,...)
Definition: OTString.cpp:1334
OTIdentifier m_ServerID
Definition: Mint.hpp:167
EXPORT bool GetPublicKey(OTASCIIArmor &strKey) const
OTIdentifier m_CashAccountID
Definition: Mint.hpp:199
mapOfArmor m_mapPrivate
Definition: Mint.hpp:160
#define OT_ASSERT(x)
Definition: Assert.hpp:150
OTIdentifier m_AssetID
Definition: Mint.hpp:174
#define OT_ASSERT_MSG(x, s)
Definition: Assert.hpp:155
OTAsymmetricKey * m_pKeyPublic
Definition: Mint.hpp:172
OTStringXML m_xmlUnsigned
Definition: OTContract.hpp:174
EXPORT const char * Get() const
Definition: OTString.cpp:1045
int32_t m_nDenominationCount
Definition: Mint.hpp:176
time64_t m_VALID_FROM
Definition: Mint.hpp:192
bool m_bSavePrivateKeys
Definition: Mint.hpp:180
int64_t OTTimeGetSecondsFromTime(time64_t time)
Definition: Common.hpp:230
mapOfArmor m_mapPublic
Definition: Mint.hpp:164
virtual EXPORT void Release()
Definition: OTString.cpp:765
time64_t m_VALID_TO
Definition: Mint.hpp:194
bool opentxs::Mint::VerifyContractID ( ) const
virtual

Reimplemented from opentxs::OTContract.

Definition at line 535 of file Mint.cpp.

536 {
537  // I use the == operator here because there is no != operator at this time.
538  // That's why you see the ! outside the parenthesis.
539  if (!(m_ID == m_AssetID)) {
540  OTString str1(m_ID), str2(m_AssetID);
541 
542  otErr << "\nMint ID does NOT match Asset Type ID in "
543  "Mint::VerifyContractID.\n" << str1 << "\n" << str2 << "\n";
544  // "\nRAW FILE:\n--->" << m_strRawFile << "<---"
545  return false;
546  }
547  else {
548  OTString str1(m_ID);
549  otInfo << "\nMint ID *SUCCESSFUL* match to Asset Contract ID:\n" << str1
550  << "\n\n";
551  return true;
552  }
553 }
OTIdentifier m_AssetID
Definition: Mint.hpp:174
OTLOG_IMPORT OTLogStream otInfo
OTIdentifier m_ID
Definition: OTContract.hpp:172
OTLOG_IMPORT OTLogStream otErr
bool opentxs::Mint::VerifyMint ( const OTPseudonym theOperator)

Definition at line 508 of file Mint.cpp.

509 {
510  // Make sure that the supposed Contract ID that was set is actually
511  // a hash of the contract file, signatures and all.
512  if (!VerifyContractID()) {
513  otErr << "Error comparing Mint ID to Asset Contract ID in "
514  "Mint::VerifyMint\n";
515  return false;
516  }
517  else if (!VerifySignature(theOperator)) {
518  otErr << "Error verifying signature on mint in Mint::VerifyMint.\n";
519  return false;
520  }
521 
522  otLog3 << "\nWe now know that...\n"
523  "1) The Asset Contract ID matches the Mint ID loaded from the "
524  "Mint file.\n"
525  "2) The SIGNATURE VERIFIED.\n\n";
526  return true;
527 }
OTLOG_IMPORT OTLogStream otLog3
OTLOG_IMPORT OTLogStream otErr
virtual bool VerifyContractID() const
Definition: Mint.cpp:535
virtual EXPORT bool VerifySignature(const OTPseudonym &theNym, const OTPasswordData *pPWData=nullptr) const
Definition: OTContract.cpp:818
virtual EXPORT bool opentxs::Mint::VerifyToken ( OTPseudonym theNotary,
OTString theCleartextToken,
int64_t  lDenomination 
)
pure virtual

Implemented in opentxs::MintLucre.

Member Data Documentation

OTIdentifier opentxs::Mint::m_AssetID
protected

Definition at line 174 of file Mint.hpp.

bool opentxs::Mint::m_bSavePrivateKeys
protected

Definition at line 180 of file Mint.hpp.

OTIdentifier opentxs::Mint::m_CashAccountID
protected

Definition at line 199 of file Mint.hpp.

time64_t opentxs::Mint::m_EXPIRATION
protected

Definition at line 196 of file Mint.hpp.

mapOfArmor opentxs::Mint::m_mapPrivate
protected

Definition at line 160 of file Mint.hpp.

mapOfArmor opentxs::Mint::m_mapPublic
protected

Definition at line 164 of file Mint.hpp.

int32_t opentxs::Mint::m_nDenominationCount
protected

Definition at line 176 of file Mint.hpp.

int32_t opentxs::Mint::m_nSeries
protected

Definition at line 186 of file Mint.hpp.

OTAsymmetricKey* opentxs::Mint::m_pKeyPublic
protected

Definition at line 172 of file Mint.hpp.

OTAccount* opentxs::Mint::m_pReserveAcct
protected

Definition at line 202 of file Mint.hpp.

OTIdentifier opentxs::Mint::m_ServerID
protected

Definition at line 167 of file Mint.hpp.

OTIdentifier opentxs::Mint::m_ServerNymID
protected

Definition at line 169 of file Mint.hpp.

time64_t opentxs::Mint::m_VALID_FROM
protected

Definition at line 192 of file Mint.hpp.

time64_t opentxs::Mint::m_VALID_TO
protected

Definition at line 194 of file Mint.hpp.


The documentation for this class was generated from the following files: