mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
More toward using STAmount.
This commit is contained in:
@@ -99,7 +99,7 @@ public:
|
|||||||
const uint256& getParentHash() const { return mParentHash; }
|
const uint256& getParentHash() const { return mParentHash; }
|
||||||
const uint256& getTransHash() const { return mTransHash; }
|
const uint256& getTransHash() const { return mTransHash; }
|
||||||
const uint256& getAccountHash() const { return mAccountHash; }
|
const uint256& getAccountHash() const { return mAccountHash; }
|
||||||
STAmount getTotalCoins() const { return mTotCoins; }
|
uint64 getTotalCoins() const { return mTotCoins; }
|
||||||
uint64 getCloseTimeNC() const { return mCloseTime; }
|
uint64 getCloseTimeNC() const { return mCloseTime; }
|
||||||
uint32 getLedgerSeq() const { return mLedgerSeq; }
|
uint32 getLedgerSeq() const { return mLedgerSeq; }
|
||||||
uint16 getInterval() const { return mLedgerInterval; }
|
uint16 getInterval() const { return mLedgerInterval; }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
|
|||||||
mMiddleTxn.giveObject(new STAccount("SourceAccount"));
|
mMiddleTxn.giveObject(new STAccount("SourceAccount"));
|
||||||
mMiddleTxn.giveObject(new STUInt32("Sequence"));
|
mMiddleTxn.giveObject(new STUInt32("Sequence"));
|
||||||
mMiddleTxn.giveObject(new STUInt8("Type", static_cast<unsigned char>(type)));
|
mMiddleTxn.giveObject(new STUInt8("Type", static_cast<unsigned char>(type)));
|
||||||
mMiddleTxn.giveObject(new STUInt64("Fee"));
|
mMiddleTxn.giveObject(new STAmount("Fee"));
|
||||||
|
|
||||||
mInnerTxn=STObject(mFormat->elements, "InnerTransaction");
|
mInnerTxn=STObject(mFormat->elements, "InnerTransaction");
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit, int length
|
|||||||
mMiddleTxn.giveObject(new STUInt32("Type", static_cast<uint32>(mType)));
|
mMiddleTxn.giveObject(new STUInt32("Type", static_cast<uint32>(mType)));
|
||||||
mFormat = getTxnFormat(mType);
|
mFormat = getTxnFormat(mType);
|
||||||
if (!mFormat) throw std::runtime_error("Transaction has invalid type");
|
if (!mFormat) throw std::runtime_error("Transaction has invalid type");
|
||||||
mMiddleTxn.giveObject(new STUInt64("Fee", sit.get64()));
|
mMiddleTxn.giveObject(new STAmount("Fee", sit.get64()));
|
||||||
|
|
||||||
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
|
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ STAmount SerializedTransaction::getTransactionFee() const
|
|||||||
|
|
||||||
void SerializedTransaction::setTransactionFee(STAmount saFee)
|
void SerializedTransaction::setTransactionFee(STAmount saFee)
|
||||||
{
|
{
|
||||||
STUInt64* v = dynamic_cast<STUInt64*>(mMiddleTxn.getPIndex(TransactionIFee));
|
STAmount* v = dynamic_cast<STAmount*>(mMiddleTxn.getPIndex(TransactionIFee));
|
||||||
if (!v) throw std::runtime_error("corrupt transaction");
|
if (!v) throw std::runtime_error("corrupt transaction");
|
||||||
v->setValue(saFee);
|
v->setValue(saFee);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ public:
|
|||||||
|
|
||||||
int getOffset() const { return mOffset; }
|
int getOffset() const { return mOffset; }
|
||||||
uint64 getValue() const { return mValue; }
|
uint64 getValue() const { return mValue; }
|
||||||
|
void setValue(const STAmount& v) { mValue=v; }
|
||||||
bool isNative() const { return mIsNative; }
|
bool isNative() const { return mIsNative; }
|
||||||
const uint160& getCurrency() const { return mCurrency; }
|
const uint160& getCurrency() const { return mCurrency; }
|
||||||
void zero() { mOffset = mIsNative ? -100 : 0; mValue = 0; }
|
void zero() { mOffset = mIsNative ? -100 : 0; mValue = 0; }
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ Transaction::pointer Transaction::setCreate(
|
|||||||
{
|
{
|
||||||
mTransaction->setITFieldU32(sfFlags, tfCreateAccount);
|
mTransaction->setITFieldU32(sfFlags, tfCreateAccount);
|
||||||
mTransaction->setITFieldAccount(sfDestination, naCreateAccountID);
|
mTransaction->setITFieldAccount(sfDestination, naCreateAccountID);
|
||||||
mTransaction->setITFieldU64(sfAmount, uFund);
|
mTransaction->setITFieldAmount(sfAmount, uFund);
|
||||||
|
|
||||||
sign(naPrivateKey);
|
sign(naPrivateKey);
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ Transaction::pointer Transaction::setPayment(
|
|||||||
STAmount saAmount)
|
STAmount saAmount)
|
||||||
{
|
{
|
||||||
mTransaction->setITFieldAccount(sfDestination, toAccount);
|
mTransaction->setITFieldAccount(sfDestination, toAccount);
|
||||||
mTransaction->setITFieldU64(sfAmount, saAmount);
|
mTransaction->setITFieldAmount(sfAmount, saAmount);
|
||||||
|
|
||||||
sign(naPrivateKey);
|
sign(naPrivateKey);
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,11 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
|||||||
|
|
||||||
if (saSrcBalance < saPaid)
|
if (saSrcBalance < saPaid)
|
||||||
{
|
{
|
||||||
std::cerr << "applyTransaction: Delay transaction: insufficent balance" << std::endl;
|
std::cerr
|
||||||
|
<< str(boost::format("applyTransaction: Delay transaction: insufficent balance: balance=%s paid=%s")
|
||||||
|
% saSrcBalance
|
||||||
|
% saPaid)
|
||||||
|
<< std::endl;
|
||||||
return terINSUF_FEE_B;
|
return terINSUF_FEE_B;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user