com.r3corda.core.contracts

## Package com.r3corda.core.contracts

### 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.
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. Note that the first character cannot be a number (enum naming constraints), so we drop that in the toString lest some people get confused.
DayCountBasisYear | `enum class DayCountBasisYear` This forms the year part of the "Day Count Basis" used for interest calculation.
DealState | `interface DealState : LinearState` Interface representing an agreement that exposes various attributes that are common. Implementing it simplifies implementation of general protocols that manipulate many agreement types.
Expression | `data class Expression` Represents a textual expression of e.g. a formula
ExpressionDeserializer | `object ExpressionDeserializer`
ExpressionSerializer | `object ExpressionSerializer`
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)
FixableDealState | `interface FixableDealState : DealState` Interface adding fixing specific methods
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).
IssuanceDefinition | `interface IssuanceDefinition` Marker interface for data classes that represent the issuance state for a contract. These are intended as templates from which the state object is initialised.
LedgerTransaction | `data class LedgerTransaction : NamedByHash` 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.
LinearState | `interface LinearState : ContractState` A state that evolves by superseding itself, all of which share the common "thread"
NamedByHash | `interface NamedByHash` Implemented by anything that can be named by a secure hash value (e.g. transactions, attachments).
OwnableState | `interface OwnableState : ContractState` A contract state that can have a single owner.
PartyAndReference | `data class PartyAndReference` 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
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 TransactionBuilder is a transaction class thats mutable (unlike the others which are all immutable). It is intended to be passed around contracts that may edit it by adding new states/commands or modifying the existing set. Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties.
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.
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 | `sealed class TransactionVerificationException : Exception`

### Extensions for External Classes

java.time.LocalDate |
kotlin.Double |
kotlin.Int |
kotlin.collections.Iterable |
kotlin.collections.List |

### Properties

CHF | `val CHF: Currency`
GBP | `val GBP: Currency`
R | `val R: Requirements`
USD | `val USD: Currency`

### Functions

calculateDaysBetween | `fun calculateDaysBetween(startDate: LocalDate, endDate: LocalDate, dcbYear: DayCountBasisYear, dcbDay: DayCountBasisDay): Int`
currency | `fun currency(code: String): Currency` Defines a simple domain specific language for the specificiation of financial contracts. Currently covers:
hash | `fun ContractState.hash(): SecureHash` Returns the SHA-256 hash of the serialised contents of this state (not cached)
requireThat | `fun <R> requireThat(body: Requirements.() -> R): R`
toLedgerTransaction | `fun WireTransaction.toLedgerTransaction(identityService: IdentityService, attachmentStorage: AttachmentStorage): LedgerTransaction` Looks up identities and attachments from storage to generate a LedgerTransaction.
verifyMoveCommands | `fun <T : CommandData> verifyMoveCommands(inputs: List<OwnableState>, tx: TransactionForVerification): Unit` Simple functionality for verifying a move command. Verifies that each input has a signature from its owning key.
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.