rippled
TxFormats.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/protocol/TxFormats.h>
21 #include <ripple/protocol/jss.h>
22 
23 namespace ripple {
24 
26 {
27  // Fields shared by all txFormats:
28  static const std::initializer_list<SOElement> commonFields{
34  {sfPreviousTxnID, soeOPTIONAL}, // emulate027
37  {sfFee, soeREQUIRED},
42  {sfSigners, soeOPTIONAL}, // submit_multisigned
43  };
44 
45  add(jss::AccountSet,
47  {
58  },
59  commonFields);
60 
61  add(jss::TrustSet,
63  {
68  },
69  commonFields);
70 
71  add(jss::OfferCreate,
73  {
79  },
80  commonFields);
81 
82  add(jss::OfferCancel,
84  {
87  },
88  commonFields);
89 
90  add(jss::SetRegularKey,
92  {
95  },
96  commonFields);
97 
98  add(jss::Payment,
99  ttPAYMENT,
100  {
104  {sfPaths, soeDEFAULT},
109  },
110  commonFields);
111 
112  add(jss::EscrowCreate,
114  {
122  },
123  commonFields);
124 
125  add(jss::EscrowFinish,
127  {
128  {sfOwner, soeREQUIRED},
133  },
134  commonFields);
135 
136  add(jss::EscrowCancel,
138  {
139  {sfOwner, soeREQUIRED},
142  },
143  commonFields);
144 
145  add(jss::EnableAmendment,
146  ttAMENDMENT,
147  {
150  },
151  commonFields);
152 
153  add(jss::SetFee,
154  ttFEE,
155  {
161  },
162  commonFields);
163 
164  add(jss::UNLModify,
165  ttUNL_MODIFY,
166  {
170  },
171  commonFields);
172 
173  add(jss::TicketCreate,
175  {
178  },
179  commonFields);
180 
181  // The SignerEntries are optional because a SignerList is deleted by
182  // setting the SignerQuorum to zero and omitting SignerEntries.
183  add(jss::SignerListSet,
185  {
189  },
190  commonFields);
191 
192  add(jss::PaymentChannelCreate,
194  {
202  },
203  commonFields);
204 
205  add(jss::PaymentChannelFund,
207  {
212  },
213  commonFields);
214 
215  add(jss::PaymentChannelClaim,
217  {
224  },
225  commonFields);
226 
227  add(jss::CheckCreate,
229  {
236  },
237  commonFields);
238 
239  add(jss::CheckCash,
240  ttCHECK_CASH,
241  {
246  },
247  commonFields);
248 
249  add(jss::CheckCancel,
251  {
254  },
255  commonFields);
256 
257  add(jss::AccountDelete,
259  {
263  },
264  commonFields);
265 
266  add(jss::DepositPreauth,
268  {
272  },
273  commonFields);
274 }
275 
276 TxFormats const&
278 {
279  static TxFormats const instance;
280  return instance;
281 }
282 
283 } // namespace ripple
ripple::ttPAYCHAN_CLAIM
@ ttPAYCHAN_CLAIM
Definition: TxFormats.h:51
ripple::ttCHECK_CANCEL
@ ttCHECK_CANCEL
Definition: TxFormats.h:54
ripple::KnownFormats< TxType >::add
Item const & add(char const *name, TxType type, std::initializer_list< SOElement > uniqueFields, std::initializer_list< SOElement > commonFields={})
Add a new format.
Definition: KnownFormats.h:168
ripple::sfRegularKey
const SF_Account sfRegularKey(access, STI_ACCOUNT, 8, "RegularKey")
Definition: SField.h:488
ripple::sfTicketCount
const SF_U32 sfTicketCount(access, STI_UINT32, 40, "TicketCount")
Definition: SField.h:393
ripple::ttACCOUNT_DELETE
@ ttACCOUNT_DELETE
Definition: TxFormats.h:57
ripple::sfQualityIn
const SF_U32 sfQualityIn(access, STI_UINT32, 20, "QualityIn")
Definition: SField.h:373
ripple::sfSigners
const SField sfSigners(access, STI_ARRAY, 3, "Signers", SField::sMD_Default, SField::notSigning)
Definition: SField.h:517
ripple::sfOperationLimit
const SF_U32 sfOperationLimit(access, STI_UINT32, 29, "OperationLimit")
Definition: SField.h:382
ripple::ttOFFER_CREATE
@ ttOFFER_CREATE
Definition: TxFormats.h:43
ripple::sfSigningPubKey
const SF_Blob sfSigningPubKey(access, STI_VL, 3, "SigningPubKey")
Definition: SField.h:460
ripple::sfSignerQuorum
const SF_U32 sfSignerQuorum(access, STI_UINT32, 35, "SignerQuorum")
Definition: SField.h:388
ripple::sfMessageKey
const SF_Blob sfMessageKey(access, STI_VL, 2, "MessageKey")
Definition: SField.h:459
ripple::sfSequence
const SF_U32 sfSequence(access, STI_UINT32, 4, "Sequence")
Definition: SField.h:356
ripple::sfAccount
const SF_Account sfAccount(access, STI_ACCOUNT, 1, "Account")
Definition: SField.h:481
ripple::sfFlags
const SF_U32 sfFlags(access, STI_UINT32, 2, "Flags")
Definition: SField.h:354
ripple::sfWalletLocator
const SF_U256 sfWalletLocator(access, STI_HASH256, 7, "WalletLocator")
Definition: SField.h:425
ripple::sfTakerPays
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
Definition: SField.h:444
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:34
ripple::sfUnauthorize
const SF_Account sfUnauthorize(access, STI_ACCOUNT, 6, "Unauthorize")
Definition: SField.h:486
ripple::sfUNLModifyValidator
const SF_Blob sfUNLModifyValidator(access, STI_VL, 19, "UNLModifyValidator")
Definition: SField.h:476
ripple::sfUNLModifyDisabling
const SF_U8 sfUNLModifyDisabling(access, STI_UINT8, 17, "UNLModifyDisabling")
Definition: SField.h:343
ripple::sfPayChannel
const SF_U256 sfPayChannel(access, STI_HASH256, 22, "Channel")
Definition: SField.h:435
ripple::sfAmount
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
Definition: SField.h:441
ripple::sfSignerEntries
const SField sfSignerEntries(access, STI_ARRAY, 4, "SignerEntries")
Definition: SField.h:518
ripple::sfReserveBase
const SF_U32 sfReserveBase(access, STI_UINT32, 31, "ReserveBase")
Definition: SField.h:384
ripple::sfLimitAmount
const SF_Amount sfLimitAmount(access, STI_AMOUNT, 3, "LimitAmount")
Definition: SField.h:443
ripple::sfFinishAfter
const SF_U32 sfFinishAfter(access, STI_UINT32, 37, "FinishAfter")
Definition: SField.h:390
ripple::sfSignature
const SF_Blob sfSignature(access, STI_VL, 6, "Signature", SField::sMD_Default, SField::notSigning)
Definition: SField.h:462
ripple::sfAccountTxnID
const SF_U256 sfAccountTxnID(access, STI_HASH256, 9, "AccountTxnID")
Definition: SField.h:427
ripple::ttESCROW_FINISH
@ ttESCROW_FINISH
Definition: TxFormats.h:38
ripple::ttPAYMENT
@ ttPAYMENT
Definition: TxFormats.h:36
ripple::sfDestinationTag
const SF_U32 sfDestinationTag(access, STI_UINT32, 14, "DestinationTag")
Definition: SField.h:366
ripple::ttFEE
@ ttFEE
Definition: TxFormats.h:62
ripple::sfFulfillment
const SF_Blob sfFulfillment(access, STI_VL, 16, "Fulfillment")
Definition: SField.h:473
ripple::sfLastLedgerSequence
const SF_U32 sfLastLedgerSequence(access, STI_UINT32, 27, "LastLedgerSequence")
Definition: SField.h:380
ripple::sfOwner
const SF_Account sfOwner(access, STI_ACCOUNT, 2, "Owner")
Definition: SField.h:482
ripple::TxFormats::getInstance
static TxFormats const & getInstance()
Definition: TxFormats.cpp:277
ripple::sfSendMax
const SF_Amount sfSendMax(access, STI_AMOUNT, 9, "SendMax")
Definition: SField.h:449
ripple::ttTRUST_SET
@ ttTRUST_SET
Definition: TxFormats.h:56
ripple::sfAmendment
const SF_U256 sfAmendment(access, STI_HASH256, 19, "Amendment")
Definition: SField.h:433
ripple::soeOPTIONAL
@ soeOPTIONAL
Definition: SOTemplate.h:35
ripple::TxFormats::TxFormats
TxFormats()
Create the object.
Definition: TxFormats.cpp:25
ripple::sfTxnSignature
const SF_Blob sfTxnSignature(access, STI_VL, 4, "TxnSignature", SField::sMD_Default, SField::notSigning)
Definition: SField.h:461
ripple::sfTransactionType
const SF_U16 sfTransactionType(access, STI_UINT16, 2, "TransactionType")
Definition: SField.h:347
ripple::sfLedgerSequence
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
Definition: SField.h:358
ripple::sfReferenceFeeUnits
const SF_U32 sfReferenceFeeUnits(access, STI_UINT32, 30, "ReferenceFeeUnits")
Definition: SField.h:383
ripple::ttCHECK_CASH
@ ttCHECK_CASH
Definition: TxFormats.h:53
ripple::ttTICKET_CREATE
@ ttTICKET_CREATE
Definition: TxFormats.h:46
ripple::ttAMENDMENT
@ ttAMENDMENT
Definition: TxFormats.h:61
ripple::sfSourceTag
const SF_U32 sfSourceTag(access, STI_UINT32, 3, "SourceTag")
Definition: SField.h:355
ripple::sfExpiration
const SF_U32 sfExpiration(access, STI_UINT32, 10, "Expiration")
Definition: SField.h:362
ripple::sfFee
const SF_Amount sfFee(access, STI_AMOUNT, 8, "Fee")
Definition: SField.h:448
ripple::TxFormats
Manages the list of known transaction formats.
Definition: TxFormats.h:68
ripple::ttPAYCHAN_CREATE
@ ttPAYCHAN_CREATE
Definition: TxFormats.h:49
ripple::sfQualityOut
const SF_U32 sfQualityOut(access, STI_UINT32, 21, "QualityOut")
Definition: SField.h:374
ripple::ttESCROW_CREATE
@ ttESCROW_CREATE
Definition: TxFormats.h:37
ripple::ttCHECK_CREATE
@ ttCHECK_CREATE
Definition: TxFormats.h:52
ripple::sfTicketSequence
const SF_U32 sfTicketSequence(access, STI_UINT32, 41, "TicketSequence")
Definition: SField.h:394
ripple::sfPublicKey
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
Definition: SField.h:458
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::sfWalletSize
const SF_U32 sfWalletSize(access, STI_UINT32, 12, "WalletSize")
Definition: SField.h:364
ripple::sfBalance
const SF_Amount sfBalance(access, STI_AMOUNT, 2, "Balance")
Definition: SField.h:442
ripple::ttESCROW_CANCEL
@ ttESCROW_CANCEL
Definition: TxFormats.h:40
ripple::sfDeliverMin
const SF_Amount sfDeliverMin(access, STI_AMOUNT, 10, "DeliverMin")
Definition: SField.h:450
ripple::sfOfferSequence
const SF_U32 sfOfferSequence(access, STI_UINT32, 25, "OfferSequence")
Definition: SField.h:378
ripple::ttACCOUNT_SET
@ ttACCOUNT_SET
Definition: TxFormats.h:39
ripple::sfReserveIncrement
const SF_U32 sfReserveIncrement(access, STI_UINT32, 32, "ReserveIncrement")
Definition: SField.h:385
ripple::ttOFFER_CANCEL
@ ttOFFER_CANCEL
Definition: TxFormats.h:44
ripple::sfClearFlag
const SF_U32 sfClearFlag(access, STI_UINT32, 34, "ClearFlag")
Definition: SField.h:387
ripple::sfCondition
const SF_Blob sfCondition(access, STI_VL, 17, "Condition")
Definition: SField.h:474
ripple::sfPaths
const SField sfPaths(access, STI_PATHSET, 1, "Paths")
Definition: SField.h:491
ripple::sfMemos
const SField sfMemos(access, STI_ARRAY, 9, "Memos")
Definition: SField.h:523
ripple::sfSettleDelay
const SF_U32 sfSettleDelay(access, STI_UINT32, 39, "SettleDelay")
Definition: SField.h:392
ripple::sfTakerGets
const SF_Amount sfTakerGets(access, STI_AMOUNT, 5, "TakerGets")
Definition: SField.h:445
ripple::ttUNL_MODIFY
@ ttUNL_MODIFY
Definition: TxFormats.h:63
ripple::sfDestination
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
Definition: SField.h:483
ripple::sfCheckID
const SF_U256 sfCheckID(access, STI_HASH256, 24, "CheckID")
Definition: SField.h:437
ripple::sfTransferRate
const SF_U32 sfTransferRate(access, STI_UINT32, 11, "TransferRate")
Definition: SField.h:363
ripple::sfBaseFee
const SF_U64 sfBaseFee(access, STI_UINT64, 5, "BaseFee")
Definition: SField.h:401
ripple::sfAuthorize
const SF_Account sfAuthorize(access, STI_ACCOUNT, 5, "Authorize")
Definition: SField.h:485
ripple::ttPAYCHAN_FUND
@ ttPAYCHAN_FUND
Definition: TxFormats.h:50
ripple::ttREGULAR_KEY_SET
@ ttREGULAR_KEY_SET
Definition: TxFormats.h:41
ripple::sfPreviousTxnID
const SF_U256 sfPreviousTxnID(access, STI_HASH256, 5, "PreviousTxnID", SField::sMD_DeleteFinal)
Definition: SField.h:423
ripple::sfCancelAfter
const SF_U32 sfCancelAfter(access, STI_UINT32, 36, "CancelAfter")
Definition: SField.h:389
ripple::ttDEPOSIT_PREAUTH
@ ttDEPOSIT_PREAUTH
Definition: TxFormats.h:55
ripple::soeDEFAULT
@ soeDEFAULT
Definition: SOTemplate.h:36
ripple::sfEmailHash
const SF_U128 sfEmailHash(access, STI_HASH128, 1, "EmailHash")
Definition: SField.h:410
ripple::sfSetFlag
const SF_U32 sfSetFlag(access, STI_UINT32, 33, "SetFlag")
Definition: SField.h:386
ripple::sfTickSize
const SF_U8 sfTickSize(access, STI_UINT8, 16, "TickSize")
Definition: SField.h:342
ripple::sfInvoiceID
const SF_U256 sfInvoiceID(access, STI_HASH256, 17, "InvoiceID")
Definition: SField.h:431
ripple::ttSIGNER_LIST_SET
@ ttSIGNER_LIST_SET
Definition: TxFormats.h:48
std::initializer_list
ripple::sfDomain
const SF_Blob sfDomain(access, STI_VL, 7, "Domain")
Definition: SField.h:463