Module _c

Source
Expand description

§Low-level unsafe C bindings

Use very carefully if at all necessary.

Constants§

ALREADY_SET
COMPARE_EQUAL
COMPARE_GREATER
COMPARE_LESS
DOESNT_EXIST
EMISSION_FAILURE
ENCODE_ACCOUNT_DST_SIZE
ENCODE_ACCOUNT_SIZE
ENCODE_ACCOUNT_SRC_SIZE
ENCODE_DROPS_SIZE
ENCODE_FLAGS_SIZE
ENCODE_FLS_SIZE
ENCODE_LLS_SIZE
ENCODE_SEQUENCE_SIZE
ENCODE_SIGNING_PUBKEY_NULL_SIZE
ENCODE_SIGNING_PUBKEY_SIZE
ENCODE_TAG_DST_SIZE
ENCODE_TAG_SRC_SIZE
ENCODE_TL_SIZE
ENCODE_TT_SIZE
ENCODE_UINT32_COMMON_SIZE
ENCODE_UINT32_UNCOMMON_SIZE
FEE_TOO_LARGE
GUARD_VIOLATION
HOOKAPI_INCLUDED
HOOKMACROS_INCLUDED
INT8_MAX
INT8_MIN
INT16_MAX
INT16_MIN
INT32_MAX
INT32_MIN
INTERNAL_ERROR
INTPTR_MAX
INTPTR_MIN
INT_FAST8_MAX
INT_FAST8_MIN
INT_FAST16_MAX
INT_FAST16_MIN
INT_FAST32_MAX
INT_FAST32_MIN
INT_LEAST8_MAX
INT_LEAST8_MIN
INT_LEAST16_MAX
INT_LEAST16_MIN
INT_LEAST32_MAX
INT_LEAST32_MIN
INVALID_ACCOUNT
INVALID_ARGUMENT
INVALID_FIELD
INVALID_FLOAT
KEYLET_ACCOUNT
KEYLET_AMENDMENTS
KEYLET_CHECK
KEYLET_CHILD
KEYLET_DEPOSIT_PREAUTH
KEYLET_EMITTED
KEYLET_EMITTED_DIR
KEYLET_ESCROW
KEYLET_FEES
KEYLET_HOOK
KEYLET_HOOK_STATE
KEYLET_LINE
KEYLET_NEGATIVE_UNL
KEYLET_OFFER
KEYLET_OWNER_DIR
KEYLET_PAGE
KEYLET_PAYCHAN
KEYLET_QUALITY
KEYLET_SIGNERS
KEYLET_SKIP
KEYLET_TICKET
KEYLET_UNCHECKED
NOT_IMPLEMENTED
NO_FREE_SLOTS
NO_SUCH_KEYLET
OUT_OF_BOUNDS
PARSE_ERROR
PREPARE_PAYMENT_SIMPLE_SIZE
PREPARE_PAYMENT_SIMPLE_TRUSTLINE_SIZE
PREREQUISITE_NOT_MET
PTRDIFF_MAX
PTRDIFF_MIN
RC_ACCEPT
RC_ROLLBACK
SIG_ATOMIC_MAX
SIG_ATOMIC_MIN
SIZE_MAX
SUCCESS
TOO_BIG
TOO_MANY_EMITTED_TXN
TOO_MANY_NONCES
TOO_SMALL
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINTPTR_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
WINT_MAX
WINT_MIN
_ATFILE_SOURCE
_BITS_STDINT_INTN_H
_BITS_STDINT_UINTN_H
_BITS_TIME64_H
_BITS_TYPESIZES_H
_BITS_TYPES_H
_BITS_WCHAR_H
_DEFAULT_SOURCE
_FEATURES_H
_POSIX_C_SOURCE
_POSIX_SOURCE
_STDC_PREDEF_H
_STDINT_H
_SYS_CDEFS_H
__FD_SETSIZE
__GLIBC_MINOR__
__GLIBC_USE_DEPRECATED_GETS
__GLIBC_USE_DEPRECATED_SCANF
__GLIBC_USE_IEC_60559_BFP_EXT
__GLIBC_USE_IEC_60559_BFP_EXT_C2X
__GLIBC_USE_IEC_60559_FUNCS_EXT
__GLIBC_USE_IEC_60559_FUNCS_EXT_C2X
__GLIBC_USE_IEC_60559_TYPES_EXT
__GLIBC_USE_ISOC2X
__GLIBC_USE_LIB_EXT2
__GLIBC__
__GNU_LIBRARY__
__HAVE_GENERIC_SELECTION
__INO_T_MATCHES_INO64_T
__LONG_DOUBLE_USES_FLOAT128
__OFF_T_MATCHES_OFF64_T
__RLIM_T_MATCHES_RLIM64_T
__STATFS_MATCHES_STATFS64
__STDC_IEC_559_COMPLEX__
__STDC_IEC_559__
__STDC_ISO_10646__
__SYSCALL_WORDSIZE
__TIMESIZE
__USE_ATFILE
__USE_FORTIFY_LEVEL
__USE_ISOC11
__USE_ISOC95
__USE_ISOC99
__USE_MISC
__USE_POSIX
__USE_POSIX2
__USE_POSIX199309
__USE_POSIX199506
__USE_POSIX_IMPLICITLY
__USE_XOPEN2K
__USE_XOPEN2K8
__WORDSIZE
__WORDSIZE_TIME64_COMPAT32
__glibc_c99_flexarr_available
amAMOUNT
amBALANCE
amDELIVEREDAMOUNT
amDELIVERMIN
amFEE
amHIGHLIMIT
amLIMITAMOUNT
amLOWLIMIT
amMINIMUMOFFER
amRIPPLEESCROW
amSENDMAX
amTAKERGETS
amTAKERPAYS
atACCOUNT
atAUTHORIZE
atDESTINATION
atISSUER
atOWNER
atPSEUDOCALLBACK
atREGULARKEY
atTARGET
atUNAUTHORIZE
sfAccount
sfAccountHash
sfAccountTxnID
sfAffectedNodes
sfAmendment
sfAmendments
sfAmount
sfAuthorize
sfBalance
sfBaseFee
sfBondAmount
sfBookDirectory
sfBookNode
sfCancelAfter
sfCheckID
sfClearFlag
sfCloseResolution
sfCloseTime
sfCondition
sfConsensusHash
sfCookie
sfCreateCode
sfCreatedNode
sfDeletedNode
sfDeliverMin
sfDeliveredAmount
sfDestination
sfDestinationNode
sfDestinationTag
sfDigest
sfDomain
sfEmailHash
sfEmitBurden
sfEmitDetails
sfEmitGeneration
sfEmitNonce
sfEmitParentTxnID
sfExchangeRate
sfExpiration
sfExpireCode
sfFee
sfFinalFields
sfFinishAfter
sfFirstLedgerSequence
sfFlags
sfFulfillment
sfFundCode
sfGeneric
sfHash
sfHashes
sfHighLimit
sfHighNode
sfHighQualityIn
sfHighQualityOut
sfHookData
sfHookDataMaxSize
sfHookOn
sfHookReserveCount
sfHookStateCount
sfIndex
sfIndexNext
sfIndexPrevious
sfIndexes
sfInvalid
sfInvoiceID
sfIssuer
sfLastLedgerSequence
sfLedgerEntry
sfLedgerEntryType
sfLedgerHash
sfLedgerIndex
sfLedgerSequence
sfLimitAmount
sfLoadFee
sfLowLimit
sfLowNode
sfLowQualityIn
sfLowQualityOut
sfMajorities
sfMajority
sfMasterSignature
sfMemo
sfMemoData
sfMemoFormat
sfMemoType
sfMemos
sfMessageKey
sfMetadata
sfMethod
sfMinimumOffer
sfModifiedNode
sfNecessary
sfNegativeUNL
sfNegativeUNLEntry
sfNegativeUNLToDisable
sfNegativeUNLToReEnable
sfNewFields
sfNickname
sfOfferSequence
sfOperationLimit
sfOwner
sfOwnerCount
sfOwnerNode
sfParentCloseTime
sfParentHash
sfPaths
sfPayChannel
sfPreviousFields
sfPreviousTxnID
sfPreviousTxnLgrSeq
sfPublicKey
sfQualityIn
sfQualityOut
sfReferenceFeeUnits
sfRegularKey
sfRemoveCode
sfReserveBase
sfReserveIncrement
sfRippleEscrow
sfRootIndex
sfSendMax
sfSequence
sfServerVersion
sfSetFlag
sfSettleDelay
sfSignature
sfSigner
sfSignerEntries
sfSignerEntry
sfSignerListID
sfSignerQuorum
sfSignerWeight
sfSigners
sfSigningAccounts
sfSigningPubKey
sfSigningTime
sfSourceTag
sfStampEscrow
sfSufficient
sfTakerGets
sfTakerGetsCurrency
sfTakerGetsIssuer
sfTakerPays
sfTakerPaysCurrency
sfTakerPaysIssuer
sfTarget
sfTemplate
sfTemplateEntry
sfTickSize
sfTicketID
sfTransaction
sfTransactionHash
sfTransactionIndex
sfTransactionMetaData
sfTransactionResult
sfTransactionType
sfTransferRate
sfTxnSignature
sfUNLModifyDisabling
sfUNLModifyValidator
sfUnauthorize
sfValidatedHash
sfValidation
sfVersion
sfWalletLocator
sfWalletSize
tfCANONICAL
ttPAYMENT

