Class: XRPL::Transaction
Overview
A transaction, built from the field formats in definitions.json.
The subclasses are not written by hand: one is created for each entry in TRANSACTION_FORMATS when this file loads, so syncing definitions.json updates the models with it and they cannot drift from the ledger.
tx = XRPL::Transaction::Payment.new(
account: wallet.classic_address,
destination: receiver.classic_address,
amount: '1000000'
)
tx.validate!
client.submit_and_wait(tx, wallet: wallet)
Fields are given in snake_case and stored under the ledger's own PascalCase names, so #to_h hands the binary codec exactly what it expects. A plain Hash still works everywhere a transaction is accepted; these classes are an addition, not a replacement. The machinery lives in XRPL::Model and is shared with XRPL::LedgerEntry.
Constant Summary collapse
- COMMON_FORMAT =
Fields every transaction carries, regardless of type.
DEFINITIONS['TRANSACTION_FORMATS'].fetch('common').freeze
- SUPPLIED_LATER =
Required by the format, but supplied by autofill and signing rather than by the caller. Demanding them up front would make #validate! useless at the point where it is actually worth running.
%w[ TransactionType Sequence Fee SigningPubKey TxnSignature LastLedgerSequence ].freeze
Constants inherited from Model
Model::ACCESSOR_TO_FIELD, Model::DEFAULT, Model::DEFINITIONS, Model::FIELD_TO_ACCESSOR, Model::OPTIONAL, Model::REQUIRED
Class Method Summary collapse
Methods inherited from Model
#==, #[], #[]=, define_types!, #flag?, flag_bit, #flag_names, for, from, #hash, #initialize, #inspect, #missing_fields, resolve, #to_blob, #to_h, underscore, #valid?, #validate!
Constructor Details
This class inherits a constructor from XRPL::Model
Class Method Details
.label ⇒ Object
42 43 44 |
# File 'lib/xrpl/transaction.rb', line 42 def label 'transaction' end |
.supplied_later ⇒ Object
46 47 48 |
# File 'lib/xrpl/transaction.rb', line 46 def supplied_later SUPPLIED_LATER end |
.type_field ⇒ Object
38 39 40 |
# File 'lib/xrpl/transaction.rb', line 38 def type_field 'TransactionType' end |