Module xrpl_hooks::_c [−][src]
Expand description
Low-level unsafe C bindings
Use very carefully if at all necessary.
Constants
Functions
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 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.
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.
Compute burden for an emitted transaction. @return the burden a theoretically emitted transaction would have.
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.
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
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.
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
Retrive the currently recommended minimum fee for a transaction to succeed.
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.
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.
Retrieve the current ledger sequence number
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.
Retrieve the burden of the originating transaction (if any) @return The burden of the originating transaction
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.
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.
Retrieve the generation of the originating transaction (if any). @return the generation of the originating transaction.
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.
Retrieve the Transaction Type (e.g. ttPayment = 0) of the originating transaction. @return The Transaction Type (tt-code)
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 functions have not been implemented yet and the api for them is subject to change
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.
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.
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
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.)
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.)
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.
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
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.
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.
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.
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.