Class TransactionMessage.Builder

java.lang.Object
com.exonum.binding.common.message.TransactionMessage.Builder
Enclosing interface:
TransactionMessage

public static class TransactionMessage.Builder
extends java.lang.Object
Builder for the binary transaction message.
  • Method Details

    • serviceId

      public TransactionMessage.Builder serviceId​(int serviceId)
      Sets service identifier to the transaction message.
    • transactionId

      public TransactionMessage.Builder transactionId​(int transactionId)
      Sets transaction identifier to the transaction message.
    • payload

      public TransactionMessage.Builder payload​(byte[] payload)
      Sets a payload of the transaction message.
    • payload

      public TransactionMessage.Builder payload​(java.nio.ByteBuffer payload)
      Sets a payload of the transaction message.
    • payload

      public TransactionMessage.Builder payload​(com.google.protobuf.MessageLite payload)
      Sets a payload of the transaction message.
    • payload

      public TransactionMessage.Builder payload​(com.google.protobuf.ByteString payload)
      Sets a payload of the transaction message.
    • signedWith

      public TransactionMessage.Builder signedWith​(KeyPair keys)
      Sets the Ed25519 key pair to use to sign the message.
      Parameters:
      keys - a key pair with a private and public keys. The public key is included in the message as an author key of the message. The private key is used for signing the message, but not included in it
    • signedWith

      public TransactionMessage.Builder signedWith​(KeyPair keys, CryptoFunction crypto)
      Sets the key pair and the crypto function to use to sign the message.
      Parameters:
      keys - a key pair with a private and public keys. The public key is included in the message as an author key of the message. The private key is used for signing the message, but not included in it
      crypto - a cryptographic function to use
    • sign

      public TransactionMessage sign​(KeyPair keys)
      Signs the message with the given Ed25519 keys, creating a new signed binary transaction message. A shorthand for signedWith(keys).build().
      Parameters:
      keys - a key pair to sign the message
      Returns:
      a new signed binary transaction message
      Throws:
      java.lang.IllegalStateException - if any field weren't set
      java.lang.IllegalArgumentException - if the public key has wrong size
    • build

      public TransactionMessage build()
      Signs the message, creating a new signed binary transaction message.
      Returns:
      a new signed binary transaction message
      Throws:
      java.lang.IllegalStateException - if any field weren't set
      java.lang.IllegalArgumentException - if the public key has wrong size