diff --git a/Transaction.cpp b/Transaction.cpp index 21f3b3d8e6..a9736da240 100644 --- a/Transaction.cpp +++ b/Transaction.cpp @@ -1,3 +1,5 @@ +#include + #include "boost/lexical_cast.hpp" #include "Application.h" @@ -16,15 +18,27 @@ Transaction::Transaction() : mTransactionID(0), mAccountFrom(0), mAccountTo(0), Transaction::Transaction(LocalAccount::pointer fromLocalAccount, const uint160& toAccount, uint64 amount, uint32 ident, uint32 ledger) : - mAccountTo(toAccount), mAmount(amount), mSourceLedger(ledger), mIdent(ident), mInLedger(0), mStatus(NEW) + mAccountTo(toAccount), mAmount(amount), mSourceLedger(ledger), mIdent(ident), mInLedger(0), mStatus(NEW) { mAccountFrom=fromLocalAccount->getAddress(); mFromPubKey=fromLocalAccount->getPublicKey(); mFromAccountSeq=fromLocalAccount->getAcctSeq(); - if(!mFromAccountSeq) mStatus=INCOMPLETE; + if(!mFromAccountSeq) + { +#ifdef DEBUG + std::cerr << "Bad source account sequence" << std::endl; +#endif + mStatus=INCOMPLETE; + } assert(mFromPubKey); updateFee(); - if(!sign(fromLocalAccount)) mStatus=INCOMPLETE; + if(!sign(fromLocalAccount)) + { +#ifdef DEBUG + std::cerr << "Unable to sign transaction" << std::endl; +#endif + mStatus=INCOMPLETE; + } } Transaction::Transaction(const std::vector &t, bool validate) : mStatus(INVALID) @@ -54,15 +68,27 @@ Transaction::Transaction(const std::vector &t, bool validate) : m bool Transaction::sign(LocalAccount::pointer fromLocalAccount) { CKey::pointer privateKey=fromLocalAccount->getPrivateKey(); - if(!privateKey) return false; + if(!privateKey) + { +#ifdef DEBUG + std::cerr << "No private key for signing" << std::endl; +#endif + return false; + } if( (mAmount==0) || (mSourceLedger==0) || (mAccountTo==0) ) { +#ifdef DEBUG + std::cerr << "Bad amount, source ledger, or destination" << std::endl; +#endif assert(false); return false; } if(mAccountFrom!=fromLocalAccount->getAddress()) { +#ifdef DEBUG + std::cerr << "Source mismatch" << std::endl; +#endif assert(false); return false; } @@ -70,6 +96,9 @@ bool Transaction::sign(LocalAccount::pointer fromLocalAccount) assert(signBuf->getLength()==73+4); if(!signBuf->makeSignature(mSignature, *privateKey)) { +#ifdef DEBUG + std::cerr << "Failed to make signature" << std::endl; +#endif assert(false); return false; } diff --git a/Wallet.cpp b/Wallet.cpp index 5d558c610c..29ac97b325 100644 --- a/Wallet.cpp +++ b/Wallet.cpp @@ -100,7 +100,13 @@ void LocalAccountFamily::lock() CKey::pointer LocalAccountFamily::getPrivateKey(int seq) { - if(!mRootPrivateKey) return CKey::pointer(); + if(!mRootPrivateKey) + { +#ifdef DEBUG + std::cerr << "Cannot get private key from loced family" << std::endl; +#endif + return CKey::pointer(); + } return CKey::pointer(new CKey(mFamily, mRootPrivateKey, seq)); } @@ -383,6 +389,13 @@ Json::Value LocalAccount::getJson() const ret["FullName"]=getFullName(); ret["Issued"]=Json::Value(isIssued()); ret["IsLocked"]=mFamily->isLocked(); + + uint64 eb=getBalance(); + if(eb!=0) ret["Balance"]=boost::lexical_cast(eb); + + uint32 sq=getAcctSeq(); + if(sq!=0) ret["TxnSeq"]=boost::lexical_cast(sq); + return ret; }