mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Move sources to src and build objs in obj.
This commit is contained in:
56
src/LocalTransaction.cpp
Normal file
56
src/LocalTransaction.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../json/writer.h"
|
||||
|
||||
#include "LocalTransaction.h"
|
||||
#include "Application.h"
|
||||
#include "Wallet.h"
|
||||
|
||||
bool LocalTransaction::makeTransaction()
|
||||
{
|
||||
if(!!mTransaction) return true;
|
||||
|
||||
LocalAccount::pointer lac(theApp->getWallet().findAccountForTransaction(mAmount));
|
||||
if(!lac)
|
||||
{
|
||||
std::cerr << "Account with sufficient balance not found" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
mTransaction=Transaction::pointer(new Transaction(lac, mDestAcctID, mAmount, mTag,
|
||||
theApp->getOPs().getCurrentLedgerID()));
|
||||
if(mTransaction->getStatus()!=NEW)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Status not NEW" << std::endl;
|
||||
Json::Value t=mTransaction->getJson(true);
|
||||
Json::StyledStreamWriter w;
|
||||
w.write(std::cerr, t);
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocalTransaction::performTransaction()
|
||||
{
|
||||
mTransaction=theApp->getOPs().processTransaction(mTransaction);
|
||||
}
|
||||
|
||||
Json::Value LocalTransaction::getJson() const
|
||||
{
|
||||
if(!mTransaction)
|
||||
{ // has no corresponding transaction
|
||||
Json::Value ret(Json::objectValue);
|
||||
ret["Status"]="unfunded";
|
||||
ret["Amount"]=boost::lexical_cast<std::string>(mAmount);
|
||||
Json::Value destination(Json::objectValue);
|
||||
destination["AccountID"]=NewcoinAddress(mDestAcctID).GetString();
|
||||
ret["Destination"]=destination;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return mTransaction->getJson(true, isPaid(), isCredited());
|
||||
}
|
||||
Reference in New Issue
Block a user