syntax = "proto3";

package com.hedera.hapi.node.addressbook;

// SPDX-License-Identifier: Apache-2.0
option java_package = "com.hederahashgraph.api.proto.java";
// <<<pbj.java_package = "com.hedera.hapi.node.addressbook">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

import "services_basic_types.proto";

/**
 * A transaction body to add a new consensus node to the network address book.
 *
 * This transaction body SHALL be considered a "privileged transaction".
 *
 * This message supports a transaction to create a new node in the network
 * address book. The transaction, once complete, enables a new consensus node
 * to join the network, and requires governing council authorization.
 *
 * - A `NodeCreateTransactionBody` MUST be signed by the `Key` assigned to the
 *   `admin_key` field and one of those keys: treasure account (2) key,
 *   systemAdmin(50) key, or addressBookAdmin(55) key.
 * - The newly created node information SHALL be added to the network address
 *   book information in the network state.
 * - The new entry SHALL be created in "state" but SHALL NOT participate in
 *   network consensus and SHALL NOT be present in network "configuration"
 *   until the next "upgrade" transaction (as noted below).
 * - All new address book entries SHALL be added to the active network
 *   configuration during the next `freeze` transaction with the field
 *   `freeze_type` set to `PREPARE_UPGRADE`.
 *
 * ### Block Stream Effects
 * Upon completion the newly assigned `node_id` SHALL be recorded in
 * the transaction receipt.<br/>
 * This value SHALL be the next available node identifier.<br/>
 * Node identifiers SHALL NOT be reused.
 */
message NodeCreateTransactionBody {
    /**
     * A Node account identifier.
     * <p>
     * This account identifier MUST be in the "account number" form.<br/>
     * This account identifier MUST NOT use the alias field.<br/>
     * If the identified account does not exist, this transaction SHALL fail.<br/>
     * Multiple nodes MAY share the same node account.<br/>
     * This field is REQUIRED.
     */
    proto.AccountID account_id = 1;

    /**
     * A short description of the node.
     * <p>
     * This value, if set, MUST NOT exceed `transaction.maxMemoUtf8Bytes`
     * (default 100) bytes when encoded as UTF-8.<br/>
     * This field is OPTIONAL.
     */
    string description = 2;

    /**
     * A list of service endpoints for gossip.
     * <p>
     * These endpoints SHALL represent the published endpoints to which other
     * consensus nodes may _gossip_ transactions.<br/>
     * These endpoints MUST specify a port.<br/>
     * This list MUST NOT be empty.<br/>
     * This list MUST NOT contain more than `10` entries.<br/>
     * The first two entries in this list SHALL be the endpoints published to
     * all consensus nodes.<br/>
     * All other entries SHALL be reserved for future use.
     * <p>
     * Each network may have additional requirements for these endpoints.
     * A client MUST check network-specific documentation for those
     * details.<br/>
     * If the network configuration value `gossipFqdnRestricted` is set, then
     * all endpoints in this list MUST supply only IP address.<br/>
     * If the network configuration value `gossipFqdnRestricted` is _not_ set,
     * then endpoints in this list MAY supply either IP address or FQDN, but
     * MUST NOT supply both values for the same endpoint.
     */
    repeated proto.ServiceEndpoint gossip_endpoint = 3;

    /**
     * A list of service endpoints for gRPC calls.
     * <p>
     * These endpoints SHALL represent the published gRPC endpoints to which
     * clients may submit transactions.<br/>
     * These endpoints MUST specify a port.<br/>
     * Endpoints in this list MAY supply either IP address or FQDN, but MUST
     * NOT supply both values for the same endpoint.<br/>
     * This list MUST NOT be empty.<br/>
     * This list MUST NOT contain more than `8` entries.
     */
    repeated proto.ServiceEndpoint service_endpoint = 4;

    /**
     * A certificate used to sign gossip events.
     * <p>
     * This value MUST be a certificate of a type permitted for gossip
     * signatures.<br/>
     * This value MUST be the DER encoding of the certificate presented.<br/>
     * This field is REQUIRED and MUST NOT be empty.
     */
    bytes gossip_ca_certificate = 5;

    /**
     * A hash of the node gRPC TLS certificate.
     * <p>
     * This value MAY be used to verify the certificate presented by the node
     * during TLS negotiation for gRPC.<br/>
     * This value MUST be a SHA-384 hash.<br/>
     * The TLS certificate to be hashed MUST first be in PEM format and MUST be
     * encoded with UTF-8 NFKD encoding to a stream of bytes provided to
     * the hash algorithm.<br/>
     * This field is OPTIONAL.
     */
    bytes grpc_certificate_hash = 6;

    /**
     * An administrative key controlled by the node operator.
     * <p>
     * This key MUST sign this transaction.<br/>
     * This key MUST sign each transaction to update this node.<br/>
     * This field MUST contain a valid `Key` value.<br/>
     * This field is REQUIRED and MUST NOT be set to an empty `KeyList`.
     */
    proto.Key admin_key = 7;

    /**
     * A boolean flag indicating whether the node operator declines to receive
     * node rewards.
     * <p>
     * If this flag is set to `true`, the node operator declines to receive
     * node rewards.<br/>
     */
    bool decline_reward = 8;

    /**
     * A web proxy for gRPC from non-gRPC clients.
     * <p>
     * This endpoint SHALL be a Fully Qualified Domain Name (FQDN) using the HTTPS
     * protocol, and SHALL support gRPC-Web for use by browser-based clients.<br/>
     * This endpoint MUST be signed by a trusted certificate authority.<br/>
     * This endpoint MUST use a valid port and SHALL be reachable over TLS.<br/>
     * This field MAY be omitted if the node does not support gRPC-Web access.<br/>
     * This field MUST be updated if the gRPC-Web endpoint changes.<br/>
     * This field SHALL enable frontend clients to avoid hard-coded proxy endpoints.
     */
    proto.ServiceEndpoint grpc_proxy_endpoint = 9;
}
