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  {
57  },
58  commonFields);
59 
60  add(jss::TrustSet,
62  {
66  },
67  commonFields);
68 
69  add(jss::OfferCreate,
71  {
76  },
77  commonFields);
78 
79  add(jss::OfferCancel,
81  {
83  },
84  commonFields);
85 
86  add(jss::SetRegularKey,
88  {
90  },
91  commonFields);
92 
93  add(jss::Payment,
94  ttPAYMENT,
95  {
103  },
104  commonFields);
105 
106  add(jss::EscrowCreate,
108  {
115  },
116  commonFields);
117 
118  add(jss::EscrowFinish,
120  {
121  {sfOwner, soeREQUIRED},
125  },
126  commonFields);
127 
128  add(jss::EscrowCancel,
130  {
131  {sfOwner, soeREQUIRED},
133  },
134  commonFields);
135 
136  add(jss::EnableAmendment,
137  ttAMENDMENT,
138  {
141  },
142  commonFields);
143 
144  add(jss::SetFee,
145  ttFEE,
146  {
152  },
153  commonFields);
154 
155  add(jss::UNLModify,
156  ttUNL_MODIFY,
157  {
161  },
162  commonFields);
163 
164  add(jss::TicketCreate,
166  {
169  },
170  commonFields);
171 
172  add(jss::TicketCancel,
174  {
176  },
177  commonFields);
178 
179  // The SignerEntries are optional because a SignerList is deleted by
180  // setting the SignerQuorum to zero and omitting SignerEntries.
181  add(jss::SignerListSet,
183  {
186  },
187  commonFields);
188 
189  add(jss::PaymentChannelCreate,
191  {
198  },
199  commonFields);
200 
201  add(jss::PaymentChannelFund,
203  {
207  },
208  commonFields);
209 
210  add(jss::PaymentChannelClaim,
212  {
218  },
219  commonFields);
220 
221  add(jss::CheckCreate,
223  {
229  },
230  commonFields);
231 
232  add(jss::CheckCash,
233  ttCHECK_CASH,
234  {
238  },
239  commonFields);
240 
241  add(jss::CheckCancel,
243  {
245  },
246  commonFields);
247 
248  add(jss::AccountDelete,
250  {
253  },
254  commonFields);
255 
256  add(jss::DepositPreauth,
258  {
261  },
262  commonFields);
263 }
264 
265 TxFormats const&
267 {
268  static TxFormats const instance;
269  return instance;
270 }
271 
272 } // 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:155
ripple::sfRegularKey
const SF_Account sfRegularKey(access, STI_ACCOUNT, 8, "RegularKey")
Definition: SField.h:487
ripple::ttACCOUNT_DELETE
@ ttACCOUNT_DELETE
Definition: TxFormats.h:57
ripple::sfTarget
const SF_Account sfTarget(access, STI_ACCOUNT, 7, "Target")
Definition: SField.h:486
ripple::sfTicketID
const SF_U256 sfTicketID(access, STI_HASH256, 20, "TicketID")
Definition: SField.h:432
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:516
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:459
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:458
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:480
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:423
ripple::sfTakerPays
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
Definition: SField.h:443
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:34
ripple::sfUnauthorize
const SF_Account sfUnauthorize(access, STI_ACCOUNT, 6, "Unauthorize")
Definition: SField.h:485
ripple::sfUNLModifyValidator
const SF_Blob sfUNLModifyValidator(access, STI_VL, 19, "UNLModifyValidator")
Definition: SField.h:475
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:434
ripple::sfAmount
const SF_Amount sfAmount(access, STI_AMOUNT, 1, "Amount")
Definition: SField.h:440
ripple::sfSignerEntries
const SField sfSignerEntries(access, STI_ARRAY, 4, "SignerEntries")
Definition: SField.h:517
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:442
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:461
ripple::sfAccountTxnID
const SF_U256 sfAccountTxnID(access, STI_HASH256, 9, "AccountTxnID")
Definition: SField.h:425
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:60
ripple::sfFulfillment
const SF_Blob sfFulfillment(access, STI_VL, 16, "Fulfillment")
Definition: SField.h:472
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:481
ripple::TxFormats::getInstance
static TxFormats const & getInstance()
Definition: TxFormats.cpp:266
ripple::sfSendMax
const SF_Amount sfSendMax(access, STI_AMOUNT, 9, "SendMax")
Definition: SField.h:448
ripple::ttTRUST_SET
@ ttTRUST_SET
Definition: TxFormats.h:56
ripple::sfAmendment
const SF_U256 sfAmendment(access, STI_HASH256, 19, "Amendment")
Definition: SField.h:431
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:460
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:59
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:447
ripple::TxFormats
Manages the list of known transaction formats.
Definition: TxFormats.h:66
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::sfPublicKey
const SF_Blob sfPublicKey(access, STI_VL, 1, "PublicKey")
Definition: SField.h:457
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::ttTICKET_CANCEL
@ ttTICKET_CANCEL
Definition: TxFormats.h:47
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:441
ripple::ttESCROW_CANCEL
@ ttESCROW_CANCEL
Definition: TxFormats.h:40
ripple::sfDeliverMin
const SF_Amount sfDeliverMin(access, STI_AMOUNT, 10, "DeliverMin")
Definition: SField.h:449
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:473
ripple::sfPaths
const SField sfPaths(access, STI_PATHSET, 1, "Paths")
Definition: SField.h:490
ripple::sfMemos
const SField sfMemos(access, STI_ARRAY, 9, "Memos")
Definition: SField.h:522
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:444
ripple::ttUNL_MODIFY
@ ttUNL_MODIFY
Definition: TxFormats.h:61
ripple::sfDestination
const SF_Account sfDestination(access, STI_ACCOUNT, 3, "Destination")
Definition: SField.h:482
ripple::sfCheckID
const SF_U256 sfCheckID(access, STI_HASH256, 24, "CheckID")
Definition: SField.h:436
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:399
ripple::sfAuthorize
const SF_Account sfAuthorize(access, STI_ACCOUNT, 5, "Authorize")
Definition: SField.h:484
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:421
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:408
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:429
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:462