core

## Package core

### Types

AccrualAdjustment | `enum class AccrualAdjustment` Simple enum for returning accurals adjusted or unadjusted. We dont actually do anything with this yet though, so its ignored for now.
Amount | `data class Amount : Comparable<Amount>` Amount represents a positive quantity of currency, measured in pennies, which are the smallest representable units.
Attachment | `interface Attachment : NamedByHash` An attachment is a ZIP (or an optionally signed JAR) that contains one or more files. Attachments are meant to contain public static data which can be referenced from transactions and utilised from contracts. Good examples of how attachments are meant to be used include:
AuthenticatedObject | `data class AuthenticatedObject<out T : Any>` Wraps an object that was signed by a public key, which may be a well known/recognised institutional key.
BusinessCalendar | `open class BusinessCalendar` A business calendar performs date calculations that take into account national holidays and weekends. This is a typical feature of financial contracts, in which a business may not want a payment event to fall on a day when no staff are around to handle problems.
Command | `data class Command` Command data/content plus pubkey pair: the signature is stored at the end of the serialized bytes
CommandData | `interface CommandData` Marker interface for classes that represent commands
Contract | `interface Contract` Implemented by a program that implements business logic on the shared ledger. All participants run this code for every LedgerTransaction they see on the network, for every input and output state. All contracts must accept the transaction for it to be accepted: failure of any aborts the entire thing. The time is taken from a trusted timestamp attached to the transaction itself i.e. it is NOT necessarily the current time.
ContractFactory | `interface ContractFactory` A contract factory knows how to lazily load and instantiate contract objects.
ContractState | `interface ContractState` A contract state (or just "state") contains opaque data used by a contract program. It can be thought of as a disk file that the program can use to persist data across transactions. States are immutable: once created they are never updated, instead, any changes must generate a new successor state.
DateOffset | `enum class DateOffset` Date offset that the fixing is done prior to the accrual start date. Currently not used in the calculation.
DateRollConvention | `enum class DateRollConvention` This reflects what happens if a date on which a business event is supposed to happen actually falls upon a non-working day Depending on the accounting requirement, we can move forward until we get to a business day, or backwards There are some additional rules which are explained in the individual cases below
DateRollDirection | `enum class DateRollDirection` This is utilised in the DateRollConvention class to determine which way we should initially step when finding a business day
DayCountBasisDay | `enum class DayCountBasisDay` This forms the day part of the "Day Count Basis" used for interest calculation.
DayCountBasisYear | `enum class DayCountBasisYear` This forms the year part of the "Day Count Basis" used for interest calculation.
Fix | `data class Fix : CommandData` A Fix represents a named interest rate, on a given day, for a given duration. It can be embedded in a tx.
FixOf | `data class FixOf` A FixOf identifies the question side of a fix: what day, tenor and type of fix ("LIBOR", "EURIBOR" etc)
Frequency | `enum class Frequency` Frequency at which an event occurs - the enumerator also casts to an integer specifying the number of times per year that would divide into (eg annually = 1, semiannual = 2, monthly = 12 etc).
LedgerTransaction | `data class LedgerTransaction` A LedgerTransaction wraps the data needed to calculate one or more successor states from a set of input states. It is the first step after extraction from a WireTransaction. The signatures at this point have been lined up with the commands from the wire, and verified/looked up.
NamedByHash | `interface NamedByHash` Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments).
OwnableState | `interface OwnableState : ContractState`
Party | `data class Party` A Party is well known (name, pubkey) pair. In a real system this would probably be an X.509 certificate.
PartyReference | `data class PartyReference` Reference to something being stored or issued by a party e.g. in a vault or (more likely) on their normal ledger. The reference is intended to be encrypted so its meaningless to anyone other than the party.
PaymentRule | `enum class PaymentRule` Whether the payment should be made before the due date, or after it.
Requirements | `class Requirements`
SignedTransaction | `data class SignedTransaction : NamedByHash` Container for a WireTransaction and attached signatures.
StateAndRef | `data class StateAndRef<out T : ContractState>` A StateAndRef is simply a (state, ref) pair. For instance, a wallet (which holds available assets) contains these.
StateRef | `data class StateRef` A stateref is a pointer (reference) to a state, this is an equivalent of an "outpoint" in Bitcoin. It records which transaction defined the state and where in that transaction it was.
Tenor | `data class Tenor` Placeholder class for the Tenor datatype - which is a standardised duration of time until maturity
ThreadBox | `class ThreadBox<T>` A threadbox is a simple utility that makes it harder to forget to take a lock before accessing some shared state. Simply define a private class to hold the data that must be grouped under the same lock, and then pass the only instance to the ThreadBox constructor. You can now use the locked method with a lambda to take the lock in a way that ensures itll be released if theres an exception.
TimestampCommand | `data class TimestampCommand : CommandData` If present in a transaction, contains a time that was verified by the timestamping authority/authorities whose public keys are identified in the containing Command object. The true time must be between (after, before)
TransactionBuilder | `class TransactionBuilder` A mutable transaction thats in the process of being built, before all signatures are present.
TransactionForVerification | `data class TransactionForVerification` A transaction in fully resolved and sig-checked form, ready for passing as input to a verification function.
TransactionGraphSearch | `class TransactionGraphSearch : Callable<List<WireTransaction>>` Given a map of transaction id to SignedTransaction, performs a breadth first search of the dependency graph from the starting point down in order to find transactions that match the given query criteria.
TransactionGroup | `class TransactionGroup` A TransactionGroup defines a directed acyclic graph of transactions that can be resolved with each other and then verified. Successful verification does not imply the non-existence of other conflicting transactions: simply that this subgraph does not contain conflicts and is accepted by the involved contracts.
TransientProperty | `class TransientProperty<T>` A simple wrapper that enables the use of Kotlins "val x by TransientProperty { ... }" syntax. Such a property will not be serialized to disk, and if its missing (or the first time its accessed), the initializer will be used to set it up. Note that the initializer will be called with the TransientProperty object locked.
TypeOnlyCommandData | `abstract class TypeOnlyCommandData : CommandData` Commands that inherit from this are intended to have no data items: its only their presence that matters.
WireTransaction | `data class WireTransaction : NamedByHash` Transaction ready for serialisation, without any signatures attached.

