+ * If first byte in B starts with either address version bytes,
+ * and bytes 26 to 32 are zero, then use as an address, but only if valid.
+ *
+ * Otherwise, assume B is a public key. + */ + private Account getAccountFromB(MachineState state) { + byte[] bBytes = this.getB(state); + + if ((bBytes[0] == Crypto.ADDRESS_VERSION || bBytes[0] == Crypto.AT_ADDRESS_VERSION) + && Arrays.mismatch(bBytes, Account.ADDRESS_LENGTH, 32, ADDRESS_PADDING, 0, ADDRESS_PADDING.length) == -1) { + // Extract only the bytes containing address + byte[] addressBytes = Arrays.copyOf(bBytes, Account.ADDRESS_LENGTH); + // If address (in byte form) is valid... + if (Crypto.isValidAddress(addressBytes)) + // ...then return an Account using address (converted to Base58 + return new Account(this.repository, Base58.encode(addressBytes)); + } + + return new PublicKeyAccount(this.repository, bBytes); + } + + /* Convenience methods to allow QortalFunctionCode package-visibility access to A/B-get/set methods. */ + + protected byte[] getB(MachineState state) { + return super.getB(state); + } + + protected void setB(MachineState state, byte[] bBytes) { + super.setB(state, bBytes); + } + } diff --git a/src/main/java/org/qortal/at/QortalATLogger.java b/src/main/java/org/qortal/at/QortalATLogger.java deleted file mode 100644 index df01247a..00000000 --- a/src/main/java/org/qortal/at/QortalATLogger.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.qortal.at; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class QortalATLogger implements org.ciyam.at.LoggerInterface { - - // NOTE: We're logging on behalf of org.qortal.at.AT, not ourselves! - private static final Logger LOGGER = LogManager.getLogger(AT.class); - - @Override - public void error(String message) { - LOGGER.error(message); - } - - @Override - public void debug(String message) { - LOGGER.debug(message); - } - - @Override - public void echo(String message) { - LOGGER.info(message); - } - -} diff --git a/src/main/java/org/qortal/at/QortalAtLogger.java b/src/main/java/org/qortal/at/QortalAtLogger.java new file mode 100644 index 00000000..703972a6 --- /dev/null +++ b/src/main/java/org/qortal/at/QortalAtLogger.java @@ -0,0 +1,2182 @@ +package org.qortal.at; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.message.MessageFactory; +import org.apache.logging.log4j.spi.AbstractLogger; +import org.apache.logging.log4j.spi.ExtendedLoggerWrapper; +import org.apache.logging.log4j.util.MessageSupplier; +import org.apache.logging.log4j.util.Supplier; + +/** + * Extended Logger interface with convenience methods for + * the ERROR, DEBUG and ECHO custom log levels. + *
Compatible with Log4j 2.6 or higher.
+ */ +public final class QortalAtLogger extends ExtendedLoggerWrapper implements org.ciyam.at.AtLogger { + private static final long serialVersionUID = 4740841485167L; + private final ExtendedLoggerWrapper logger; + + private static final String FQCN = QortalAtLogger.class.getName(); + private static final Level ERROR = Level.forName("ERROR", 200); + private static final Level DEBUG = Level.forName("DEBUG", 500); + private static final Level ECHO = Level.forName("ECHO", 400); + + private QortalAtLogger(final Logger logger) { + super((AbstractLogger) logger, logger.getName(), logger.getMessageFactory()); + this.logger = this; + } + + /** + * Returns a custom Logger with the name of the calling class. + * + * @return The custom Logger for the calling class. + */ + public static QortalAtLogger create() { + final Logger wrapped = LogManager.getLogger(); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger using the fully qualified name of the Class as + * the Logger name. + * + * @param loggerName The Class whose name should be used as the Logger name. + * If null it will default to the calling class. + * @return The custom Logger. + */ + public static QortalAtLogger create(final Class> loggerName) { + final Logger wrapped = LogManager.getLogger(loggerName); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger using the fully qualified name of the Class as + * the Logger name. + * + * @param loggerName The Class whose name should be used as the Logger name. + * If null it will default to the calling class. + * @param messageFactory The message factory is used only when creating a + * logger, subsequent use does not change the logger but will log + * a warning if mismatched. + * @return The custom Logger. + */ + public static QortalAtLogger create(final Class> loggerName, final MessageFactory messageFactory) { + final Logger wrapped = LogManager.getLogger(loggerName, messageFactory); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger using the fully qualified class name of the value + * as the Logger name. + * + * @param value The value whose class name should be used as the Logger + * name. If null the name of the calling class will be used as + * the logger name. + * @return The custom Logger. + */ + public static QortalAtLogger create(final Object value) { + final Logger wrapped = LogManager.getLogger(value); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger using the fully qualified class name of the value + * as the Logger name. + * + * @param value The value whose class name should be used as the Logger + * name. If null the name of the calling class will be used as + * the logger name. + * @param messageFactory The message factory is used only when creating a + * logger, subsequent use does not change the logger but will log + * a warning if mismatched. + * @return The custom Logger. + */ + public static QortalAtLogger create(final Object value, final MessageFactory messageFactory) { + final Logger wrapped = LogManager.getLogger(value, messageFactory); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger with the specified name. + * + * @param name The logger name. If null the name of the calling class will + * be used. + * @return The custom Logger. + */ + public static QortalAtLogger create(final String name) { + final Logger wrapped = LogManager.getLogger(name); + return new QortalAtLogger(wrapped); + } + + /** + * Returns a custom Logger with the specified name. + * + * @param name The logger name. If null the name of the calling class will + * be used. + * @param messageFactory The message factory is used only when creating a + * logger, subsequent use does not change the logger but will log + * a warning if mismatched. + * @return The custom Logger. + */ + public static QortalAtLogger create(final String name, final MessageFactory messageFactory) { + final Logger wrapped = LogManager.getLogger(name, messageFactory); + return new QortalAtLogger(wrapped); + } + + /** + * Logs a message with the specific Marker at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param msg the message string to be logged + */ + public void error(final Marker marker, final Message msg) { + logger.logIfEnabled(FQCN, ERROR, marker, msg, (Throwable) null); + } + + /** + * Logs a message with the specific Marker at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param msg the message string to be logged + * @param t A Throwable or null. + */ + public void error(final Marker marker, final Message msg, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, marker, msg, t); + } + + /** + * Logs a message object with the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message object to log. + */ + public void error(final Marker marker, final Object message) { + logger.logIfEnabled(FQCN, ERROR, marker, message, (Throwable) null); + } + + /** + * Logs a message CharSequence with the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message CharSequence to log. + * @since Log4j-2.6 + */ + public void error(final Marker marker, final CharSequence message) { + logger.logIfEnabled(FQCN, ERROR, marker, message, (Throwable) null); + } + + /** + * Logs a message at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param marker the marker data specific to this log statement + * @param message the message to log. + * @param t the exception to log, including its stack trace. + */ + public void error(final Marker marker, final Object message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, marker, message, t); + } + + /** + * Logs a message at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param marker the marker data specific to this log statement + * @param message the CharSequence to log. + * @param t the exception to log, including its stack trace. + * @since Log4j-2.6 + */ + public void error(final Marker marker, final CharSequence message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, marker, message, t); + } + + /** + * Logs a message object with the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message object to log. + */ + public void error(final Marker marker, final String message) { + logger.logIfEnabled(FQCN, ERROR, marker, message, (Throwable) null); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param params parameters to the message. + * @see #getMessageFactory() + */ + public void error(final Marker marker, final String message, final Object... params) { + logger.logIfEnabled(FQCN, ERROR, marker, message, params); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4, p5); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @param p8 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7, final Object p8) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param marker the marker data specific to this log statement + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @param p8 parameter to the message. + * @param p9 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final Marker marker, final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7, final Object p8, final Object p9) { + logger.logIfEnabled(FQCN, ERROR, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); + } + + /** + * Logs a message at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param marker the marker data specific to this log statement + * @param message the message to log. + * @param t the exception to log, including its stack trace. + */ + public void error(final Marker marker, final String message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, marker, message, t); + } + + /** + * Logs the specified Message at the {@code ERROR} level. + * + * @param msg the message string to be logged + */ + public void error(final Message msg) { + logger.logIfEnabled(FQCN, ERROR, null, msg, (Throwable) null); + } + + /** + * Logs the specified Message at the {@code ERROR} level. + * + * @param msg the message string to be logged + * @param t A Throwable or null. + */ + public void error(final Message msg, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, null, msg, t); + } + + /** + * Logs a message object with the {@code ERROR} level. + * + * @param message the message object to log. + */ + public void error(final Object message) { + logger.logIfEnabled(FQCN, ERROR, null, message, (Throwable) null); + } + + /** + * Logs a message at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param message the message to log. + * @param t the exception to log, including its stack trace. + */ + public void error(final Object message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, null, message, t); + } + + /** + * Logs a message CharSequence with the {@code ERROR} level. + * + * @param message the message CharSequence to log. + * @since Log4j-2.6 + */ + public void error(final CharSequence message) { + logger.logIfEnabled(FQCN, ERROR, null, message, (Throwable) null); + } + + /** + * Logs a CharSequence at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param message the CharSequence to log. + * @param t the exception to log, including its stack trace. + * @since Log4j-2.6 + */ + public void error(final CharSequence message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, null, message, t); + } + + /** + * Logs a message object with the {@code ERROR} level. + * + * @param message the message object to log. + */ + public void error(final String message) { + logger.logIfEnabled(FQCN, ERROR, null, message, (Throwable) null); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param params parameters to the message. + * @see #getMessageFactory() + */ + public void error(final String message, final Object... params) { + logger.logIfEnabled(FQCN, ERROR, null, message, params); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4, p5); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4, p5, p6); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @param p8 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7, final Object p8) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8); + } + + /** + * Logs a message with parameters at the {@code ERROR} level. + * + * @param message the message to log; the format depends on the message factory. + * @param p0 parameter to the message. + * @param p1 parameter to the message. + * @param p2 parameter to the message. + * @param p3 parameter to the message. + * @param p4 parameter to the message. + * @param p5 parameter to the message. + * @param p6 parameter to the message. + * @param p7 parameter to the message. + * @param p8 parameter to the message. + * @param p9 parameter to the message. + * @see #getMessageFactory() + * @since Log4j-2.6 + */ + public void error(final String message, final Object p0, final Object p1, final Object p2, + final Object p3, final Object p4, final Object p5, final Object p6, + final Object p7, final Object p8, final Object p9) { + logger.logIfEnabled(FQCN, ERROR, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); + } + + /** + * Logs a message at the {@code ERROR} level including the stack trace of + * the {@link Throwable} {@code t} passed as parameter. + * + * @param message the message to log. + * @param t the exception to log, including its stack trace. + */ + public void error(final String message, final Throwable t) { + logger.logIfEnabled(FQCN, ERROR, null, message, t); + } + + /** + * Logs a message which is only to be constructed if the logging level is the {@code ERROR}level. + * + * @param msgSupplier A function, which when called, produces the desired log message; + * the format depends on the message factory. + * @since Log4j-2.4 + */ + public void error(final Supplier> msgSupplier) { + logger.logIfEnabled(FQCN, ERROR, null, msgSupplier, (Throwable) null); + } + + /** + * Logs a message (only to be constructed if the logging level is the {@code ERROR} + * level) including the stack trace of the {@link Throwable}t
passed as parameter.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void error(final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ERROR, null, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ERROR} level with the specified Marker.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @since Log4j-2.4
+ */
+ public void error(final Marker marker, final Supplier> msgSupplier) {
+ logger.logIfEnabled(FQCN, ERROR, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is the
+ * {@code ERROR} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void error(final Marker marker, final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, ERROR, marker, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ERROR}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void error(final Marker marker, final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ERROR, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is
+ * the {@code ERROR} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void error(final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, ERROR, null, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ERROR} level with the specified Marker. The {@code MessageSupplier} may or may
+ * not use the {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void error(final Marker marker, final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, ERROR, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ERROR}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void error(final Marker marker, final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ERROR, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ERROR} level. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void error(final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, ERROR, null, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ERROR}
+ * level) including the stack trace of the {@link Throwable} t
passed as parameter.
+ * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the
+ * {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void error(final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ERROR, null, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message with the specific Marker at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message string to be logged
+ */
+ public void debug(final Marker marker, final Message msg) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msg, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with the specific Marker at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message string to be logged
+ * @param t A Throwable or null.
+ */
+ public void debug(final Marker marker, final Message msg, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msg, t);
+ }
+
+ /**
+ * Logs a message object with the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ public void debug(final Marker marker, final Object message) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message CharSequence with the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message CharSequence to log.
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final CharSequence message) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(final Marker marker, final Object message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, t);
+ }
+
+ /**
+ * Logs a message at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the CharSequence to log.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final CharSequence message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, t);
+ }
+
+ /**
+ * Logs a message object with the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ public void debug(final Marker marker, final String message) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param params parameters to the message.
+ * @see #getMessageFactory()
+ */
+ public void debug(final Marker marker, final String message, final Object... params) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, params);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4, p5);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @param p9 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8, final Object p9) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ /**
+ * Logs a message at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(final Marker marker, final String message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, t);
+ }
+
+ /**
+ * Logs the specified Message at the {@code DEBUG} level.
+ *
+ * @param msg the message string to be logged
+ */
+ public void debug(final Message msg) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msg, (Throwable) null);
+ }
+
+ /**
+ * Logs the specified Message at the {@code DEBUG} level.
+ *
+ * @param msg the message string to be logged
+ * @param t A Throwable or null.
+ */
+ public void debug(final Message msg, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msg, t);
+ }
+
+ /**
+ * Logs a message object with the {@code DEBUG} level.
+ *
+ * @param message the message object to log.
+ */
+ public void debug(final Object message) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(final Object message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, t);
+ }
+
+ /**
+ * Logs a message CharSequence with the {@code DEBUG} level.
+ *
+ * @param message the message CharSequence to log.
+ * @since Log4j-2.6
+ */
+ public void debug(final CharSequence message) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a CharSequence at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the CharSequence to log.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.6
+ */
+ public void debug(final CharSequence message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, t);
+ }
+
+ /**
+ * Logs a message object with the {@code DEBUG} level.
+ *
+ * @param message the message object to log.
+ */
+ public void debug(final String message) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param params parameters to the message.
+ * @see #getMessageFactory()
+ */
+ public void debug(final String message, final Object... params) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, params);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4, p5);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @param p9 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void debug(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8, final Object p9) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ /**
+ * Logs a message at the {@code DEBUG} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(final String message, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the {@code DEBUG}level.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @since Log4j-2.4
+ */
+ public void debug(final Supplier> msgSupplier) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code DEBUG}
+ * level) including the stack trace of the {@link Throwable} t
passed as parameter.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void debug(final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code DEBUG} level with the specified Marker.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @since Log4j-2.4
+ */
+ public void debug(final Marker marker, final Supplier> msgSupplier) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is the
+ * {@code DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void debug(final Marker marker, final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code DEBUG}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void debug(final Marker marker, final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is
+ * the {@code DEBUG} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void debug(final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, DEBUG, null, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code DEBUG} level with the specified Marker. The {@code MessageSupplier} may or may
+ * not use the {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void debug(final Marker marker, final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code DEBUG}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void debug(final Marker marker, final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code DEBUG} level. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void debug(final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code DEBUG}
+ * level) including the stack trace of the {@link Throwable} t
passed as parameter.
+ * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the
+ * {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void debug(final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, DEBUG, null, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message with the specific Marker at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message string to be logged
+ */
+ public void echo(final Marker marker, final Message msg) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msg, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with the specific Marker at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message string to be logged
+ * @param t A Throwable or null.
+ */
+ public void echo(final Marker marker, final Message msg, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msg, t);
+ }
+
+ /**
+ * Logs a message object with the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ public void echo(final Marker marker, final Object message) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message CharSequence with the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message CharSequence to log.
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final CharSequence message) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void echo(final Marker marker, final Object message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, t);
+ }
+
+ /**
+ * Logs a message at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the CharSequence to log.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final CharSequence message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, t);
+ }
+
+ /**
+ * Logs a message object with the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ public void echo(final Marker marker, final String message) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param params parameters to the message.
+ * @see #getMessageFactory()
+ */
+ public void echo(final Marker marker, final String message, final Object... params) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, params);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4, p5);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4, p5, p6);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @param p9 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final Marker marker, final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8, final Object p9) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ /**
+ * Logs a message at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void echo(final Marker marker, final String message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, t);
+ }
+
+ /**
+ * Logs the specified Message at the {@code ECHO} level.
+ *
+ * @param msg the message string to be logged
+ */
+ public void echo(final Message msg) {
+ logger.logIfEnabled(FQCN, ECHO, null, msg, (Throwable) null);
+ }
+
+ /**
+ * Logs the specified Message at the {@code ECHO} level.
+ *
+ * @param msg the message string to be logged
+ * @param t A Throwable or null.
+ */
+ public void echo(final Message msg, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, msg, t);
+ }
+
+ /**
+ * Logs a message object with the {@code ECHO} level.
+ *
+ * @param message the message object to log.
+ */
+ public void echo(final Object message) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void echo(final Object message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, t);
+ }
+
+ /**
+ * Logs a message CharSequence with the {@code ECHO} level.
+ *
+ * @param message the message CharSequence to log.
+ * @since Log4j-2.6
+ */
+ public void echo(final CharSequence message) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a CharSequence at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the CharSequence to log.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.6
+ */
+ public void echo(final CharSequence message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, t);
+ }
+
+ /**
+ * Logs a message object with the {@code ECHO} level.
+ *
+ * @param message the message object to log.
+ */
+ public void echo(final String message) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param params parameters to the message.
+ * @see #getMessageFactory()
+ */
+ public void echo(final String message, final Object... params) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, params);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4, p5);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4, p5, p6);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ /**
+ * Logs a message with parameters at the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param p0 parameter to the message.
+ * @param p1 parameter to the message.
+ * @param p2 parameter to the message.
+ * @param p3 parameter to the message.
+ * @param p4 parameter to the message.
+ * @param p5 parameter to the message.
+ * @param p6 parameter to the message.
+ * @param p7 parameter to the message.
+ * @param p8 parameter to the message.
+ * @param p9 parameter to the message.
+ * @see #getMessageFactory()
+ * @since Log4j-2.6
+ */
+ public void echo(final String message, final Object p0, final Object p1, final Object p2,
+ final Object p3, final Object p4, final Object p5, final Object p6,
+ final Object p7, final Object p8, final Object p9) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ /**
+ * Logs a message at the {@code ECHO} level including the stack trace of
+ * the {@link Throwable} {@code t} passed as parameter.
+ *
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void echo(final String message, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the {@code ECHO}level.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @since Log4j-2.4
+ */
+ public void echo(final Supplier> msgSupplier) {
+ logger.logIfEnabled(FQCN, ECHO, null, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ECHO}
+ * level) including the stack trace of the {@link Throwable} t
passed as parameter.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void echo(final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ECHO} level with the specified Marker.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @since Log4j-2.4
+ */
+ public void echo(final Marker marker, final Supplier> msgSupplier) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is the
+ * {@code ECHO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void echo(final Marker marker, final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, ECHO, marker, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ECHO}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message;
+ * the format depends on the message factory.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void echo(final Marker marker, final Supplier> msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message with parameters which are only to be constructed if the logging level is
+ * the {@code ECHO} level.
+ *
+ * @param message the message to log; the format depends on the message factory.
+ * @param paramSuppliers An array of functions, which when called, produce the desired log message parameters.
+ * @since Log4j-2.4
+ */
+ public void echo(final String message, final Supplier>... paramSuppliers) {
+ logger.logIfEnabled(FQCN, ECHO, null, message, paramSuppliers);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ECHO} level with the specified Marker. The {@code MessageSupplier} may or may
+ * not use the {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void echo(final Marker marker, final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ECHO}
+ * level) with the specified Marker and including the stack trace of the {@link Throwable}
+ * t
passed as parameter. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t A Throwable or null.
+ * @since Log4j-2.4
+ */
+ public void echo(final Marker marker, final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, marker, msgSupplier, t);
+ }
+
+ /**
+ * Logs a message which is only to be constructed if the logging level is the
+ * {@code ECHO} level. The {@code MessageSupplier} may or may not use the
+ * {@link MessageFactory} to construct the {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @since Log4j-2.4
+ */
+ public void echo(final MessageSupplier msgSupplier) {
+ logger.logIfEnabled(FQCN, ECHO, null, msgSupplier, (Throwable) null);
+ }
+
+ /**
+ * Logs a message (only to be constructed if the logging level is the {@code ECHO}
+ * level) including the stack trace of the {@link Throwable} t
passed as parameter.
+ * The {@code MessageSupplier} may or may not use the {@link MessageFactory} to construct the
+ * {@code Message}.
+ *
+ * @param msgSupplier A function, which when called, produces the desired log message.
+ * @param t the exception to log, including its stack trace.
+ * @since Log4j-2.4
+ */
+ public void echo(final MessageSupplier msgSupplier, final Throwable t) {
+ logger.logIfEnabled(FQCN, ECHO, null, msgSupplier, t);
+ }
+}
+
diff --git a/src/main/java/org/qortal/at/QortalAtLoggerFactory.java b/src/main/java/org/qortal/at/QortalAtLoggerFactory.java
new file mode 100644
index 00000000..19cbb3d9
--- /dev/null
+++ b/src/main/java/org/qortal/at/QortalAtLoggerFactory.java
@@ -0,0 +1,24 @@
+package org.qortal.at;
+
+import org.ciyam.at.AtLogger;
+
+public class QortalAtLoggerFactory implements org.ciyam.at.AtLoggerFactory {
+
+ private static QortalAtLoggerFactory instance;
+
+ private QortalAtLoggerFactory() {
+ }
+
+ public static synchronized QortalAtLoggerFactory getInstance() {
+ if (instance == null)
+ instance = new QortalAtLoggerFactory();
+
+ return instance;
+ }
+
+ @Override
+ public AtLogger create(final Class> loggerName) {
+ return QortalAtLogger.create(loggerName);
+ }
+
+}
diff --git a/src/main/java/org/qortal/at/QortalFunctionCode.java b/src/main/java/org/qortal/at/QortalFunctionCode.java
index f7d089cf..cf6b1cfd 100644
--- a/src/main/java/org/qortal/at/QortalFunctionCode.java
+++ b/src/main/java/org/qortal/at/QortalFunctionCode.java
@@ -1,15 +1,18 @@
package org.qortal.at;
-import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.ciyam.at.ExecutionException;
import org.ciyam.at.FunctionData;
import org.ciyam.at.IllegalFunctionCodeException;
import org.ciyam.at.MachineState;
-import org.ciyam.at.Timestamp;
+import org.qortal.crosschain.BTC;
+import org.qortal.crypto.Crypto;
+import org.qortal.settings.Settings;
/**
* Qortal-specific CIYAM-AT Functions.
@@ -19,28 +22,43 @@ import org.ciyam.at.Timestamp;
*/
public enum QortalFunctionCode {
/**
- * 0x0500
+ * See comments in {@link BTCACCT} for more details.
+ *
+ * @param refunderPubKeyHash 20-byte HASH160 of P2SH funder's public key, for refunding purposes
+ * @param lockTime seconds-since-epoch threshold, after which P2SH funder can claim refund
+ * @param redeemerPubKeyHash 20-byte HASH160 of P2SH redeemer's public key
+ * @param secretHash 20-byte HASH160 of secret, used by P2SH redeemer to claim funds
+ * @return
+ */
+ public static byte[] buildScript(byte[] refunderPubKeyHash, int lockTime, byte[] redeemerPubKeyHash, byte[] secretHash) {
+ return Bytes.concat(redeemScript1, refunderPubKeyHash, redeemScript2, BitTwiddling.toLEByteArray((int) (lockTime & 0xffffffffL)),
+ redeemScript3, redeemerPubKeyHash, redeemScript4, secretHash, redeemScript5);
+ }
+
+ /**
+ * Builds a custom transaction to spend P2SH.
+ *
+ * @param amount output amount, should be total of input amounts, less miner fees
+ * @param spendKey key for signing transaction, and also where funds are 'sent' (output)
+ * @param fundingOutput output from transaction that funded P2SH address
+ * @param redeemScriptBytes the redeemScript itself, in byte[] form
+ * @param lockTime (optional) transaction nLockTime, used in refund scenario
+ * @param scriptSigBuilder function for building scriptSig using transaction input signature
+ * @return Signed Bitcoin transaction for spending P2SH
+ */
+ public static Transaction buildP2shTransaction(Coin amount, ECKey spendKey, TransactionOutput fundingOutput, byte[] redeemScriptBytes, Long lockTime, Function
+ * tradeTimeout (minutes) is the time window for the recipient to send the
+ * 32-byte secret to the AT, before the AT automatically refunds the AT's creator.
+ *
+ * @param qortalCreator Qortal address for AT creator, also used for refunds
+ * @param secretHash 20-byte HASH160 of 32-byte secret
+ * @param tradeTimeout how many minutes, from start of 'trade mode' until AT auto-refunds AT creator
+ * @param initialPayout how much QORT to pay trade partner upon switch to 'trade mode'
+ * @param redeemPayout how much QORT to pay trade partner if they send correct 32-byte secret to AT
+ * @param bitcoinAmount how much BTC the AT creator is expecting to trade
+ * @return
+ */
+ public static byte[] buildQortalAT(String qortalCreator, byte[] secretHash, int tradeTimeout, long initialPayout, long redeemPayout, long bitcoinAmount) {
+ // Labels for data segment addresses
+ int addrCounter = 0;
+
+ // Constants (with corresponding dataByteBuffer.put*() calls below)
+
+ final int addrQortalCreator1 = addrCounter++;
+ final int addrQortalCreator2 = addrCounter++;
+ final int addrQortalCreator3 = addrCounter++;
+ final int addrQortalCreator4 = addrCounter++;
+
+ final int addrSecretHash = addrCounter;
+ addrCounter += 4;
+
+ final int addrTradeTimeout = addrCounter++;
+ final int addrInitialPayoutAmount = addrCounter++;
+ final int addrRedeemPayoutAmount = addrCounter++;
+ final int addrBitcoinAmount = addrCounter++;
+
+ final int addrMessageTxType = addrCounter++;
+
+ final int addrSecretHashPointer = addrCounter++;
+ final int addrQortalRecipientPointer = addrCounter++;
+ final int addrMessageSenderPointer = addrCounter++;
+
+ final int addrMessageDataPointer = addrCounter++;
+ final int addrMessageDataLength = addrCounter++;
+
+ final int addrEndOfConstants = addrCounter;
+
+ // Variables
+
+ final int addrQortalRecipient1 = addrCounter++;
+ final int addrQortalRecipient2 = addrCounter++;
+ final int addrQortalRecipient3 = addrCounter++;
+ final int addrQortalRecipient4 = addrCounter++;
+
+ final int addrTradeRefundTimestamp = addrCounter++;
+ final int addrLastTxTimestamp = addrCounter++;
+ final int addrBlockTimestamp = addrCounter++;
+ final int addrTxType = addrCounter++;
+ final int addrResult = addrCounter++;
+
+ final int addrMessageSender1 = addrCounter++;
+ final int addrMessageSender2 = addrCounter++;
+ final int addrMessageSender3 = addrCounter++;
+ final int addrMessageSender4 = addrCounter++;
+
+ final int addrMessageData = addrCounter;
+ addrCounter += 4;
+
+ // Data segment
+ ByteBuffer dataByteBuffer = ByteBuffer.allocate(addrCounter * MachineState.VALUE_SIZE);
+
+ // AT creator's Qortal address, decoded from Base58
+ assert dataByteBuffer.position() == addrQortalCreator1 * MachineState.VALUE_SIZE : "addrQortalCreator1 incorrect";
+ byte[] qortalCreatorBytes = Base58.decode(qortalCreator);
+ dataByteBuffer.put(Bytes.ensureCapacity(qortalCreatorBytes, 32, 0));
+
+ // Hash of secret
+ assert dataByteBuffer.position() == addrSecretHash * MachineState.VALUE_SIZE : "addrSecretHash incorrect";
+ dataByteBuffer.put(Bytes.ensureCapacity(secretHash, 32, 0));
+
+ // Trade timeout in minutes
+ assert dataByteBuffer.position() == addrTradeTimeout * MachineState.VALUE_SIZE : "addrTradeTimeout incorrect";
+ dataByteBuffer.putLong(tradeTimeout);
+
+ // Initial payout amount
+ assert dataByteBuffer.position() == addrInitialPayoutAmount * MachineState.VALUE_SIZE : "addrInitialPayoutAmount incorrect";
+ dataByteBuffer.putLong(initialPayout);
+
+ // Redeem payout amount
+ assert dataByteBuffer.position() == addrRedeemPayoutAmount * MachineState.VALUE_SIZE : "addrRedeemPayoutAmount incorrect";
+ dataByteBuffer.putLong(redeemPayout);
+
+ // Expected Bitcoin amount
+ assert dataByteBuffer.position() == addrBitcoinAmount * MachineState.VALUE_SIZE : "addrBitcoinAmount incorrect";
+ dataByteBuffer.putLong(bitcoinAmount);
+
+ // We're only interested in MESSAGE transactions
+ assert dataByteBuffer.position() == addrMessageTxType * MachineState.VALUE_SIZE : "addrMessageTxType incorrect";
+ dataByteBuffer.putLong(API.ATTransactionType.MESSAGE.value);
+
+ // Index into data segment of hash, used by GET_B_IND
+ assert dataByteBuffer.position() == addrSecretHashPointer * MachineState.VALUE_SIZE : "addrSecretHashPointer incorrect";
+ dataByteBuffer.putLong(addrSecretHash);
+
+ // Index into data segment of recipient address, used by SET_B_IND
+ assert dataByteBuffer.position() == addrQortalRecipientPointer * MachineState.VALUE_SIZE : "addrQortalRecipientPointer incorrect";
+ dataByteBuffer.putLong(addrQortalRecipient1);
+
+ // Index into data segment of (temporary) transaction's sender's address, used by GET_B_IND
+ assert dataByteBuffer.position() == addrMessageSenderPointer * MachineState.VALUE_SIZE : "addrMessageSenderPointer incorrect";
+ dataByteBuffer.putLong(addrMessageSender1);
+
+ // Source location and length for hashing any passed secret
+ assert dataByteBuffer.position() == addrMessageDataPointer * MachineState.VALUE_SIZE : "addrMessageDataPointer incorrect";
+ dataByteBuffer.putLong(addrMessageData);
+ assert dataByteBuffer.position() == addrMessageDataLength * MachineState.VALUE_SIZE : "addrMessageDataLength incorrect";
+ dataByteBuffer.putLong(32L);
+
+ assert dataByteBuffer.position() == addrEndOfConstants * MachineState.VALUE_SIZE : "dataByteBuffer position not at end of constants";
+
+ // Code labels
+ Integer labelRefund = null;
+
+ Integer labelOfferTxLoop = null;
+ Integer labelCheckOfferTx = null;
+
+ Integer labelTradeMode = null;
+ Integer labelTradeTxLoop = null;
+ Integer labelCheckTradeTx = null;
+
+ ByteBuffer codeByteBuffer = ByteBuffer.allocate(512);
+
+ // Two-pass version
+ for (int pass = 0; pass < 2; ++pass) {
+ codeByteBuffer.clear();
+
+ try {
+ /* Initialization */
+
+ // Use AT creation 'timestamp' as starting point for finding transactions sent to AT
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_CREATION_TIMESTAMP, addrLastTxTimestamp));
+
+ // Set restart position to after this opcode
+ codeByteBuffer.put(OpCode.SET_PCS.compile());
+
+ /* Loop, waiting for message from AT owner containing trade partner details, or AT owner's address to cancel offer */
+
+ /* Transaction processing loop */
+ labelOfferTxLoop = codeByteBuffer.position();
+
+ // Find next transaction to this AT since the last one (if any)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.PUT_TX_AFTER_TIMESTAMP_INTO_A, addrLastTxTimestamp));
+ // If no transaction found, A will be zero. If A is zero, set addrComparator to 1, otherwise 0.
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.CHECK_A_IS_ZERO, addrResult));
+ // If addrResult is zero (i.e. A is non-zero, transaction was found) then go check transaction
+ codeByteBuffer.put(OpCode.BZR_DAT.compile(addrResult, calcOffset(codeByteBuffer, labelCheckOfferTx)));
+ // Stop and wait for next block
+ codeByteBuffer.put(OpCode.STP_IMD.compile());
+
+ /* Check transaction */
+ labelCheckOfferTx = codeByteBuffer.position();
+
+ // Update our 'last found transaction's timestamp' using 'timestamp' from transaction
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_TIMESTAMP_FROM_TX_IN_A, addrLastTxTimestamp));
+ // Extract transaction type (message/payment) from transaction and save type in addrTxType
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_TYPE_FROM_TX_IN_A, addrTxType));
+ // If transaction type is not MESSAGE type then go look for another transaction
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrTxType, addrMessageTxType, calcOffset(codeByteBuffer, labelOfferTxLoop)));
+
+ /* Check transaction's sender */
+
+ // Extract sender address from transaction into B register
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PUT_ADDRESS_FROM_TX_IN_A_INTO_B));
+ // Save B register into data segment starting at addrMessageSender1 (as pointed to by addrMessageSenderPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.GET_B_IND, addrMessageSenderPointer));
+ // Compare each part of transaction's sender's address with expected address. If they don't match, look for another transaction.
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender1, addrQortalCreator1, calcOffset(codeByteBuffer, labelOfferTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender2, addrQortalCreator2, calcOffset(codeByteBuffer, labelOfferTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender3, addrQortalCreator3, calcOffset(codeByteBuffer, labelOfferTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender4, addrQortalCreator4, calcOffset(codeByteBuffer, labelOfferTxLoop)));
+
+ /* Extract trade partner info from message */
+
+ // Extract message from transaction into B register
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PUT_MESSAGE_FROM_TX_IN_A_INTO_B));
+ // Save B register into data segment starting at addrQortalRecipient1 (as pointed to by addrQortalRecipientPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.GET_B_IND, addrQortalRecipientPointer));
+ // Compare each of recipient address with creator's address (for offer-cancel scenario). If they don't match, assume recipient is trade partner.
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrQortalRecipient1, addrQortalCreator1, calcOffset(codeByteBuffer, labelTradeMode)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrQortalRecipient2, addrQortalCreator2, calcOffset(codeByteBuffer, labelTradeMode)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrQortalRecipient3, addrQortalCreator3, calcOffset(codeByteBuffer, labelTradeMode)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrQortalRecipient4, addrQortalCreator4, calcOffset(codeByteBuffer, labelTradeMode)));
+ // Recipient address is AT creator's address, so cancel offer and finish.
+ codeByteBuffer.put(OpCode.JMP_ADR.compile(labelRefund == null ? 0 : labelRefund));
+
+ /* Switch to 'trade mode' */
+ labelTradeMode = codeByteBuffer.position();
+
+ // Send initial payment to recipient so they have enough funds to message AT if all goes well
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.PAY_TO_ADDRESS_IN_B, addrInitialPayoutAmount));
+
+ // Calculate trade timeout refund 'timestamp' by adding addrTradeTimeout minutes to above message's 'timestamp', then save into addrTradeRefundTimestamp
+ codeByteBuffer.put(OpCode.EXT_FUN_RET_DAT_2.compile(FunctionCode.ADD_MINUTES_TO_TIMESTAMP, addrTradeRefundTimestamp, addrLastTxTimestamp, addrTradeTimeout));
+
+ // Set restart position to after this opcode
+ codeByteBuffer.put(OpCode.SET_PCS.compile());
+
+ /* Loop, waiting for trade timeout or message from Qortal trade recipient containing secret */
+
+ // Fetch current block 'timestamp'
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_BLOCK_TIMESTAMP, addrBlockTimestamp));
+ // If we're not past refund 'timestamp' then look for next transaction
+ codeByteBuffer.put(OpCode.BLT_DAT.compile(addrBlockTimestamp, addrTradeRefundTimestamp, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+ // We're past refund 'timestamp' so go refund everything back to AT creator
+ codeByteBuffer.put(OpCode.JMP_ADR.compile(labelRefund == null ? 0 : labelRefund));
+
+ /* Transaction processing loop */
+ labelTradeTxLoop = codeByteBuffer.position();
+
+ // Find next transaction to this AT since the last one (if any)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.PUT_TX_AFTER_TIMESTAMP_INTO_A, addrLastTxTimestamp));
+ // If no transaction found, A will be zero. If A is zero, set addrComparator to 1, otherwise 0.
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.CHECK_A_IS_ZERO, addrResult));
+ // If addrResult is zero (i.e. A is non-zero, transaction was found) then go check transaction
+ codeByteBuffer.put(OpCode.BZR_DAT.compile(addrResult, calcOffset(codeByteBuffer, labelCheckTradeTx)));
+ // Stop and wait for next block
+ codeByteBuffer.put(OpCode.STP_IMD.compile());
+
+ /* Check transaction */
+ labelCheckTradeTx = codeByteBuffer.position();
+
+ // Update our 'last found transaction's timestamp' using 'timestamp' from transaction
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_TIMESTAMP_FROM_TX_IN_A, addrLastTxTimestamp));
+ // Extract transaction type (message/payment) from transaction and save type in addrTxType
+ codeByteBuffer.put(OpCode.EXT_FUN_RET.compile(FunctionCode.GET_TYPE_FROM_TX_IN_A, addrTxType));
+ // If transaction type is not MESSAGE type then go look for another transaction
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrTxType, addrMessageTxType, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+
+ /* Check transaction's sender */
+
+ // Extract sender address from transaction into B register
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PUT_ADDRESS_FROM_TX_IN_A_INTO_B));
+ // Save B register into data segment starting at addrMessageSender1 (as pointed to by addrMessageSenderPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.GET_B_IND, addrMessageSenderPointer));
+ // Compare each part of transaction's sender's address with expected address. If they don't match, look for another transaction.
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender1, addrQortalRecipient1, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender2, addrQortalRecipient2, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender3, addrQortalRecipient3, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+ codeByteBuffer.put(OpCode.BNE_DAT.compile(addrMessageSender4, addrQortalRecipient4, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+
+ /* Check 'secret' in transaction's message */
+
+ // Extract message from transaction into B register
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PUT_MESSAGE_FROM_TX_IN_A_INTO_B));
+ // Save B register into data segment starting at addrMessageData (as pointed to by addrMessageDataPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.GET_B_IND, addrMessageDataPointer));
+ // Load B register with expected hash result (as pointed to by addrSecretHashPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.SET_B_IND, addrSecretHashPointer));
+ // Perform HASH160 using source data at addrMessageData. (Location and length specified via addrMessageDataPointer and addrMessageDataLength).
+ // Save the equality result (1 if they match, 0 otherwise) into addrResult.
+ codeByteBuffer.put(OpCode.EXT_FUN_RET_DAT_2.compile(FunctionCode.CHECK_HASH160_WITH_B, addrResult, addrMessageDataPointer, addrMessageDataLength));
+ // If hashes don't match, addrResult will be zero so go find another transaction
+ codeByteBuffer.put(OpCode.BZR_DAT.compile(addrResult, calcOffset(codeByteBuffer, labelTradeTxLoop)));
+
+ /* Success! Pay arranged amount to intended recipient */
+
+ // Load B register with intended recipient address (as pointed to by addrQortalRecipientPointer)
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.SET_B_IND, addrQortalRecipientPointer));
+ // Pay AT's balance to recipient
+ codeByteBuffer.put(OpCode.EXT_FUN_DAT.compile(FunctionCode.PAY_TO_ADDRESS_IN_B, addrRedeemPayoutAmount));
+ // Fall-through to refunding any remaining balance back to AT creator
+
+ /* Refund balance back to AT creator */
+ labelRefund = codeByteBuffer.position();
+
+ // Load B register with AT creator's address.
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PUT_CREATOR_INTO_B));
+ // Pay AT's balance back to AT's creator.
+ codeByteBuffer.put(OpCode.EXT_FUN.compile(FunctionCode.PAY_ALL_TO_ADDRESS_IN_B));
+ // We're finished forever
+ codeByteBuffer.put(OpCode.FIN_IMD.compile());
+ } catch (CompilationException e) {
+ throw new IllegalStateException("Unable to compile BTC-QORT ACCT?", e);
+ }
+ }
+
+ codeByteBuffer.flip();
+
+ byte[] codeBytes = new byte[codeByteBuffer.limit()];
+ codeByteBuffer.get(codeBytes);
+
+ assert Arrays.equals(Crypto.digest(codeBytes), BTCACCT.CODE_BYTES_HASH)
+ : String.format("BTCACCT.CODE_BYTES_HASH mismatch: expected %s, actual %s", HashCode.fromBytes(CODE_BYTES_HASH), HashCode.fromBytes(Crypto.digest(codeBytes)));
+
+ final short ciyamAtVersion = 2;
+ final short numCallStackPages = 0;
+ final short numUserStackPages = 0;
+ final long minActivationAmount = 0L;
+
+ return MachineState.toCreationBytes(ciyamAtVersion, codeBytes, dataByteBuffer.array(), numCallStackPages, numUserStackPages, minActivationAmount);
+ }
+
+ /**
+ * Returns CrossChainTradeData with useful info extracted from AT.
+ *
+ * @param repository
+ * @param atAddress
+ * @throws DataException
+ */
+ public static CrossChainTradeData populateTradeData(Repository repository, ATData atData) throws DataException {
+ String atAddress = atData.getATAddress();
+
+ ATStateData atStateData = repository.getATRepository().getLatestATState(atAddress);
+ byte[] stateData = atStateData.getStateData();
+
+ QortalAtLoggerFactory loggerFactory = QortalAtLoggerFactory.getInstance();
+ byte[] dataBytes = MachineState.extractDataBytes(loggerFactory, stateData);
+
+ CrossChainTradeData tradeData = new CrossChainTradeData();
+ tradeData.qortalAtAddress = atAddress;
+ tradeData.qortalCreator = Crypto.toAddress(atData.getCreatorPublicKey());
+ tradeData.creationTimestamp = atData.getCreation();
+ tradeData.qortBalance = repository.getAccountRepository().getBalance(atAddress, Asset.QORT).getBalance();
+
+ ByteBuffer dataByteBuffer = ByteBuffer.wrap(dataBytes);
+ byte[] addressBytes = new byte[32];
+
+ // Skip AT creator address
+ dataByteBuffer.position(dataByteBuffer.position() + 32);
+
+ // Hash of secret
+ tradeData.secretHash = new byte[20];
+ dataByteBuffer.get(tradeData.secretHash);
+ dataByteBuffer.position(dataByteBuffer.position() + 32 - 20); // skip to 32 bytes
+
+ // Trade timeout
+ tradeData.tradeRefundTimeout = dataByteBuffer.getLong();
+
+ // Initial payout
+ tradeData.initialPayout = dataByteBuffer.getLong();
+
+ // Redeem payout
+ tradeData.redeemPayout = dataByteBuffer.getLong();
+
+ // Expected BTC amount
+ tradeData.expectedBitcoin = dataByteBuffer.getLong();
+
+ // Skip MESSAGE transaction type
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Skip pointer to secretHash
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Skip pointer to Qortal recipient
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Skip pointer to message sender
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Skip pointer to message data
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Skip message data length
+ dataByteBuffer.position(dataByteBuffer.position() + 8);
+
+ // Qortal recipient (if any)
+ dataByteBuffer.get(addressBytes);
+
+ // Trade offer timeout (AT 'timestamp' converted to Qortal block height)
+ long tradeRefundTimestamp = dataByteBuffer.getLong();
+
+ if (tradeRefundTimestamp != 0) {
+ tradeData.mode = CrossChainTradeData.Mode.TRADE;
+ tradeData.tradeRefundHeight = new Timestamp(tradeRefundTimestamp).blockHeight;
+
+ if (addressBytes[0] != 0)
+ tradeData.qortalRecipient = Base58.encode(Arrays.copyOf(addressBytes, Account.ADDRESS_LENGTH));
+
+ // We'll suggest half of trade timeout
+ CiyamAtSettings ciyamAtSettings = BlockChain.getInstance().getCiyamAtSettings();
+
+ int tradeModeSwitchHeight = (int) (tradeData.tradeRefundHeight - tradeData.tradeRefundTimeout / ciyamAtSettings.minutesPerBlock);
+
+ BlockData blockData = repository.getBlockRepository().fromHeight(tradeModeSwitchHeight);
+ if (blockData != null) {
+ tradeData.tradeModeTimestamp = blockData.getTimestamp(); // NOTE: milliseconds from epoch
+ tradeData.lockTime = (int) (tradeData.tradeModeTimestamp / 1000L + tradeData.tradeRefundTimeout / 2 * 60);
+ }
+ } else {
+ tradeData.mode = CrossChainTradeData.Mode.OFFER;
+ }
+
+ return tradeData;
+ }
+
+ public static byte[] findP2shSecret(String p2shAddress, List