Type alias CompilationData<CompilationContext>

CompilationData<CompilationContext>: {
    bytecode?: {
        [fullIdentifier: string]: Uint8Array;
    };
    compilationContext?: CompilationContext;
    currentBlockHeight?: number;
    currentBlockTime?: number;
    hdKeys?: {
        addressIndex?: number;
        hdPrivateKeys?: {
            [entityId: string]: string;
        };
        hdPublicKeys?: {
            [entityId: string]: string;
        };
    };
    keys?: {
        privateKeys?: {
            [variableId: string]: Uint8Array;
        };
    };
}

Data required at compilation time to generate the bytecode for a particular CashAssembly Template script.

Type Parameters

Type declaration

  • Optional bytecode?: {
        [fullIdentifier: string]: Uint8Array;
    }

    A map of full identifiers to pre-computed bytecode for this compilation.

    This is always used to provide bytecode for AddressData and WalletData, and it can also be used to provide public keys and signatures that have been pre-computed by other entities (e.g. when computing these would require access to private keys held by another entity).

    The provided fullIdentifier should match the complete identifier for each item, e.g. some_wallet_data, variable_id.public_key, or variable_id.schnorr_signature.all_outputs.

    To provide AddressData or WalletData from advanced user interfaces, consider parsing input with compileCashAssembly.

    Remarks

    It is security-critical that only identifiers provided by the entities expected to provide them are included here. For example:

    1. When generating a lockingBytecode for a 2-of-2 wallet, a malicious entity could provide a pre-computed value for us.public_key that is equal to them.public_key such that the resulting lockingBytecode is entirely controlled by that entity.

    2. When generating an unlockingBytecode that includes a data signature, if a malicious entity can provide a pre-computed value for identifiers present in the message, the malicious entity can trick the compiling entity into signing an unintended message, e.g. creating a false attestation or releasing funds from an unrelated wallet. (This can be partially mitigated by avoiding key reuse.)

    To safely include identifiers from external entities, the compilation must first be evaluated only with trusted information (variables owned by or previously validated by the compiling entity). On unsuccessful compilations, missing variables can be extracted with extractMissingVariables, and each missing variable should be filled only by bytecode values provided by entities from which they were expected.

    • [fullIdentifier: string]: Uint8Array
  • Optional compilationContext?: CompilationContext

    The CompilationContext expected by this particular compiler for any operations used in the compilation.

  • Optional currentBlockHeight?: number

    The current block height at address creation time.

  • Optional currentBlockTime?: number

    The current MTP block time as a UNIX timestamp at address creation time.

    Note, this is never a current timestamp, but rather the median timestamp of the last 11 blocks. It is therefore approximately one hour in the past.

    Every block has a precise MTP block time, much like a block height. See BIP113 for details.

  • Optional hdKeys?: {
        addressIndex?: number;
        hdPrivateKeys?: {
            [entityId: string]: string;
        };
        hdPublicKeys?: {
            [entityId: string]: string;
        };
    }

    An object describing the settings used for WalletTemplateHdKey variables in this compilation.

    • Optional addressIndex?: number

      The current address index to be used for this compilation. The addressIndex gets added to each WalletTemplateHdKey.addressOffset to calculate the dynamic index (i) used in each WalletTemplateHdKey.privateDerivationPath or WalletTemplateHdKey.publicDerivationPath.

      This is required for any compiler operation that requires derivation. Typically, the value is incremented by one for each address in a wallet.

    • Optional hdPrivateKeys?: {
          [entityId: string]: string;
      }

      A map of entity IDs to HD private keys. These HD private keys are used to derive each HdKey variable assigned to that entity (as specified in CompilerConfiguration.entityOwnership) according to its WalletTemplateHdKey.privateDerivationPath.

      HD private keys may be encoded for either mainnet or testnet (the network information is ignored).

      If both an HD private key (in hdPrivateKeys) and HD public key (in hdPublicKeys) are provided for the same entity in the same compilation (not recommended), only the HD private key is used.

      • [entityId: string]: string
    • Optional hdPublicKeys?: {
          [entityId: string]: string;
      }

      A map of entity IDs to HD public keys. These HD public keys are used to derive public keys for each HdKey variable assigned to that entity (as specified in CompilerConfiguration.entityOwnership) according to its WalletTemplateHdKey.publicDerivationPath.

      HD public keys may be encoded for either mainnet or testnet (the network information is ignored).

      If both an HD private key (in hdPrivateKeys) and HD public key (in hdPublicKeys) are provided for the same entity in the same compilation (not recommended), the HD private key is used.

      • [entityId: string]: string
  • Optional keys?: {
        privateKeys?: {
            [variableId: string]: Uint8Array;
        };
    }

    An object describing the settings used for WalletTemplateKey variables in this compilation.

    Note that public keys are not provided in this object. Instead, public keys are provided directly via the bytecode object; this is because – much like signatures or address data – public keys require no further processing by collaborating entities once shared by their owning entity.

    • Optional privateKeys?: {
          [variableId: string]: Uint8Array;
      }

      A map of Key variable IDs to their private keys for this compilation.

      • [variableId: string]: Uint8Array

Generated using TypeDoc