### Exceptions

TransactionConflictException | `class TransactionConflictException : Exception`
TransactionResolutionException | `class TransactionResolutionException : Exception`
TransactionVerificationException | `class TransactionVerificationException : Exception` Thrown if a verification fails due to a contract rejection.
UnknownContractException | `class UnknownContractException : Exception`

### Extensions for External Classes

java.nio.file.Path |
java.time.LocalDate |
java.time.temporal.Temporal |
kotlin.Double |
kotlin.Int |
kotlin.Long |
kotlin.String |
kotlin.collections.Iterable |
kotlin.collections.List |

### Properties

CHF | `val CHF: Currency`
GBP | `val GBP: Currency`
R | `val R: Requirements`
RunOnCallerThread | `val RunOnCallerThread: <ERROR CLASS>`
USD | `val USD: Currency`

### Functions

currency | `fun currency(code: String): Currency` Defines a simple domain specific language for the specificiation of financial contracts. Currently covers:
dayCountCalculator | `fun dayCountCalculator(startDate: LocalDate, endDate: LocalDate, dcbYear: DayCountBasisYear, dcbDay: DayCountBasisDay): BigDecimal`
extractZipFile | `fun extractZipFile(zipPath: Path, toPath: Path): Unit` Given a path to a zip file, extracts it to the given directory.
failure | `fun <T> <ERROR CLASS><T>.failure(executor: Executor, body: (Throwable) -> Unit): <ERROR CLASS>` `infix fun <T> <ERROR CLASS><T>.failure(body: (Throwable) -> Unit): <ERROR CLASS><T>`
hash | `fun ContractState.hash(): SecureHash` Returns the SHA-256 hash of the serialised contents of this state (not cached)
logElapsedTime | `fun <T> logElapsedTime(label: String, logger: <ERROR CLASS>? = null, body: () -> T): T`
random63BitValue | `fun random63BitValue(): Long` Returns a random positive long generated using a secure RNG. This function sacrifies a bit of entropy in order to avoid potential bugs where the value is used in a context where negative numbers are not expected.
requireThat | `fun <R> requireThat(body: Requirements.() -> R): R`
setFrom | `fun <T> <ERROR CLASS><T>.setFrom(logger: <ERROR CLASS>? = null, block: () -> T): <ERROR CLASS><T>` Executes the given block and sets the future to either the result, or any exception that was thrown.
success | `fun <T> <ERROR CLASS><T>.success(executor: Executor, body: (T) -> Unit): <ERROR CLASS>` `infix fun <T> <ERROR CLASS><T>.success(body: (T) -> Unit): <ERROR CLASS><T>`
then | `fun <T> <ERROR CLASS><T>.then(executor: Executor, body: () -> Unit): <ERROR CLASS>` `infix fun <T> <ERROR CLASS><T>.then(body: () -> Unit): <ERROR CLASS><T>`
toLedgerTransaction | `fun WireTransaction.toLedgerTransaction(identityService: IdentityService, attachmentStorage: AttachmentStorage): LedgerTransaction` Looks up identities and attachments from storage to generate a LedgerTransaction.
verifyToLedgerTransaction | `fun SignedTransaction.verifyToLedgerTransaction(identityService: IdentityService, attachmentStorage: AttachmentStorage): LedgerTransaction` Calls verify to check all required signatures are present, and then uses the passed IdentityService to call WireTransaction.toLedgerTransaction to look up well known identities from pubkeys.