From 4af70eb1285e0705b2d4d81561e23d86a995dcdc Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 18 May 2012 12:46:19 -0700 Subject: [PATCH 1/2] Simply unit test invokation. --- src/main.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 90ff261bb..11008f002 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,15 +120,7 @@ int main(int argc, char* argv[]) } else if (bTest) { - std::vector pvCmd; - - // Copy all but "--test" at argv[1]. - pvCmd.push_back(argv[0]); - - for (int i=1; i++ != argc; ) - pvCmd.push_back(argv[i]); - - iResult = unit_test_main(init_unit_test, pvCmd.size()-1, &pvCmd[0]); + iResult = unit_test_main(init_unit_test, argc, argv); } else if (!vm.count("parameters")) { From 8760a5b3d206a43872d6bc4c96905178776f6a70 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 18 May 2012 19:28:39 -0700 Subject: [PATCH 2/2] Change over to STAmount. --- src/AccountState.h | 2 +- src/Ledger.cpp | 10 +++---- src/Ledger.h | 16 ++++++------ src/LedgerFormats.cpp | 9 +++---- src/RPCServer.cpp | 13 +++++----- src/SerializedLedger.h | 2 +- src/SerializedTransaction.cpp | 8 +++--- src/SerializedTransaction.h | 4 +-- src/SerializedTypes.h | 2 +- src/Transaction.cpp | 24 ++++++++--------- src/Transaction.h | 29 +++++++-------------- src/TransactionEngine.cpp | 49 +++++++++++++++++------------------ src/TransactionFormats.cpp | 5 ++-- 13 files changed, 80 insertions(+), 93 deletions(-) diff --git a/src/AccountState.h b/src/AccountState.h index c6aaf1b3a..3dc17c4fb 100644 --- a/src/AccountState.h +++ b/src/AccountState.h @@ -31,7 +31,7 @@ public: AccountState(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger const NewcoinAddress& getAccountID() const { return mAccountID; } - uint64 getBalance() const { return mLedgerEntry->getIFieldU64(sfBalance); } + STAmount getBalance() const { return mLedgerEntry->getIValueFieldAmount(sfBalance); } uint32 getSeq() const { return mLedgerEntry->getIFieldU32(sfSequence); } SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; } diff --git a/src/Ledger.cpp b/src/Ledger.cpp index d5269a806..5bcc47934 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -26,7 +26,7 @@ Ledger::Ledger(const NewcoinAddress& masterID, uint64 startAmount) : mTotCoins(s // special case: put coins in root account AccountState::pointer startAccount = boost::make_shared(masterID); - startAccount->peekSLE().setIFieldU64(sfBalance, startAmount); + startAccount->peekSLE().setIFieldAmount(sfBalance, startAmount); startAccount->peekSLE().setIFieldU32(sfSequence, 1); writeBack(lepCREATE, startAccount->getSLE()); #ifdef DEBUG @@ -55,7 +55,7 @@ Ledger::Ledger(Ledger::pointer prevLedger) : mParentHash(prevLedger->getHash()), mCloseTime = prevLedger->getNextLedgerClose(); } -Ledger::Ledger(const std::vector& rawLedger) : mTotCoins(0), mCloseTime(0), +Ledger::Ledger(const std::vector& rawLedger) : mCloseTime(0), mLedgerSeq(0), mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true) { Serializer s(rawLedger); @@ -75,7 +75,7 @@ Ledger::Ledger(const std::vector& rawLedger) : mTotCoins(0), mClo } } -Ledger::Ledger(const std::string& rawLedger) : mTotCoins(0), mCloseTime(0), +Ledger::Ledger(const std::string& rawLedger) : mCloseTime(0), mLedgerSeq(0), mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true) { Serializer s(rawLedger); @@ -154,11 +154,11 @@ bool Ledger::addTransaction(Transaction::pointer trans) return true; } -bool Ledger::addTransaction(const uint256& txID, const Serializer& txn, uint64_t fee) +bool Ledger::addTransaction(const uint256& txID, const Serializer& txn, STAmount saPaid) { // low-level - just add to table SHAMapItem::pointer item = boost::make_shared(txID, txn.peekData()); if (!mTransactionMap->addGiveItem(item, true)) return false; - mTotCoins -= fee; + mTotCoins -= saPaid; return true; } diff --git a/src/Ledger.h b/src/Ledger.h index db85840bf..c9e1390b8 100644 --- a/src/Ledger.h +++ b/src/Ledger.h @@ -54,12 +54,12 @@ public: private: - uint256 mHash, mParentHash, mTransHash, mAccountHash; - uint64 mTotCoins; - uint64 mCloseTime; // when this ledger closes - uint32 mLedgerSeq; - uint16 mLedgerInterval; - bool mClosed, mValidHash, mAccepted, mImmutable; + uint256 mHash, mParentHash, mTransHash, mAccountHash; + uint64 mTotCoins; + uint64 mCloseTime; // when this ledger closes + uint32 mLedgerSeq; + uint16 mLedgerInterval; + bool mClosed, mValidHash, mAccepted, mImmutable; SHAMap::pointer mTransactionMap, mAccountStateMap; @@ -71,7 +71,7 @@ private: protected: bool addTransaction(Transaction::pointer); - bool addTransaction(const uint256& id, const Serializer& txn, uint64_t fee); + bool addTransaction(const uint256& id, const Serializer& txn, STAmount saPaid); static Ledger::pointer getSQL(const std::string& sqlStatement); @@ -99,7 +99,7 @@ public: const uint256& getParentHash() const { return mParentHash; } const uint256& getTransHash() const { return mTransHash; } const uint256& getAccountHash() const { return mAccountHash; } - uint64 getTotalCoins() const { return mTotCoins; } + STAmount getTotalCoins() const { return mTotCoins; } uint64 getCloseTimeNC() const { return mCloseTime; } uint32 getLedgerSeq() const { return mLedgerSeq; } uint16 getInterval() const { return mLedgerInterval; } diff --git a/src/LedgerFormats.cpp b/src/LedgerFormats.cpp index 919d73ea5..490a0af40 100644 --- a/src/LedgerFormats.cpp +++ b/src/LedgerFormats.cpp @@ -9,7 +9,7 @@ LedgerEntryFormat LedgerFormats[]= { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 }, - { S_FIELD(Balance), STI_UINT64, SOE_REQUIRED, 0 }, + { S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 }, { S_FIELD(LastReceive), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(LastTxn), STI_UINT32, SOE_REQUIRED, 0 }, { S_FIELD(AuthorizedKey),STI_HASH160, SOE_IFFLAG, 1 }, @@ -39,12 +39,11 @@ LedgerEntryFormat LedgerFormats[]= { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Borrower), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Lender), STI_ACCOUNT, SOE_REQUIRED, 0 }, - { S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 }, { S_FIELD(Limit), STI_AMOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 }, - { S_FIELD(CurrentRate), STI_UINT32, SOE_IFFLAG, 2 }, - { S_FIELD(RateLock), STI_UINT32, SOE_IFFLAG, 4 }, - { S_FIELD(NextRate), STI_UINT32, SOE_IFFLAG, 8 }, + { S_FIELD(CurrentRate), STI_UINT32, SOE_IFFLAG, 1 }, + { S_FIELD(RateLock), STI_UINT32, SOE_IFFLAG, 2 }, + { S_FIELD(NextRate), STI_UINT32, SOE_IFFLAG, 4 }, { S_FIELD(NextRateLgr), STI_UINT32, SOE_IFFLAG, 8 }, { S_FIELD(NextRateExp), STI_UINT32, SOE_IFFLAG, 16 }, { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 }, diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 104d87037..f0ef1ad8f 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -618,7 +618,7 @@ Json::Value RPCServer::doWalletClaim(Json::Value& params) naRegular0Public.getAccountPublic(), vucGeneratorSig); - (void) theApp->getOPs().processTransaction(trns); + // (void) theApp->getOPs().processTransaction(trns); Json::Value obj(Json::objectValue); @@ -691,10 +691,11 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params) return "source account does not exist"; } - uint64 uSrcBalance = sleSrc->getIFieldU64(sfBalance); - uint64 uInitialFunds = (params.size() < 4) ? 0 : boost::lexical_cast(params[3u].asString()); + STAmount saSrcBalance = sleSrc->getIValueFieldAmount(sfBalance); + STAmount saInitialFunds = (params.size() < 4) ? 0 : boost::lexical_cast(params[3u].asString()); - if (uSrcBalance < theConfig.FEE_CREATE + uInitialFunds) +#if 0 + if (saSrcBalance < theConfig.FEE_CREATE + saInitialFunds) { return "insufficent funds"; } @@ -702,7 +703,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params) { return "source account has not been claimed"; } - +#endif NewcoinAddress naRegularGenerator; NewcoinAddress naRegular0Public; NewcoinAddress naRegular0Private; @@ -765,7 +766,7 @@ Json::Value RPCServer::doWalletCreate(Json::Value& params) theConfig.FEE_CREATE, 0, // YYY No source tag naCreateID, - uInitialFunds); // Initial funds in XNC. + saInitialFunds); // Initial funds in XNC. (void) theApp->getOPs().processTransaction(trans); diff --git a/src/SerializedLedger.h b/src/SerializedLedger.h index 925704968..f858629e2 100644 --- a/src/SerializedLedger.h +++ b/src/SerializedLedger.h @@ -69,7 +69,7 @@ public: { return mObject.setValueFieldAccount(field, account); } void setIFieldAccount(SOE_Field field, const NewcoinAddress& account) { return mObject.setValueFieldAccount(field, account); } - void setIFeldAmount(SOE_Field field, const STAmount& amount) + void setIFieldAmount(SOE_Field field, const STAmount& amount) { return mObject.setValueFieldAmount(field, amount); } bool getIFieldPresent(SOE_Field field) const { return mObject.isFieldPresent(field); } diff --git a/src/SerializedTransaction.cpp b/src/SerializedTransaction.cpp index a007be112..bfa342a5e 100644 --- a/src/SerializedTransaction.cpp +++ b/src/SerializedTransaction.cpp @@ -160,18 +160,18 @@ void SerializedTransaction::setVersion(uint32 ver) v->setValue(ver); } -uint64 SerializedTransaction::getTransactionFee() const +STAmount SerializedTransaction::getTransactionFee() const { - const STUInt64* v = dynamic_cast(mMiddleTxn.peekAtPIndex(TransactionIFee)); + const STAmount* v = dynamic_cast(mMiddleTxn.peekAtPIndex(TransactionIFee)); if (!v) throw std::runtime_error("corrupt transaction"); return v->getValue(); } -void SerializedTransaction::setTransactionFee(uint64 fee) +void SerializedTransaction::setTransactionFee(STAmount saFee) { STUInt64* v = dynamic_cast(mMiddleTxn.getPIndex(TransactionIFee)); if (!v) throw std::runtime_error("corrupt transaction"); - v->setValue(fee); + v->setValue(saFee); } uint32 SerializedTransaction::getSequence() const diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index 587387e73..5becb4fe0 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -48,8 +48,8 @@ public: void setVersion(uint32); TransactionType getTxnType() const { return mType; } - uint64 getTransactionFee() const; - void setTransactionFee(uint64); + STAmount getTransactionFee() const; + void setTransactionFee(STAmount saFee); const NewcoinAddress& getSourceAccount() const { return mSourceAccount; } std::vector getSigningPubKey() const; diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index 57b94b0db..b10a9cbdc 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -258,7 +258,7 @@ public: friend STAmount divide(const STAmount& v1, const STAmount& v2, const uint160& currencyOut); friend STAmount multiply(const STAmount& v1, const STAmount& v2, const uint160& currencyOut); - // Someone iis offering X for Y, what is the rate? + // Someone is offering X for Y, what is the rate? friend uint64 getRate(const STAmount& offerOut, const STAmount& offerIn); // Someone is offering X for Y, I try to pay Z, how much do I get? diff --git a/src/Transaction.cpp b/src/Transaction.cpp index 78f6357ae..d7ffcbf24 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -56,7 +56,7 @@ Transaction::Transaction( const NewcoinAddress& naPublicKey, const NewcoinAddress& naSourceAccount, uint32 uSeq, - uint64 uFee, + STAmount saFee, uint32 uSourceTag) : mStatus(NEW) { @@ -71,7 +71,7 @@ Transaction::Transaction( mTransaction->setSigningPubKey(mFromPubKey); mTransaction->setSourceAccount(mAccountFrom); mTransaction->setSequence(uSeq); - mTransaction->setTransactionFee(uFee); + mTransaction->setTransactionFee(saFee); if (uSourceTag) { @@ -155,7 +155,7 @@ Transaction::pointer Transaction::sharedClaim( Transaction::pointer Transaction::setCreate( const NewcoinAddress& naPrivateKey, const NewcoinAddress& naCreateAccountID, - uint64 uFund) + STAmount uFund) { mTransaction->setITFieldU32(sfFlags, tfCreateAccount); mTransaction->setITFieldAccount(sfDestination, naCreateAccountID); @@ -170,14 +170,14 @@ Transaction::pointer Transaction::sharedCreate( const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naSourceAccount, uint32 uSeq, - uint64 uFee, + STAmount saFee, uint32 uSourceTag, const NewcoinAddress& naCreateAccountID, - uint64 uFund) + STAmount uFund) { pointer tResult = boost::make_shared(ttPAYMENT, naPublicKey, naSourceAccount, - uSeq, uFee, uSourceTag); + uSeq, saFee, uSourceTag); return tResult->setCreate(naPrivateKey, naCreateAccountID, uFund); } @@ -189,10 +189,10 @@ Transaction::pointer Transaction::sharedCreate( Transaction::pointer Transaction::setPayment( const NewcoinAddress& naPrivateKey, const NewcoinAddress& toAccount, - uint64 uAmount) + STAmount saAmount) { mTransaction->setITFieldAccount(sfDestination, toAccount); - mTransaction->setITFieldU64(sfAmount, uAmount); + mTransaction->setITFieldU64(sfAmount, saAmount); sign(naPrivateKey); @@ -203,16 +203,16 @@ Transaction::pointer Transaction::sharedPayment( const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naSourceAccount, uint32 uSeq, - uint64 uFee, + STAmount saFee, uint32 uSourceTag, const NewcoinAddress& toAccount, - uint64 uAmount) + STAmount saAmount) { pointer tResult = boost::make_shared(ttPAYMENT, naPublicKey, naSourceAccount, - uSeq, uFee, uSourceTag); + uSeq, saFee, uSourceTag); - return tResult->setPayment(naPrivateKey, toAccount, uAmount); + return tResult->setPayment(naPrivateKey, toAccount, saAmount); } // diff --git a/src/Transaction.h b/src/Transaction.h index 3f114e0b7..9bd65e705 100644 --- a/src/Transaction.h +++ b/src/Transaction.h @@ -56,12 +56,12 @@ private: Transaction::pointer setCreate( const NewcoinAddress& naPrivateKey, const NewcoinAddress& naCreateAccountID, - uint64 uFund); + STAmount uFund); Transaction::pointer setPayment( const NewcoinAddress& naPrivateKey, const NewcoinAddress& toAccount, - uint64 uAmount); + STAmount saAmount); public: Transaction(const SerializedTransaction::pointer st, bool bValidate); @@ -73,7 +73,7 @@ public: const NewcoinAddress& naPublicKey, // To prove transaction is consistent and authorized. const NewcoinAddress& naSourceAccount, // To identify the paying account. uint32 uSeq, // To order transactions. - uint64 uFee, // Transaction fee. + STAmount saFee, // Transaction fee. uint32 uSourceTag); // User call back value. // Claim a wallet. @@ -90,26 +90,20 @@ public: const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naSourceAccount, uint32 uSeq, - uint64 uFee, + STAmount saFee, uint32 uSourceTag, const NewcoinAddress& naCreateAccountID, // Account to create. - uint64 uFund); // Initial funds in XNC. + STAmount uFund); // Initial funds in XNC. // Make a payment. static Transaction::pointer sharedPayment( const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey, const NewcoinAddress& naSourceAccount, uint32 uSeq, - uint64 uFee, + STAmount saFee, uint32 uSourceTag, const NewcoinAddress& toAccount, - uint64 uAmount); - -#if 0 - Transaction(const NewcoinAddress& fromID, const NewcoinAddress& toID, - CKey::pointer pubKey, uint64 uAmount, uint64 fee, uint32 fromSeq, uint32 fromLedger, - uint32 ident, const std::vector& signature, uint32 ledgerSeq, TransStatus st); -#endif + STAmount saAmount); bool sign(const NewcoinAddress& naAccountPrivate); bool checkSign() const; @@ -119,8 +113,8 @@ public: const uint256& getID() const { return mTransactionID; } const NewcoinAddress& getFromAccount() const { return mAccountFrom; } - uint64 getAmount() const { return mTransaction->getITFieldU64(sfAmount); } - uint64 getFee() const { return mTransaction->getTransactionFee(); } + STAmount getAmount() const { return mTransaction->getITFieldU64(sfAmount); } + STAmount getFee() const { return mTransaction->getTransactionFee(); } uint32 getFromAccountSeq() const { return mTransaction->getSequence(); } uint32 getSourceLedger() const { return mTransaction->getITFieldU32(sfTargetLedger); } uint32 getIdent() const { return mTransaction->getITFieldU32(sfSourceTag); } @@ -155,11 +149,6 @@ public: protected: static Transaction::pointer transactionFromSQL(const std::string& statement); -#if 0 - Transaction(const uint256& transactionID, const NewcoinAddress& accountFrom, const NewcoinAddress& accountTo, - CKey::pointer key, uint64 uAmount, uint64 fee, uint32 fromAccountSeq, uint32 sourceLedger, - uint32 ident, const std::vector& signature, uint32 inLedger, TransStatus status); -#endif }; #endif diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index 6c2f1a363..c907819f6 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -35,19 +35,19 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran return tenINVALID; } - uint64 uFee = theConfig.FEE_DEFAULT; + STAmount saCost = theConfig.FEE_DEFAULT; // Customize behavoir based on transaction type. switch(txn.getTxnType()) { case ttCLAIM: - uFee = 0; + saCost = 0; break; case ttPAYMENT: if (txn.getFlags() & tfCreateAccount) { - uFee = theConfig.FEE_CREATE; + saCost = theConfig.FEE_CREATE; } break; @@ -70,13 +70,12 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran if (terSUCCESS != result) return result; - uint64 txnFee = txn.getTransactionFee(); + STAmount saPaid = txn.getTransactionFee(); if ( (params & tepNO_CHECK_FEE) != tepNONE) { - if (uFee) + if (saCost) { - // WRITEME: Check if fee is adequate - if (txnFee == 0) + if (saPaid < saCost) { std::cerr << "applyTransaction: insufficient fee" << std::endl; return tenINSUF_FEE_P; @@ -84,7 +83,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran } else { - if (txnFee) + if (!saPaid.isZero()) { // Transaction is malformed. std::cerr << "applyTransaction: fee not allowed" << std::endl; @@ -105,9 +104,9 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran // find source account // If we are only verifying some transactions, this would be probablistic. - LedgerStateParms qry = lepNONE; - SerializedLedgerEntry::pointer src = mLedger->getAccountRoot(qry, srcAccountID); - if (!src) + LedgerStateParms qry = lepNONE; + SerializedLedgerEntry::pointer sleSrc = mLedger->getAccountRoot(qry, srcAccountID); + if (!sleSrc) { std::cerr << str(boost::format("applyTransaction: Delay transaction: source account does not exisit: %s") % txn.getSourceAccount().humanAccountID()) << std::endl; return terNO_ACCOUNT; @@ -115,25 +114,25 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran // deduct the fee, so it's not available during the transaction // we only write the account back if the transaction succeeds - if (txnFee) + if (!saCost.isZero()) { - uint64 uSrcBalance = src->getIFieldU64(sfBalance); + STAmount saSrcBalance = sleSrc->getIValueFieldAmount(sfBalance); - if (uSrcBalance < txnFee) + if (saSrcBalance < saPaid) { std::cerr << "applyTransaction: Delay transaction: insufficent balance" << std::endl; return terINSUF_FEE_B; } - src->setIFieldU64(sfBalance, uSrcBalance - txnFee); + sleSrc->setIFieldAmount(sfBalance, saSrcBalance - saPaid); } // Validate sequence uint32 t_seq = txn.getSequence(); - if (uFee) + if (saCost) { - uint32 a_seq = src->getIFieldU32(sfSequence); + uint32 a_seq = sleSrc->getIFieldU32(sfSequence); if (t_seq != a_seq) { @@ -152,7 +151,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran std::cerr << "applyTransaction: past sequence number" << std::endl; return terPAST_SEQ; } - else src->setIFieldU32(sfSequence, t_seq); + else sleSrc->setIFieldU32(sfSequence, t_seq); } else { @@ -164,7 +163,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran } std::vector accounts; - accounts.push_back(std::make_pair(taaMODIFY, src)); + accounts.push_back(std::make_pair(taaMODIFY, sleSrc)); switch(txn.getTxnType()) { @@ -219,7 +218,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran Serializer s; txn.add(s); - mLedger->addTransaction(txID, s, txnFee); + mLedger->addTransaction(txID, s, saPaid); } return result; @@ -384,20 +383,20 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction accounts.push_back(std::make_pair(taaMODIFY, dest)); } - uint64 uAmount = txn.getITFieldU64(sfAmount); + STAmount saAmount = txn.getITFieldAmount(sfAmount); if (!currency) { - uint64 uSrcBalance = accounts[0].second->getIFieldU64(sfBalance); + STAmount saSrcBalance = accounts[0].second->getIValueFieldAmount(sfBalance); - if (uSrcBalance < uAmount) + if (saSrcBalance < saAmount) { std::cerr << "doPayment: Delay transaction: Insufficent funds." << std::endl; return terUNFUNDED; } - accounts[0].second->setIFieldU64(sfBalance, uSrcBalance - uAmount); - accounts[1].second->setIFieldU64(sfBalance, accounts[1].second->getIFieldU64(sfBalance) + uAmount); + accounts[0].second->setIFieldAmount(sfBalance, saSrcBalance - saAmount); + accounts[1].second->setIFieldAmount(sfBalance, accounts[1].second->getIValueFieldAmount(sfBalance) + saAmount); } else { diff --git a/src/TransactionFormats.cpp b/src/TransactionFormats.cpp index 902aff111..a53f89857 100644 --- a/src/TransactionFormats.cpp +++ b/src/TransactionFormats.cpp @@ -9,9 +9,8 @@ TransactionFormat InnerTxnFormats[]= { S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 }, { S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 }, { S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 }, - { S_FIELD(Currency), STI_HASH160, SOE_IFFLAG, 1 }, - { S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 2 }, - { S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 4 }, + { S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 }, + { S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 2 }, { S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } } },