mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Moved cpp code to src/cpp and js code to src/js.
This commit is contained in:
137
src/cpp/ripple/TransactionFormats.cpp
Normal file
137
src/cpp/ripple/TransactionFormats.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
std::map<int, TransactionFormat*> TransactionFormat::byType;
|
||||
std::map<std::string, TransactionFormat*> TransactionFormat::byName;
|
||||
|
||||
#define TF_BASE \
|
||||
<< SOElement(sfTransactionType, SOE_REQUIRED) \
|
||||
<< SOElement(sfFlags, SOE_REQUIRED) \
|
||||
<< SOElement(sfSourceTag, SOE_OPTIONAL) \
|
||||
<< SOElement(sfAccount, SOE_REQUIRED) \
|
||||
<< SOElement(sfSequence, SOE_REQUIRED) \
|
||||
<< SOElement(sfFee, SOE_REQUIRED) \
|
||||
<< SOElement(sfSigningPubKey, SOE_REQUIRED) \
|
||||
<< SOElement(sfTxnSignature, SOE_OPTIONAL)
|
||||
|
||||
#define DECLARE_TF(name, type) tf = new TransactionFormat(#name, type); (*tf) TF_BASE
|
||||
|
||||
static bool TFInit()
|
||||
{
|
||||
TransactionFormat* tf;
|
||||
|
||||
DECLARE_TF(AccountSet, ttACCOUNT_SET)
|
||||
<< SOElement(sfEmailHash, SOE_OPTIONAL)
|
||||
<< SOElement(sfWalletLocator, SOE_OPTIONAL)
|
||||
<< SOElement(sfWalletSize, SOE_OPTIONAL)
|
||||
<< SOElement(sfMessageKey, SOE_OPTIONAL)
|
||||
<< SOElement(sfDomain, SOE_OPTIONAL)
|
||||
<< SOElement(sfTransferRate, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
DECLARE_TF(Claim, ttCLAIM)
|
||||
<< SOElement(sfGenerator, SOE_REQUIRED)
|
||||
<< SOElement(sfPublicKey, SOE_REQUIRED)
|
||||
<< SOElement(sfSignature, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
DECLARE_TF(CreditSet, ttCREDIT_SET)
|
||||
<< SOElement(sfLimitAmount, SOE_OPTIONAL)
|
||||
<< SOElement(sfQualityIn, SOE_OPTIONAL)
|
||||
<< SOElement(sfQualityOut, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
DECLARE_TF(Invoice, ttINVOICE)
|
||||
<< SOElement(sfTarget, SOE_REQUIRED)
|
||||
<< SOElement(sfAmount, SOE_REQUIRED)
|
||||
<< SOElement(sfDestination, SOE_OPTIONAL)
|
||||
<< SOElement(sfIdentifier, SOE_OPTIONAL)
|
||||
;
|
||||
)
|
||||
*/
|
||||
|
||||
DECLARE_TF(NicknameSet, ttNICKNAME_SET)
|
||||
<< SOElement(sfNickname, SOE_REQUIRED)
|
||||
<< SOElement(sfMinimumOffer, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
DECLARE_TF(OfferCreate, ttOFFER_CREATE)
|
||||
<< SOElement(sfTakerPays, SOE_REQUIRED)
|
||||
<< SOElement(sfTakerGets, SOE_REQUIRED)
|
||||
<< SOElement(sfExpiration, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
DECLARE_TF(OfferCancel, ttOFFER_CANCEL)
|
||||
<< SOElement(sfOfferSequence, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
DECLARE_TF(PasswordFund, ttPASSWORD_FUND)
|
||||
<< SOElement(sfDestination, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
DECLARE_TF(PasswordSet, ttPASSWORD_SET)
|
||||
<< SOElement(sfAuthorizedKey, SOE_REQUIRED)
|
||||
<< SOElement(sfGenerator, SOE_REQUIRED)
|
||||
<< SOElement(sfPublicKey, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
DECLARE_TF(Payment, ttPAYMENT)
|
||||
<< SOElement(sfDestination, SOE_REQUIRED)
|
||||
<< SOElement(sfAmount, SOE_REQUIRED)
|
||||
<< SOElement(sfSendMax, SOE_OPTIONAL)
|
||||
<< SOElement(sfPaths, SOE_OPTIONAL)
|
||||
<< SOElement(sfInvoiceID, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
DECLARE_TF(WalletAdd, ttWALLET_ADD)
|
||||
<< SOElement(sfAmount, SOE_REQUIRED)
|
||||
<< SOElement(sfAuthorizedKey, SOE_REQUIRED)
|
||||
<< SOElement(sfPublicKey, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
DECLARE_TF(Contract, ttCONTRACT)
|
||||
<< SOElement(sfExpiration, SOE_REQUIRED)
|
||||
<< SOElement(sfBondAmount, SOE_REQUIRED)
|
||||
<< SOElement(sfStampEscrow, SOE_REQUIRED)
|
||||
<< SOElement(sfRippleEscrow, SOE_REQUIRED)
|
||||
<< SOElement(sfCreateCode, SOE_OPTIONAL)
|
||||
<< SOElement(sfFundCode, SOE_OPTIONAL)
|
||||
<< SOElement(sfRemoveCode, SOE_OPTIONAL)
|
||||
<< SOElement(sfExpireCode, SOE_OPTIONAL)
|
||||
;
|
||||
|
||||
DECLARE_TF(RemoveContract, ttCONTRACT_REMOVE)
|
||||
<< SOElement(sfTarget, SOE_REQUIRED)
|
||||
;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TFInitComplete = TFInit();
|
||||
|
||||
TransactionFormat* TransactionFormat::getTxnFormat(TransactionType t)
|
||||
{
|
||||
std::map<int, TransactionFormat*>::iterator it = byType.find(static_cast<int>(t));
|
||||
if (it == byType.end())
|
||||
return NULL;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
TransactionFormat* TransactionFormat::getTxnFormat(int t)
|
||||
{
|
||||
std::map<int, TransactionFormat*>::iterator it = byType.find((t));
|
||||
if (it == byType.end())
|
||||
return NULL;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
TransactionFormat* TransactionFormat::getTxnFormat(const std::string& t)
|
||||
{
|
||||
std::map<std::string, TransactionFormat*>::iterator it = byName.find((t));
|
||||
if (it == byName.end())
|
||||
return NULL;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
Reference in New Issue
Block a user