Class AccountKey

All Implemented Interfaces:
IValidated, IWriteable, Comparable<ABlob>

public class AccountKey extends AArrayBlob
Immutable class representing an Ed25519 Public Key for an Account

Using Ed25519:

  • AccountKey is the Public Key (32 bytes)
  • Field Details

  • Method Details

    • getType

      public AType getType()
      Description copied from class: ACell
      Gets the most specific known runtime Type for this Cell.
      Overrides:
      getType in class ABlob
      Returns:
      The Type of this Call
    • createRef

      protected <R extends ACell> Ref<R> createRef()
      Description copied from class: ACell
      Creates a new Ref for this Cell
      Overrides:
      createRef in class ACell
      Type Parameters:
      R - Type of Cell
      Returns:
      New Ref instance
    • wrap

      public static AccountKey wrap(byte[] data)
      Wraps the specified bytes as an AccountKey object. Warning: underlying bytes are used directly. Use only if no external references to the byte array will be retained.
      Parameters:
      data - Byte array to wrap as Account Key
      Returns:
      An Address wrapping the given bytes
    • wrap

      public static AccountKey wrap(byte[] data, int offset)
      Wraps the specified bytes as an AccountKey object. Warning: underlying bytes are used directly. Use only if no external references to the byte array will be retained.
      Parameters:
      data - Data array containing address bytes.
      offset - Offset into byte array
      Returns:
      An Address wrapping the given bytes
    • create

      public static AccountKey create(ABlob b)
      Creates an AccountKey from a blob. Must have correct length.
      Parameters:
      b - Blob to wrap as Account Key
      Returns:
      AccountKey instance, or null if not valid
    • dummy

      public static AccountKey dummy(String nonce)
      Creates a "Dummy" Address that is not a valid public key, and therefore cannot have valid signed transactions. To do this, a short hex nonce is repeated to fill the entire address length. This construction makes it possible to examine an Address and assess whether it is (plausibly) a dummy address.
      Parameters:
      nonce - Hex string to repeat to produce a visible dummy address
      Returns:
      An Address that cannot be used to sign transactions.
    • equals

      public boolean equals(ABlob o)
      Description copied from class: ABlob
      Determines if this Blob is equal to another Blob. Blobs are defined to be equal if they have the same on-chain representation, i.e. if and only if all of the following are true: - Blob is of the same general type - Blobs are of the same length - All byte values are equal
      Specified by:
      equals in class ABlob
      Parameters:
      o - Blob to compare with
      Returns:
      true if Blobs are equal, false otherwise
    • equals

      public boolean equals(AccountKey o)
    • fromHex

      public static AccountKey fromHex(String hexString)
      Constructs an AccountKey object from a hex string. Throws an exception if string is not valid
      Parameters:
      hexString - Hex String
      Returns:
      An AccountKey constructed from the hex string
    • fromHexOrNull

      public static AccountKey fromHexOrNull(String hexString)
      Constructs an AccountKey object from a hex string
      Parameters:
      hexString - Hex String
      Returns:
      An Address constructed from the hex string, or null if not a valid hex string
    • fromHexOrNull

      public static AccountKey fromHexOrNull(AString a)
    • fromChecksumHex

      public static AccountKey fromChecksumHex(String hexString)
      Constructs an AccountKey object from a checksummed hex string. Throws an exception if checksum is not valid
      Parameters:
      hexString - Hex String
      Returns:
      An Address constructed from the hex string
    • toChecksumHex

      public String toChecksumHex()
      Converts this AccountKey to a checksummed hex string.
      Returns:
      A String containing the checksummed hex representation of this Address
    • readRaw

      public static AccountKey readRaw(ByteBuffer data)
    • encode

      public int encode(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, including a tag byte which will be written first
      Specified by:
      encode in interface IWriteable
      Specified by:
      encode in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures
      Specified by:
      isCVMValue in class ACell
      Returns:
      true if the object is a CVM Value, false otherwise
    • estimatedEncodingSize

      public int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.
      Returns:
      The estimated size for the binary representation of this object.
    • getEncodingLength

      public long getEncodingLength()
      Description copied from class: ACell
      Method to calculate the encoding length of a Cell. May be overridden to avoid creating encodings during memory size calculations. This reduces hashing!
      Overrides:
      getEncodingLength in class ACell
      Returns:
      Exact encoding length of this Cell
    • getChunk

      public Blob getChunk(long i)
      Description copied from class: ABlob
      Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size
      Specified by:
      getChunk in class ABlob
      Parameters:
      i - Index of chunk
      Returns:
      A Blob containing the specified chunk data.
    • validateCell

      public void validateCell() throws InvalidDataException
      Description copied from class: ACell
      Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.
      Overrides:
      validateCell in class AArrayBlob
      Throws:
      InvalidDataException - If the Cell is invalid
    • isEmbedded

      public boolean isEmbedded()
      Description copied from class: ACell
      Determines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.
      Overrides:
      isEmbedded in class ACell
      Returns:
      true if Cell is embedded, false otherwise
    • calcMemorySize

      protected long calcMemorySize()
      Description copied from class: ACell
      Calculates the Memory Size for this Cell. Requires any child Refs to be either Direct or of persisted status at minimum, or you might get a MissingDataException
      Overrides:
      calcMemorySize in class ACell
      Returns:
      Memory Size of this Cell
    • isRegularBlob

      public boolean isRegularBlob()
      Description copied from class: ABlob
      Returns true if this object is a regular blob (i.e. not a special blob type like Hash or Address)
      Overrides:
      isRegularBlob in class ABlob
      Returns:
      True if a regular blob
    • getTag

      public byte getTag()
      Description copied from class: ACell
      Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding
      Specified by:
      getTag in class ACell
      Returns:
      Tag byte for this Cell
    • isCanonical

      public boolean isCanonical()
      Description copied from class: ACell
      Returns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.
      Specified by:
      isCanonical in class ACell
      Returns:
      true if the object is in canonical format, false otherwise
    • toCanonical

      public Blob toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Returns this if already canonical
      Specified by:
      toCanonical in class ABlob
      Returns:
      Canonical version of Cell