Functions§

_g
Guard function. Each time a loop appears in your code a call to this must be the first branch instruction after the beginning of the loop. @param id The identifier of the guard (typically the line number). @param maxiter The maximum number of times this loop will iterate across the life of the hook. @return Can be ignored. If the guard is violated the hook will terminate.
accept
Accept the originating transaction and commit all hook state changes and submit all emitted transactions. @param read_ptr An optional string to use as a return comment. May be 0. @param read_len The length of the string. May be 0. @return Will never return, terminates the hook.
cbak
emit
Emit a transaction from this hook. @param read_ptr Memory location of a buffer containing the fully formed binary transaction to emit. @param read_len The length of the transaction. @return A negative integer if the emission failed.
etxn_burden
Compute burden for an emitted transaction. @return the burden a theoretically emitted transaction would have.
etxn_details
Write a full emit_details stobject into the buffer specified. @param write_ptr A sufficiently large buffer to write into. @param write_len The length of that buffer. @return The number of bytes written or a negative integer indicating an error.
etxn_fee_base
Compute the minimum fee required to be paid by a hypothetically emitted transaction based on its size in bytes. @param The size of the emitted transaction in bytes @return The minimum fee in drops this transaction should pay to succeed
etxn_generation
Compute the generation of an emitted transaction. If this hook was invoked by a transaction emitted by a previous hook then the generation counter will be 1+ the previous generation counter otherwise it will be 1. @return The generation of a hypothetically emitted transaction.
etxn_reserve
Inform xrpld that you will be emitting at most @count@ transactions during the course of this hook execution. @param count The number of transactions you intend to emit from this hook. @return If a negaitve integer an error has occured
fee_base
Retrive the currently recommended minimum fee for a transaction to succeed.
float_compare
float_divide
float_exponent
float_exponent_set
float_int
float_invert
float_mantissa
float_mantissa_set
float_mulratio
float_multiply
float_negate
float_one
float_set
float_sign
float_sign_set
float_sto
float_sto_set
float_sum
hook
hook_account
Retrieve the account the hook is running on. @param write_ptr A buffer of at least 20 bytes to write into. @param write_len The length of that buffer @return The number of bytes written into the buffer of a negative integer if an error occured.
hook_hash
Retrieve the hash of the currently executing hook. @param write_ptr A buffer of at least 32 bytes to write into. @param write_len The length of that buffer @return The number of bytes written into the buffer of a negative integer if an error occured.
ledger_last_hash
ledger_seq
Retrieve the current ledger sequence number
nonce
Retrieve a nonce for use in an emitted transaction (or another task). Can be called repeatedly for multiple nonces. @param write_ptr A buffer of at least 32 bytes to write into. @param write_len The length of that buffer @return The number of bytes written into the buffer of a negative integer if an error occured.
otxn_burden
Retrieve the burden of the originating transaction (if any) @return The burden of the originating transaction
otxn_field
Retrieve a field from the originating transaction in its raw serialized form. @param write_ptr A buffer to output the field into @param write_len The length of the buffer. @param field_if The field code of the field being requested @return The number of bytes written to write_ptr or a negative integer if an error occured.
otxn_field_txt
Retrieve a field from the originating transaction as “full text” (The way it is displayed in JSON) @param write_ptr A buffer to write the representation into @param write_len The length of the buffer @param field_id The field code of the field being requested @return The number of bytes written to write_ptr or a negative integer if an error occured.
otxn_generation
Retrieve the generation of the originating transaction (if any). @return the generation of the originating transaction.
otxn_id
Retrieve the TXNID of the originating transaction. @param write_ptr A buffer at least 32 bytes long @param write_len The length of the buffer. @return The number of bytes written into the buffer or a negative integer on failure.
otxn_slot
otxn_type
Retrieve the Transaction Type (e.g. ttPayment = 0) of the originating transaction. @return The Transaction Type (tt-code)
rollback
Rollback the originating transaction, discard all hook state changes and emitted transactions. @param read_ptr An optional string to use as a return comment. May be 0. @param read_len The length of the string. May be 0. @return Will never return, terminates the hook.
slot
Slot functions have not been implemented yet and the api for them is subject to change
slot_clear
slot_count
slot_float
slot_id
slot_set
slot_size
slot_subarray
slot_subfield
slot_type
state
Retrieve a value from the hook’s key-value map. @param write_ptr A buffer to write the state value into @param write_len The length of that buffer @param kread_ptr A buffer to read the state key from @param kread_len The length of that key @return The number of bytes written or a negative integer if an error occured.
state_foreign
Retrieve a value from another hook’s key-value map. @param write_ptr A buffer to write the state value into @param write_len The length of that buffer @param kread_ptr A buffer to read the state key from @param kread_len The length of that key @param aread_ptr A buffer containing an account-id of another account containing a hook whose state we are reading @param aread_len The length of the account-id (should always be 20). @return The number of bytes written or a negative integer if an error occured.
state_set
In the hook’s state key-value map, set the value for the key pointed at by kread_ptr. @param read_ptr A buffer containing the data to store @param read_len The length of the data @param kread_ptr A buffer containing the key @param kread_len The length of the key @return The number of bytes stored or a negative integer if an error occured
sto_emplace
sto_erase
sto_subarray
Index into a xrpld serialized array and return the location and length of an index. Unlike sto_subfield this api always returns the offset and length of the whole object at that index (not its payload.) Use SUB_OFFSET and SUB_LENGTH macros to extract return value. @param read_ptr The memory location of the stobject @param read_len The length of the stobject @param array_id The index requested @return high-word (most significant 4 bytes excluding the most significant bit (MSB)) is the field offset relative to read_ptr and the low-word (least significant 4 bytes) is its length. MSB is sign bit, if set (negative) return value indicates error (typically error means could not find.)
sto_subfield
Index into a xrpld serialized object and return the location and length of a subfield. Except for Array subtypes the offset and length refer to the payload of the subfield not the entire subfield. Use SUB_OFFSET and SUB_LENGTH macros to extract return value. @param read_ptr The memory location of the stobject @param read_len The length of the stobject @param field_id The Field Code of the subfield @return high-word (most significant 4 bytes excluding the most significant bit (MSB)) is the field offset relative to read_ptr and the low-word (least significant 4 bytes) is its length. MSB is sign bit, if set (negative) return value indicates error (typically error means could not find.)
sto_validate
trace
Print some output to the trace log on xrpld. Any xrpld instance set to “trace” log level will see this. @param read_ptr A buffer containing either data or text (in either utf8, or utf16le) @param read_len The byte length of the data/text to send to the trace log @param as_hex If 0 treat the read_ptr as pointing at a string of text, otherwise treat it as data and print hex @return The number of bytes output or a negative integer if an error occured.
trace_float
trace_num
Print some output to the trace log on xrpld along with a decimal number. Any xrpld instance set to “trace” log level will see this. @param read_ptr A pointer to the string to output @param read_len The length of the string to output @param number Any integer you wish to display after the text @return A negative value on error
trace_slot
util_accid
Read an r-address from the memory pointed to by read_ptr of length read_len and decode it to a 20 byte account id and write to write_ptr @param read_ptr The memory address of the r-address @param read_len The byte length of the r-address @param write_ptr The memory address of a suitable buffer to write the decoded account id into. @param write_len The size of the write buffer. @return On success 20 will be returned indicating the bytes written. On failure a negative integer is returned indicating what went wrong.
util_keylet
util_raddr
Read a 20 byte account-id from the memory pointed to by read_ptr of length read_len and encode it to a base58-check encoded r-address. @param read_ptr The memory address of the account-id @param read_len The byte length of the account-id (should always be 20) @param write_ptr The memory address of a suitable buffer to write the encoded r-address into. @param write_len The size of the write buffer. @return On success the length of the r-address will be returned indicating the bytes written to the write buffer. On failure a negative integer is returned indicating what went wrong.
util_sha512h
Compute the first half of a SHA512 checksum. @param write_ptr The buffer to write the checksum into. Must be at least 32 bytes. @param write_len The length of the buffer. @param read_ptr The buffer to read data for digest from. @param read_len The amount of data to read from the buffer. @return The number of bytes written to write_ptr or a negative integer on error.
util_verify
Verify a cryptographic signature either ED25519 of SECP256k1. Public key should be prefixed with 0xED for 25519. @param dread_ptr The memory location of the data or payload to verify @param dread_len The length of the data or payload to verify @param sread_ptr The memory location of the signature @param sread_len The length of the signature @param kread_ptr The memory location of the public key @param kread_len The length of the public key @return True if and only if the signature was verified.