133 #include "../core/stdafx.hpp"
140 #include "../core/crypto/OTEnvelope.hpp"
142 #if defined(OT_CASH_USING_LUCRE)
143 #include "../core/crypto/OpenSSL_BIO.hpp"
146 #include "../core/OTLog.hpp"
150 #if defined(OT_CASH_USING_MAGIC_MONEY)
152 #endif // Magic Money
157 #if defined(OT_CASH_USING_LUCRE) && defined(OT_CRYPTO_USING_OPENSSL)
184 int64_t lDenomination,
191 otErr <<
"Token_Lucre::GenerateTokenRequest: Blank token expected.\n";
205 theMint.
GetPublic(ascPublicMint, lDenomination);
208 OTString strPublicMint(ascPublicMint);
213 BIO_puts(bioBank, strPublicMint.
Get());
253 const int32_t nFinalTokenCount =
262 for (int32_t i = 0; i < nFinalTokenCount; i++) {
278 char privateCoinBuffer[4096],
279 publicCoinBuffer[4096];
280 int32_t privatecoinLen = BIO_read(bioCoin, privateCoinBuffer,
285 int32_t publiccoinLen = BIO_read(bioPublicCoin, publicCoinBuffer, 4000);
287 if (privatecoinLen && publiccoinLen) {
291 strPublicCoin.
Set(publicCoinBuffer, publiccoinLen);
293 strPrivateCoin.
Set(privateCoinBuffer, privatecoinLen);
299 ((
nullptr != pArmoredPublic) && (
nullptr != pArmoredPrivate)),
300 "ERROR: Unable to allocate memory in "
301 "Token_Lucre::GenerateTokenRequest\n");
310 theEnvelope.
Seal(theNym, strPrivateCoin);
337 bool bReturnValue =
false;
343 otErr <<
"Signed token expected in Token_Lucre::ProcessToken\n";
352 OpenSSL_BIO bioPrivateRequest = BIO_new(BIO_s_mem());
360 OTString strPublicMint(ascPublicMint);
361 BIO_puts(bioBank, strPublicMint.
Get());
367 BIO_puts(bioSignature, strSignature.Get());
384 theEnvelope.
Open(theNym, strPrototoken);
391 BIO_puts(bioPrivateRequest, strPrototoken.
Get());
405 BIGNUM* bnSignature =
ReadNumber(bioSignature,
"signature=");
418 char CoinBuffer[1024];
420 BIO_read(bioCoin, CoinBuffer, 1000);
428 strCoin.
Set(CoinBuffer, coinLen);
435 theEnvelope.
Seal(theNym, strCoin);
462 #endif // defined(OT_CASH_USING_LUCRE) && defined(OT_CRYPTO_USING_OPENSSL)
static EXPORT int32_t GetMinimumPrototokenCount()
void DumpNumber(BIO *out, const char *szTitle, const BIGNUM *bn, const char *szTrailer=_NL)
BIGNUM * ReadNumber(BIO *in, const char *szTitle)
virtual EXPORT bool GenerateTokenRequest(const OTPseudonym &theNym, Mint &theMint, int64_t lDenomination, int32_t nTokenCount=Token::GetMinimumPrototokenCount())
virtual EXPORT ~Token_Lucre()
EXPORT bool Open(const OTPseudonym &theRecipient, OTString &theOutput, const OTPasswordData *pPWData=nullptr)
EXPORT bool Seal(const OTPseudonym &theRecipient, const OTString &theInput)
int32_t GetSeries() const
EXPORT bool GetPrivatePrototoken(OTASCIIArmor &ascPrototoken, int32_t nTokenIndex)
void SetDenomination(int64_t lVal)
bool GetPublic(OTASCIIArmor &theArmor, int64_t lDenomination)
time64_t GetValidTo() const
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
EXPORT bool GetAsciiArmoredData(OTASCIIArmor &theArmoredText, bool bLineBreaks=true) const
int64_t GetDenomination() const
mapOfPrototokens m_mapPrivate
#define OT_ASSERT_MSG(x, s)
time64_t GetValidFrom() const
void ProcessResponse(Coin *pCoin, PublicBank &bank, BIGNUM *bnSignedCoinRequest)
void SetSeriesAndExpiration(int32_t nSeries, time64_t VALID_FROM, time64_t VALID_TO)
OTASCIIArmor m_ascSpendable
EXPORT const char * Get() const
OTLOG_IMPORT OTLogStream otErr
virtual EXPORT bool ProcessToken(const OTPseudonym &theNym, Mint &theMint, Token &theRequest)
mapOfPrototokens m_mapPublic
virtual EXPORT void Release()