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 
22 #include <ripple/protocol/SField.h>
23 #include <ripple/protocol/SOTemplate.h>
24 #include <ripple/protocol/jss.h>
25 
26 namespace ripple {
27 
29 {
30 #pragma push_macro("PSEUDO_TXN_COMMON_FIELDS")
31 
32  // clang-format off
33 
34  #define PSEUDO_TXN_COMMON_FIELDS \
35  {sfTransactionType, soeREQUIRED}, \
36  {sfFlags, soeOPTIONAL}, \
37  {sfSourceTag, soeOPTIONAL}, \
38  {sfAccount, soeREQUIRED}, \
39  {sfSequence, soeREQUIRED}, \
40  {sfPreviousTxnID, soeOPTIONAL}, /* emulate027 */ \
41  {sfLastLedgerSequence, soeOPTIONAL}, \
42  {sfAccountTxnID, soeOPTIONAL}, \
43  {sfFee, soeREQUIRED}, \
44  {sfOperationLimit, soeOPTIONAL}, \
45  {sfMemos, soeOPTIONAL}, \
46  {sfSigningPubKey, soeREQUIRED}, \
47  {sfTxnSignature, soeOPTIONAL}, \
48  {sfSigners, soeOPTIONAL}, /* submit_multisigned */ \
49  {sfNetworkID, soeOPTIONAL}
50 
51  // clang-format on
52 
53  // Fields shared by all pseudo-transaction txFormats:
54  static const std::initializer_list<SOElement> pseudoCommonFields{
55  PSEUDO_TXN_COMMON_FIELDS,
56  };
57 
58  // Fields shared by all normal transaction txFormats:
59  static const std::initializer_list<SOElement> commonFields{
60  PSEUDO_TXN_COMMON_FIELDS,
62  };
63 
64 #pragma pop_macro("PSEUDO_TXN_COMMON_FIELDS")
65 
66  add(jss::AccountSet,
68  {
79  },
80  commonFields);
81 
82  add(jss::TrustSet,
84  {
88  },
89  commonFields);
90 
91  add(jss::OfferCreate,
93  {
98  },
99  commonFields);
100 
101  add(jss::AMMCreate,
102  ttAMM_CREATE,
103  {
107  },
108  commonFields);
109 
110  add(jss::AMMDeposit,
112  {
113  {sfAsset, soeREQUIRED},
120  },
121  commonFields);
122 
123  add(jss::AMMWithdraw,
125  {
126  {sfAsset, soeREQUIRED},
132  },
133  commonFields);
134 
135  add(jss::AMMVote,
136  ttAMM_VOTE,
137  {
138  {sfAsset, soeREQUIRED},
141  },
142  commonFields);
143 
144  add(jss::AMMBid,
145  ttAMM_BID,
146  {
147  {sfAsset, soeREQUIRED},
152  },
153  commonFields);
154 
155  add(jss::AMMDelete,
156  ttAMM_DELETE,
157  {
158  {sfAsset, soeREQUIRED},
160  },
161  commonFields);
162 
163  add(jss::OfferCancel,
165  {
167  },
168  commonFields);
169 
170  add(jss::SetRegularKey,
172  {
174  },
175  commonFields);
176 
177  add(jss::Payment,
178  ttPAYMENT,
179  {
183  {sfPaths, soeDEFAULT},
187  },
188  commonFields);
189 
190  add(jss::EscrowCreate,
192  {
199  },
200  commonFields);
201 
202  add(jss::EscrowFinish,
204  {
205  {sfOwner, soeREQUIRED},
209  },
210  commonFields);
211 
212  add(jss::EscrowCancel,
214  {
215  {sfOwner, soeREQUIRED},
217  },
218  commonFields);
219 
220  add(jss::EnableAmendment,
221  ttAMENDMENT,
222  {
225  },
226  pseudoCommonFields);
227 
228  add(jss::SetFee,
229  ttFEE,
230  {
232  // Old version uses raw numbers
237  // New version uses Amounts
241  },
242  pseudoCommonFields);
243 
244  add(jss::UNLModify,
245  ttUNL_MODIFY,
246  {
250  },
251  pseudoCommonFields);
252 
253  add(jss::TicketCreate,
255  {
257  },
258  commonFields);
259 
260  // The SignerEntries are optional because a SignerList is deleted by
261  // setting the SignerQuorum to zero and omitting SignerEntries.
262  add(jss::SignerListSet,
264  {
267  },
268  commonFields);
269 
270  add(jss::PaymentChannelCreate,
272  {
279  },
280  commonFields);
281 
282  add(jss::PaymentChannelFund,
284  {
288  },
289  commonFields);
290 
291  add(jss::PaymentChannelClaim,
293  {
299  },
300  commonFields);
301 
302  add(jss::CheckCreate,
304  {
310  },
311  commonFields);
312 
313  add(jss::CheckCash,
314  ttCHECK_CASH,
315  {
319  },
320  commonFields);
321 
322  add(jss::CheckCancel,
324  {
326  },
327  commonFields);
328 
329  add(jss::AccountDelete,
331  {
334  },
335  commonFields);
336 
337  add(jss::DepositPreauth,
339  {
342  },
343  commonFields);
344 
345  add(jss::NFTokenMint,
347  {
351  {sfURI, soeOPTIONAL},
352  },
353  commonFields);
354 
355  add(jss::NFTokenBurn,
357  {
359  {sfOwner, soeOPTIONAL},
360  },
361  commonFields);
362 
363  add(jss::NFTokenCreateOffer,
365  {
369  {sfOwner, soeOPTIONAL},
371  },
372  commonFields);
373 
374  add(jss::NFTokenCancelOffer,
376  {
378  },
379  commonFields);
380 
381  add(jss::NFTokenAcceptOffer,
383  {
387  },
388  commonFields);
389 
390  add(jss::Clawback,
391  ttCLAWBACK,
392  {
394  },
395  commonFields);
396 
397  add(jss::XChainCreateBridge,
399  {
403  },
404  commonFields);
405 
406  add(jss::XChainModifyBridge,
408  {
412  },
413  commonFields);
414 
415  add(jss::XChainCreateClaimID,
417  {
421  },
422  commonFields);
423 
424  add(jss::XChainCommit,
426  {
431  },
432  commonFields);
433 
434  add(jss::XChainClaim,
436  {
442  },
443  commonFields);
444 
445  add(jss::XChainAddClaimAttestation,
447  {
449 
457 
460  },
461  commonFields);
462 
463  add(jss::XChainAddAccountCreateAttestation,
465  {
467 
475 
479  },
480  commonFields);
481 
482  add(jss::XChainAccountCreateCommit,
484  {
489  },
490  commonFields);
491 }
492 
493 TxFormats const&
495 {
496  static TxFormats const instance;
497  return instance;
498 }
499 
500 } // namespace ripple
ripple::ttNFTOKEN_CREATE_OFFER
@ ttNFTOKEN_CREATE_OFFER
This transaction creates a new offer to buy or sell an NFT.
Definition: TxFormats.h:134
ripple::sfOfferSequence
const SF_UINT32 sfOfferSequence
ripple::ttACCOUNT_DELETE
@ ttACCOUNT_DELETE
This transaction type deletes an existing account.
Definition: TxFormats.h:122
ripple::sfPaths
const SField sfPaths
ripple::sfUNLModifyValidator
const SF_VL sfUNLModifyValidator
ripple::sfBaseFeeDrops
const SF_AMOUNT sfBaseFeeDrops
ripple::sfReserveBase
const SF_UINT32 sfReserveBase
ripple::ttAMM_DELETE
@ ttAMM_DELETE
This transaction type deletes AMM in the empty state.
Definition: TxFormats.h:161
ripple::sfAsset
const SF_ISSUE sfAsset
ripple::sfSendMax
const SF_AMOUNT sfSendMax
ripple::sfLedgerSequence
const SF_UINT32 sfLedgerSequence
ripple::sfNFTokenOffers
const SF_VECTOR256 sfNFTokenOffers
ripple::sfDestination
const SF_ACCOUNT sfDestination
ripple::ttREGULAR_KEY_SET
@ ttREGULAR_KEY_SET
This transaction type sets or clears an account's "regular key".
Definition: TxFormats.h:74
ripple::sfAmount2
const SF_AMOUNT sfAmount2
ripple::sfAmount
const SF_AMOUNT sfAmount
ripple::ttCLAWBACK
@ ttCLAWBACK
This transaction claws back issued tokens.
Definition: TxFormats.h:143
ripple::sfNFTokenID
const SF_UINT256 sfNFTokenID
ripple::sfWalletSize
const SF_UINT32 sfWalletSize
ripple::sfCheckID
const SF_UINT256 sfCheckID
ripple::ttSIGNER_LIST_SET
@ ttSIGNER_LIST_SET
This transaction type modifies the signer list associated with an account.
Definition: TxFormats.h:95
ripple::ttXCHAIN_CLAIM
@ ttXCHAIN_CLAIM
This transaction completes a crosschain transaction.
Definition: TxFormats.h:170
ripple::sfQualityOut
const SF_UINT32 sfQualityOut
ripple::sfOwner
const SF_ACCOUNT sfOwner
ripple::sfRegularKey
const SF_ACCOUNT sfRegularKey
ripple::ttESCROW_CANCEL
@ ttESCROW_CANCEL
This transaction type cancels an existing escrow.
Definition: TxFormats.h:71
ripple::ttXCHAIN_CREATE_BRIDGE
@ ttXCHAIN_CREATE_BRIDGE
This transactions creates a sidechain.
Definition: TxFormats.h:185
ripple::sfEPrice
const SF_AMOUNT sfEPrice
ripple::ttFEE
@ ttFEE
This system-generated transaction type is used to update the network's fee settings.
Definition: TxFormats.h:198
ripple::ttAMM_DEPOSIT
@ ttAMM_DEPOSIT
This transaction type deposits into an AMM instance.
Definition: TxFormats.h:149
ripple::ttOFFER_CANCEL
@ ttOFFER_CANCEL
This transaction type cancels existing offers to trade one asset for another.
Definition: TxFormats.h:83
ripple::ttPAYCHAN_CREATE
@ ttPAYCHAN_CREATE
This transaction type creates a new unidirectional XRP payment channel.
Definition: TxFormats.h:98
ripple::sfOtherChainSource
const SF_ACCOUNT sfOtherChainSource
ripple::sfQualityIn
const SF_UINT32 sfQualityIn
ripple::sfSetFlag
const SF_UINT32 sfSetFlag
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:35
ripple::sfTicketSequence
const SF_UINT32 sfTicketSequence
ripple::sfWasLockingChainSend
const SF_UINT8 sfWasLockingChainSend
ripple::ttXCHAIN_CREATE_CLAIM_ID
@ ttXCHAIN_CREATE_CLAIM_ID
This transactions creates a crosschain sequence number.
Definition: TxFormats.h:164
ripple::ttNFTOKEN_ACCEPT_OFFER
@ ttNFTOKEN_ACCEPT_OFFER
This transaction accepts an existing offer to buy or sell an existing NFT.
Definition: TxFormats.h:140
ripple::sfLPTokenOut
const SF_AMOUNT sfLPTokenOut
ripple::ttAMENDMENT
@ ttAMENDMENT
This system-generated transaction type is used to update the status of the various amendments.
Definition: TxFormats.h:192
ripple::sfTradingFee
const SF_UINT16 sfTradingFee
ripple::sfXChainClaimID
const SF_UINT64 sfXChainClaimID
ripple::sfTransferFee
const SF_UINT16 sfTransferFee
ripple::ttCHECK_CANCEL
@ ttCHECK_CANCEL
This transaction type cancels an existing check.
Definition: TxFormats.h:113
ripple::sfExpiration
const SF_UINT32 sfExpiration
ripple::sfSignerQuorum
const SF_UINT32 sfSignerQuorum
ripple::ttPAYMENT
@ ttPAYMENT
This transaction type executes a payment.
Definition: TxFormats.h:59
ripple::sfTakerPays
const SF_AMOUNT sfTakerPays
ripple::sfDeliverMin
const SF_AMOUNT sfDeliverMin
ripple::sfLimitAmount
const SF_AMOUNT sfLimitAmount
ripple::sfAsset2
const SF_ISSUE sfAsset2
ripple::ttUNL_MODIFY
@ ttUNL_MODIFY
This system-generated transaction type is used to update the network's negative UNL.
Definition: TxFormats.h:204
ripple::sfSettleDelay
const SF_UINT32 sfSettleDelay
ripple::sfSignatureReward
const SF_AMOUNT sfSignatureReward
ripple::sfUnauthorize
const SF_ACCOUNT sfUnauthorize
ripple::sfBidMax
const SF_AMOUNT sfBidMax
ripple::ttCHECK_CREATE
@ ttCHECK_CREATE
This transaction type creates a new check.
Definition: TxFormats.h:107
ripple::ttXCHAIN_COMMIT
@ ttXCHAIN_COMMIT
This transactions initiates a crosschain transaction.
Definition: TxFormats.h:167
ripple::TxFormats::getInstance
static TxFormats const & getInstance()
Definition: TxFormats.cpp:494
ripple::sfNFTokenMinter
const SF_ACCOUNT sfNFTokenMinter
ripple::ttAMM_CREATE
@ ttAMM_CREATE
This transaction type creates an AMM instance.
Definition: TxFormats.h:146
ripple::ttTRUST_SET
@ ttTRUST_SET
This transaction type modifies a trustline between two accounts.
Definition: TxFormats.h:119
ripple::sfReserveIncrement
const SF_UINT32 sfReserveIncrement
ripple::soeOPTIONAL
@ soeOPTIONAL
Definition: SOTemplate.h:36
ripple::sfAuthAccounts
const SField sfAuthAccounts
ripple::TxFormats::TxFormats
TxFormats()
Create the object.
Definition: TxFormats.cpp:28
ripple::ttNFTOKEN_MINT
@ ttNFTOKEN_MINT
This transaction mints a new NFT.
Definition: TxFormats.h:128
ripple::ttESCROW_CREATE
@ ttESCROW_CREATE
This transaction type creates an escrow object.
Definition: TxFormats.h:62
ripple::ttXCHAIN_MODIFY_BRIDGE
@ ttXCHAIN_MODIFY_BRIDGE
This transaction modifies a sidechain.
Definition: TxFormats.h:182
ripple::sfTicketCount
const SF_UINT32 sfTicketCount
ripple::ttAMM_WITHDRAW
@ ttAMM_WITHDRAW
This transaction type withdraws from an AMM instance.
Definition: TxFormats.h:152
ripple::ttESCROW_FINISH
@ ttESCROW_FINISH
This transaction type completes an existing escrow.
Definition: TxFormats.h:65
ripple::sfTakerGets
const SF_AMOUNT sfTakerGets
ripple::sfTransferRate
const SF_UINT32 sfTransferRate
ripple::sfTickSize
const SF_UINT8 sfTickSize
ripple::sfAttestationSignerAccount
const SF_ACCOUNT sfAttestationSignerAccount
ripple::sfAuthorize
const SF_ACCOUNT sfAuthorize
ripple::ttXCHAIN_ACCOUNT_CREATE_COMMIT
@ ttXCHAIN_ACCOUNT_CREATE_COMMIT
This transaction initiates a crosschain account create transaction.
Definition: TxFormats.h:173
ripple::sfReserveIncrementDrops
const SF_AMOUNT sfReserveIncrementDrops
ripple::sfClearFlag
const SF_UINT32 sfClearFlag
ripple::sfBidMin
const SF_AMOUNT sfBidMin
ripple::TxFormats
Manages the list of known transaction formats.
Definition: TxFormats.h:210
ripple::sfReserveBaseDrops
const SF_AMOUNT sfReserveBaseDrops
ripple::ttNFTOKEN_CANCEL_OFFER
@ ttNFTOKEN_CANCEL_OFFER
This transaction cancels an existing offer to buy or sell an existing NFT.
Definition: TxFormats.h:137
ripple::ttOFFER_CREATE
@ ttOFFER_CREATE
This transaction type creates an offer to trade one asset for another.
Definition: TxFormats.h:80
ripple::sfUNLModifyDisabling
const SF_UINT8 sfUNLModifyDisabling
ripple::sfEmailHash
const SF_UINT128 sfEmailHash
ripple::ttACCOUNT_SET
@ ttACCOUNT_SET
This transaction type adjusts various account settings.
Definition: TxFormats.h:68
ripple::sfSignerEntries
const SField sfSignerEntries
ripple::sfBaseFee
const SF_UINT64 sfBaseFee
ripple::sfNFTokenBuyOffer
const SF_UINT256 sfNFTokenBuyOffer
ripple::sfURI
const SF_VL sfURI
ripple::sfMinAccountCreateAmount
const SF_AMOUNT sfMinAccountCreateAmount
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::sfWalletLocator
const SF_UINT256 sfWalletLocator
ripple::sfCondition
const SF_VL sfCondition
ripple::sfIssuer
const SF_ACCOUNT sfIssuer
ripple::ttDEPOSIT_PREAUTH
@ ttDEPOSIT_PREAUTH
This transaction type grants or revokes authorization to transfer funds.
Definition: TxFormats.h:116
ripple::sfInvoiceID
const SF_UINT256 sfInvoiceID
ripple::sfDestinationTag
const SF_UINT32 sfDestinationTag
ripple::sfOtherChainDestination
const SF_ACCOUNT sfOtherChainDestination
ripple::ttCHECK_CASH
@ ttCHECK_CASH
This transaction type cashes an existing check.
Definition: TxFormats.h:110
ripple::sfXChainAccountCreateCount
const SF_UINT64 sfXChainAccountCreateCount
ripple::sfSignature
const SF_VL sfSignature
ripple::ttPAYCHAN_FUND
@ ttPAYCHAN_FUND
This transaction type funds an existing unidirectional XRP payment channel.
Definition: TxFormats.h:101
ripple::sfBalance
const SF_AMOUNT sfBalance
ripple::sfReferenceFeeUnits
const SF_UINT32 sfReferenceFeeUnits
ripple::ttAMM_VOTE
@ ttAMM_VOTE
This transaction type votes for the trading fee.
Definition: TxFormats.h:155
ripple::ttPAYCHAN_CLAIM
@ ttPAYCHAN_CLAIM
This transaction type submits a claim against an existing unidirectional payment channel.
Definition: TxFormats.h:104
ripple::sfCancelAfter
const SF_UINT32 sfCancelAfter
ripple::sfMessageKey
const SF_VL sfMessageKey
ripple::ttNFTOKEN_BURN
@ ttNFTOKEN_BURN
This transaction burns (i.e.
Definition: TxFormats.h:131
ripple::sfFinishAfter
const SF_UINT32 sfFinishAfter
ripple::sfChannel
const SF_UINT256 sfChannel
ripple::sfNFTokenTaxon
const SF_UINT32 sfNFTokenTaxon
ripple::sfAttestationRewardAccount
const SF_ACCOUNT sfAttestationRewardAccount
ripple::sfLPTokenIn
const SF_AMOUNT sfLPTokenIn
ripple::sfDomain
const SF_VL sfDomain
ripple::sfAmendment
const SF_UINT256 sfAmendment
ripple::sfXChainBridge
const SF_XCHAIN_BRIDGE sfXChainBridge
ripple::sfFulfillment
const SF_VL sfFulfillment
ripple::sfPublicKey
const SF_VL sfPublicKey
ripple::ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION
@ ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION
This transaction adds an attestation to a claimid.
Definition: TxFormats.h:179
ripple::sfNFTokenSellOffer
const SF_UINT256 sfNFTokenSellOffer
ripple::ttTICKET_CREATE
@ ttTICKET_CREATE
This transaction type creates a new set of tickets.
Definition: TxFormats.h:89
ripple::soeDEFAULT
@ soeDEFAULT
Definition: SOTemplate.h:37
ripple::sfNFTokenBrokerFee
const SF_AMOUNT sfNFTokenBrokerFee
ripple::KnownFormats< TxType, TxFormats >::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:170
ripple::ttAMM_BID
@ ttAMM_BID
This transaction type bids for the auction slot.
Definition: TxFormats.h:158
std::initializer_list
ripple::ttXCHAIN_ADD_CLAIM_ATTESTATION
@ ttXCHAIN_ADD_CLAIM_ATTESTATION
This transaction adds an attestation to a claimid.
Definition: TxFormats.h:176