140 #include <irrxml/irrXML.hpp>
190 const OTString strServerID(theServerID);
191 bool bNeedToSave =
false;
195 const uint32_t nCount =
static_cast<uint32_t
>(
Count());
197 for (uint32_t i = 0; i < nCount; i++) {
209 theServerID, lClosingTransNo,
false);
211 if (bClawedBack) bNeedToSave =
true;
221 const bool bClawedBack =
224 if (bClawedBack) bNeedToSave =
true;
230 if (bSave && bNeedToSave) {
240 const int64_t& lClosingTransactionNo)
245 "Error allocating memory in Basket::AddRequestSubContract\n");
266 int64_t lMinimumTransferAmount)
271 "Error allocating memory in Basket::AddSubContract\n");
288 "Basket::GetClosingTransactionNoAt: index out of bounds.");
292 OT_ASSERT_MSG(
nullptr != pItem,
"Basket::GetClosingTransactionNoAt: basket "
293 "item was nullptr at that index.");
313 const OTString strNodeName(xml->getNodeName());
315 if (strNodeName.Compare(
"currencyBasket")) {
317 strSubCount = xml->getAttributeValue(
"contractCount");
318 strMinTrans = xml->getAttributeValue(
"minimumTransfer");
323 otWarn <<
"Loading currency basket...\n";
327 else if (strNodeName.Compare(
"requestExchange")) {
328 OTString strTransferMultiple, strRequestAccountID, strDirection,
331 strTransferMultiple = xml->getAttributeValue(
"transferMultiple");
332 strRequestAccountID = xml->getAttributeValue(
"transferAccountID");
333 strDirection = xml->getAttributeValue(
"direction");
334 strTemp = xml->getAttributeValue(
"closingTransactionNo");
336 if (strTransferMultiple.
Exists())
338 if (strRequestAccountID.
Exists())
344 <<
". Direction is " << strDirection <<
". Closing number is "
346 << strRequestAccountID <<
"\n";
350 else if (strNodeName.Compare(
"basketItem")) {
354 "Error allocating memory in Basket::ProcessXMLNode\n");
358 strTemp = xml->getAttributeValue(
"minimumTransfer");
362 strTemp = xml->getAttributeValue(
"closingTransactionNo");
366 OTString strSubAccountID(xml->getAttributeValue(
"accountID")),
367 strContractID(xml->getAttributeValue(
"assetID"));
373 otInfo <<
"Loaded basket item.\n";
388 void Basket::GenerateContents(
OTStringXML& xmlUnsigned,
389 bool bHideAccountID)
const
394 xmlUnsigned.
Concatenate(
"<currencyBasket contractCount=\"%d\"\n"
395 " minimumTransfer=\"%lld\" >\n\n",
405 "transferMultiple=\"%d\"\n "
406 "transferAccountID=\"%s\"\n "
407 "closingTransactionNo=\"%lld\"\n "
408 "direction=\"%s\" />\n\n",
414 for (int32_t i = 0; i <
Count(); i++) {
418 "Error allocating memory in Basket::UpdateContents\n");
420 OTString strAcctID(pItem->SUB_ACCOUNT_ID),
421 strContractID(pItem->SUB_CONTRACT_ID);
425 "<basketItem minimumTransfer=\"%lld\"\n"
426 " closingTransactionNo=\"%lld\"\n"
427 " accountID=\"%s\"\n"
428 " assetID=\"%s\" />\n\n",
429 pItem->lMinimumTransferAmount, pItem->lClosingTransactionNo,
430 bHideAccountID ?
"" : strAcctID.Get(), strContractID.Get());
432 xmlUnsigned.
Concatenate(
"<basketItem minimumTransfer=\"%lld\"\n"
433 " accountID=\"%s\"\n"
434 " assetID=\"%s\" />\n\n",
435 pItem->lMinimumTransferAmount,
436 bHideAccountID ?
"" : strAcctID.Get(),
437 strContractID.Get());
455 GenerateContents(xmlUnsigned,
true);
462 , m_nSubCount(nCount)
463 , m_lMinimumTransfer(lMinimumTransferAmount)
464 , m_nTransferMultiple(0)
465 , m_bHideAccountID(false)
466 , m_bExchangingIn(false)
467 , m_lClosingTransactionNo(0)
474 , m_lMinimumTransfer(0)
475 , m_nTransferMultiple(0)
476 , m_bHideAccountID(false)
477 , m_bExchangingIn(false)
478 , m_lClosingTransactionNo(0)
int64_t m_lClosingTransactionNo
EXPORT void AddRequestSubContract(const OTIdentifier &SUB_CONTRACT_ID, const OTIdentifier &SUB_ACCOUNT_ID, const int64_t &lClosingTransactionNo)
EXPORT bool CalculateDigest(const OTData &dataInput)
EXPORT bool ClawbackTransactionNumber(const OTIdentifier &theServerID, const int64_t &lTransClawback, bool bSave=false, OTPseudonym *pSIGNER_NYM=nullptr)
int64_t lClosingTransactionNo
bool IsExchanging() const
EXPORT void Concatenate(const char *arg,...)
int64_t GetClosingNum() const
EXPORT bool Exists() const
EXPORT void SetString(const char *szString)
int64_t m_lMinimumTransfer
virtual void UpdateContents()
EXPORT bool Compare(const char *compare) const
virtual EXPORT void CalculateContractID(OTIdentifier &newID) const
virtual int32_t ProcessXMLNode(irr::io::IrrXMLReader *&xml)
virtual bool SaveContractWallet(std::ofstream &ofs) const
dequeOfBasketItems m_dequeItems
#define OT_ASSERT_MSG(x, s)
EXPORT BasketItem * At(uint32_t nIndex)
OTLOG_IMPORT OTLogStream otInfo
OTStringXML m_xmlUnsigned
OTLOG_IMPORT OTLogStream otWarn
int32_t m_nTransferMultiple
EXPORT void HarvestClosingNumbers(OTPseudonym &theNym, const OTIdentifier &theServerID, bool bSave=true)
EXPORT const char * Get() const
OTIdentifier SUB_ACCOUNT_ID
virtual EXPORT void Release()
OTIdentifier SUB_CONTRACT_ID
void SetClosingNum(const int64_t &lClosingNum)
virtual EXPORT void Release()
int64_t GetClosingTransactionNoAt(uint32_t nIndex)
virtual EXPORT void Release()
EXPORT void AddSubContract(const OTIdentifier &SUB_CONTRACT_ID, int64_t lMinimumTransferAmount)
OTIdentifier m_RequestAccountID
EXPORT bool SaveSignedNymfile(OTPseudonym &SIGNER_NYM)
EXPORT int32_t Count() const
int64_t lMinimumTransferAmount