mirror of
https://github.com/corda/corda.git
synced 2025-02-04 18:22:29 +00:00
Replace Party with Party.Full
Replace Party with Party.Full as an interim step to introducing the Party.Anonymised class. Signed-off-by: Ross Nicoll <ross.nicoll@r3.com>
This commit is contained in:
parent
3572b78372
commit
1b86ddfd6e
@ -13,10 +13,10 @@ import java.util.*
|
||||
* state/ref pairs, but it doesn't necessarily generate "correct" events!
|
||||
*/
|
||||
class EventGenerator(
|
||||
val parties: List<Party>,
|
||||
val notary: Party,
|
||||
val parties: List<Party.Full>,
|
||||
val notary: Party.Full,
|
||||
val currencies: List<Currency> = listOf(USD, GBP, CHF),
|
||||
val issuers: List<Party> = parties
|
||||
val issuers: List<Party.Full> = parties
|
||||
) {
|
||||
private var vault = listOf<StateAndRef<Cash.State>>()
|
||||
|
||||
|
@ -65,7 +65,7 @@ inline fun <R> requireThat(body: Requirements.() -> R) = Requirements.body()
|
||||
|
||||
/** Filters the command list by type, party and public key all at once. */
|
||||
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.select(signer: CompositeKey? = null,
|
||||
party: Party? = null) =
|
||||
party: Party.Full? = null) =
|
||||
filter { it.value is T }.
|
||||
filter { if (signer == null) true else signer in it.signers }.
|
||||
filter { if (party == null) true else party in it.signingParties }.
|
||||
@ -75,7 +75,7 @@ inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>
|
||||
|
||||
/** Filters the command list by type, parties and public keys all at once. */
|
||||
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.select(signers: Collection<CompositeKey>?,
|
||||
parties: Collection<Party>?) =
|
||||
parties: Collection<Party.Full>?) =
|
||||
filter { it.value is T }.
|
||||
filter { if (signers == null) true else it.signers.containsAll(signers) }.
|
||||
filter { if (parties == null) true else it.signingParties.containsAll(parties) }.
|
||||
|
@ -46,7 +46,7 @@ data class DummyContract(override val legalContractReference: SecureHash = Secur
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder {
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party.Full): TransactionBuilder {
|
||||
val state = SingleOwnerState(magicNumber, owner.party.owningKey)
|
||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.Create(), owner.party.owningKey))
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ data class TransactionState<out T : ContractState> @JvmOverloads constructor(
|
||||
/** The custom contract state */
|
||||
val data: T,
|
||||
/** Identity of the notary that ensures the state is not used as an input to a transaction more than once */
|
||||
val notary: Party,
|
||||
val notary: Party.Full,
|
||||
/**
|
||||
* All contract states may be _encumbered_ by up to one other state.
|
||||
*
|
||||
@ -148,13 +148,13 @@ data class TransactionState<out T : ContractState> @JvmOverloads constructor(
|
||||
* Copies the underlying state, replacing the notary field with the new value.
|
||||
* To replace the notary, we need an approval (signature) from _all_ participants of the [ContractState].
|
||||
*/
|
||||
fun withNotary(newNotary: Party) = TransactionState(this.data, newNotary, encumbrance)
|
||||
fun withNotary(newNotary: Party.Full) = TransactionState(this.data, newNotary, encumbrance)
|
||||
}
|
||||
|
||||
/** Wraps the [ContractState] in a [TransactionState] object */
|
||||
infix fun <T : ContractState> T.`with notary`(newNotary: Party) = withNotary(newNotary)
|
||||
infix fun <T : ContractState> T.`with notary`(newNotary: Party.Full) = withNotary(newNotary)
|
||||
|
||||
infix fun <T : ContractState> T.withNotary(newNotary: Party) = TransactionState(this, newNotary)
|
||||
infix fun <T : ContractState> T.withNotary(newNotary: Party.Full) = TransactionState(this, newNotary)
|
||||
|
||||
/**
|
||||
* Marker interface for data classes that represent the issuance state for a contract. These are intended as templates
|
||||
@ -280,7 +280,7 @@ interface DealState : LinearState {
|
||||
* Exposes the Parties involved in a generic way.
|
||||
*
|
||||
* Appears to duplicate [participants] a property of [ContractState]. However [participants] only holds public keys.
|
||||
* Currently we need to hard code Party objects into [ContractState]s. [Party] objects are a wrapper for public
|
||||
* Currently we need to hard code Party objects into [ContractState]s. [Party.Full] objects are a wrapper for public
|
||||
* keys which also contain some identity information about the public key owner. You can keep track of individual
|
||||
* parties by adding a property for each one to the state, or you can append parties to the [parties] list if you
|
||||
* are implementing [DealState]. We need to do this as identity management in Corda is currently incomplete,
|
||||
@ -289,7 +289,7 @@ interface DealState : LinearState {
|
||||
* separate process exchange certificates to ascertain identities. Thus decoupling identities from
|
||||
* [ContractState]s.
|
||||
* */
|
||||
val parties: List<Party>
|
||||
val parties: List<Party.Full>
|
||||
|
||||
/**
|
||||
* Generate a partial transaction representing an agreement (command) to this deal, allowing a general
|
||||
@ -300,7 +300,7 @@ interface DealState : LinearState {
|
||||
* TODO: This should more likely be a method on the Contract (on a common interface) and the changes to reference a
|
||||
* Contract instance from a ContractState are imminent, at which point we can move this out of here.
|
||||
*/
|
||||
fun generateAgreement(notary: Party): TransactionBuilder
|
||||
fun generateAgreement(notary: Party.Full): TransactionBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,7 +349,7 @@ inline fun <reified T : ContractState> Iterable<StateAndRef<ContractState>>.filt
|
||||
* 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 it's meaningless to anyone other than the party.
|
||||
*/
|
||||
data class PartyAndReference(val party: Party, val reference: OpaqueBytes) {
|
||||
data class PartyAndReference(val party: Party.Full, val reference: OpaqueBytes) {
|
||||
override fun toString() = "${party.name}$reference"
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ interface NetCommand : CommandData {
|
||||
data class AuthenticatedObject<out T : Any>(
|
||||
val signers: List<CompositeKey>,
|
||||
/** If any public keys were recognised, the looked up institutions are available here */
|
||||
val signingParties: List<Party>,
|
||||
val signingParties: List<Party.Full>,
|
||||
val value: T
|
||||
)
|
||||
|
||||
|
@ -62,7 +62,7 @@ sealed class TransactionType {
|
||||
/** A general transaction type where transaction validity is determined by custom contract code */
|
||||
class General : TransactionType() {
|
||||
/** Just uses the default [TransactionBuilder] with no special logic */
|
||||
class Builder(notary: Party?) : TransactionBuilder(General(), notary) {}
|
||||
class Builder(notary: Party.Full?) : TransactionBuilder(General(), notary) {}
|
||||
|
||||
override fun verifyTransaction(tx: LedgerTransaction) {
|
||||
verifyNoNotaryChange(tx)
|
||||
@ -143,7 +143,7 @@ sealed class TransactionType {
|
||||
* A transaction builder that automatically sets the transaction type to [NotaryChange]
|
||||
* and adds the list of participants to the signers set for every input state.
|
||||
*/
|
||||
class Builder(notary: Party) : TransactionBuilder(NotaryChange(), notary) {
|
||||
class Builder(notary: Party.Full) : TransactionBuilder(NotaryChange(), notary) {
|
||||
override fun addInputState(stateAndRef: StateAndRef<*>) {
|
||||
signers.addAll(stateAndRef.state.data.participants)
|
||||
super.addInputState(stateAndRef)
|
||||
|
@ -17,7 +17,7 @@ data class TransactionForContract(val inputs: List<ContractState>,
|
||||
val attachments: List<Attachment>,
|
||||
val commands: List<AuthenticatedObject<CommandData>>,
|
||||
val origHash: SecureHash,
|
||||
val inputNotary: Party? = null,
|
||||
val inputNotary: Party.Full? = null,
|
||||
val timestamp: Timestamp? = null) {
|
||||
override fun hashCode() = origHash.hashCode()
|
||||
override fun equals(other: Any?) = other is TransactionForContract && other.origHash == origHash
|
||||
@ -102,7 +102,7 @@ sealed class TransactionVerificationException(val tx: LedgerTransaction, cause:
|
||||
}
|
||||
|
||||
class InvalidNotaryChange(tx: LedgerTransaction) : TransactionVerificationException(tx, null)
|
||||
class NotaryChangeInWrongTransactionType(tx: LedgerTransaction, val outputNotary: Party) : TransactionVerificationException(tx, null) {
|
||||
class NotaryChangeInWrongTransactionType(tx: LedgerTransaction, val outputNotary: Party.Full) : TransactionVerificationException(tx, null) {
|
||||
override fun toString(): String = "Found unexpected notary change in transaction. Tx notary: ${tx.notary}, found: ${outputNotary}"
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ open class DigitalSignature(bits: ByteArray) : OpaqueBytes(bits) {
|
||||
}
|
||||
|
||||
// TODO: consider removing this as whoever needs to identify the signer should be able to derive it from the public key
|
||||
class LegallyIdentifiable(val signer: Party, bits: ByteArray) : WithKey(signer.owningKey.singleKey, bits)
|
||||
class LegallyIdentifiable(val signer: Party.Full, bits: ByteArray) : WithKey(signer.owningKey.singleKey, bits)
|
||||
}
|
||||
|
||||
object NullPublicKey : PublicKey, Comparable<PublicKey> {
|
||||
@ -81,8 +81,8 @@ fun PublicKey.toBase58String() = Base58.encode((this as EdDSAPublicKey).abyte)
|
||||
|
||||
fun KeyPair.signWithECDSA(bytesToSign: ByteArray) = private.signWithECDSA(bytesToSign, public)
|
||||
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes) = private.signWithECDSA(bytesToSign.bytes, public)
|
||||
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes, party: Party) = signWithECDSA(bytesToSign.bytes, party)
|
||||
fun KeyPair.signWithECDSA(bytesToSign: ByteArray, party: Party): DigitalSignature.LegallyIdentifiable {
|
||||
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes, party: Party.Full) = signWithECDSA(bytesToSign.bytes, party)
|
||||
fun KeyPair.signWithECDSA(bytesToSign: ByteArray, party: Party.Full): DigitalSignature.LegallyIdentifiable {
|
||||
check(public in party.owningKey.keys)
|
||||
val sig = signWithECDSA(bytesToSign)
|
||||
return DigitalSignature.LegallyIdentifiable(party, sig.bytes)
|
||||
|
@ -22,15 +22,18 @@ import java.security.PublicKey
|
||||
*
|
||||
* @see CompositeKey
|
||||
*/
|
||||
class Party(val name: String, val owningKey: CompositeKey) {
|
||||
/** A helper constructor that converts the given [PublicKey] in to a [CompositeKey] with a single node */
|
||||
constructor(name: String, owningKey: PublicKey) : this(name, owningKey.composite)
|
||||
|
||||
sealed class Party(val owningKey: CompositeKey) {
|
||||
/** Anonymised parties do not include any detail apart from owning key, so equality is dependent solely on the key */
|
||||
override fun equals(other: Any?): Boolean = other is Party && this.owningKey == other.owningKey
|
||||
override fun hashCode(): Int = owningKey.hashCode()
|
||||
override fun toString() = name
|
||||
|
||||
fun ref(bytes: OpaqueBytes) = PartyAndReference(this, bytes)
|
||||
fun ref(vararg bytes: Byte) = ref(OpaqueBytes.of(*bytes))
|
||||
override fun hashCode(): Int = owningKey.hashCode()
|
||||
|
||||
class Full(val name: String, owningKey: CompositeKey) : Party(owningKey) {
|
||||
/** A helper constructor that converts the given [PublicKey] in to a [CompositeKey] with a single node */
|
||||
constructor(name: String, owningKey: PublicKey) : this(name, owningKey.composite)
|
||||
override fun toString() = name
|
||||
|
||||
fun ref(bytes: OpaqueBytes) = PartyAndReference(this, bytes)
|
||||
fun ref(vararg bytes: Byte) = ref(OpaqueBytes.of(*bytes))
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ abstract class FlowLogic<out T> {
|
||||
* other side. The default implementation returns the class object of this FlowLogic, but any [Class] instance
|
||||
* will do as long as the other side registers with it.
|
||||
*/
|
||||
open fun getCounterpartyMarker(party: Party): Class<*> = javaClass
|
||||
open fun getCounterpartyMarker(party: Party.Full): Class<*> = javaClass
|
||||
|
||||
/**
|
||||
* Serializes and queues the given [payload] object for sending to the [otherParty]. Suspends until a response
|
||||
@ -59,7 +59,7 @@ abstract class FlowLogic<out T> {
|
||||
*
|
||||
* @returns an [UntrustworthyData] wrapper around the received object.
|
||||
*/
|
||||
inline fun <reified R : Any> sendAndReceive(otherParty: Party, payload: Any) = sendAndReceive(R::class.java, otherParty, payload)
|
||||
inline fun <reified R : Any> sendAndReceive(otherParty: Party.Full, payload: Any) = sendAndReceive(R::class.java, otherParty, payload)
|
||||
|
||||
/**
|
||||
* Serializes and queues the given [payload] object for sending to the [otherParty]. Suspends until a response
|
||||
@ -73,7 +73,7 @@ abstract class FlowLogic<out T> {
|
||||
* @returns an [UntrustworthyData] wrapper around the received object.
|
||||
*/
|
||||
@Suspendable
|
||||
open fun <R : Any> sendAndReceive(receiveType: Class<R>, otherParty: Party, payload: Any): UntrustworthyData<R> {
|
||||
open fun <R : Any> sendAndReceive(receiveType: Class<R>, otherParty: Party.Full, payload: Any): UntrustworthyData<R> {
|
||||
return stateMachine.sendAndReceive(receiveType, otherParty, payload, sessionFlow)
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ abstract class FlowLogic<out T> {
|
||||
* verified for consistency and that all expectations are satisfied, as a malicious peer may send you subtly
|
||||
* corrupted data in order to exploit your code.
|
||||
*/
|
||||
inline fun <reified R : Any> receive(otherParty: Party): UntrustworthyData<R> = receive(R::class.java, otherParty)
|
||||
inline fun <reified R : Any> receive(otherParty: Party.Full): UntrustworthyData<R> = receive(R::class.java, otherParty)
|
||||
|
||||
/**
|
||||
* Suspends until the specified [otherParty] sends us a message of type [receiveType].
|
||||
@ -96,7 +96,7 @@ abstract class FlowLogic<out T> {
|
||||
* @returns an [UntrustworthyData] wrapper around the received object.
|
||||
*/
|
||||
@Suspendable
|
||||
open fun <R : Any> receive(receiveType: Class<R>, otherParty: Party): UntrustworthyData<R> {
|
||||
open fun <R : Any> receive(receiveType: Class<R>, otherParty: Party.Full): UntrustworthyData<R> {
|
||||
return stateMachine.receive(receiveType, otherParty, sessionFlow)
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ abstract class FlowLogic<out T> {
|
||||
* network's event horizon time.
|
||||
*/
|
||||
@Suspendable
|
||||
open fun send(otherParty: Party, payload: Any) = stateMachine.send(otherParty, payload, sessionFlow)
|
||||
open fun send(otherParty: Party.Full, payload: Any) = stateMachine.send(otherParty, payload, sessionFlow)
|
||||
|
||||
/**
|
||||
* Invokes the given subflow. This function returns once the subflow completes successfully with the result
|
||||
|
@ -25,15 +25,15 @@ data class StateMachineRunId private constructor(val uuid: UUID) {
|
||||
interface FlowStateMachine<R> {
|
||||
@Suspendable
|
||||
fun <T : Any> sendAndReceive(receiveType: Class<T>,
|
||||
otherParty: Party,
|
||||
otherParty: Party.Full,
|
||||
payload: Any,
|
||||
sessionFlow: FlowLogic<*>): UntrustworthyData<T>
|
||||
|
||||
@Suspendable
|
||||
fun <T : Any> receive(receiveType: Class<T>, otherParty: Party, sessionFlow: FlowLogic<*>): UntrustworthyData<T>
|
||||
fun <T : Any> receive(receiveType: Class<T>, otherParty: Party.Full, sessionFlow: FlowLogic<*>): UntrustworthyData<T>
|
||||
|
||||
@Suspendable
|
||||
fun send(otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>)
|
||||
fun send(otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>)
|
||||
|
||||
val serviceHub: ServiceHub
|
||||
val logger: Logger
|
||||
|
@ -114,14 +114,14 @@ interface CordaRPCOps : RPCOps {
|
||||
// TODO These need rethinking. Instead of these direct calls we should have a way of replicating a subset of
|
||||
// the node's state locally and query that directly.
|
||||
/**
|
||||
* Returns the [Party] corresponding to the given key, if found.
|
||||
* Returns the [Party.Full] corresponding to the given key, if found.
|
||||
*/
|
||||
fun partyFromKey(key: CompositeKey): Party?
|
||||
fun partyFromKey(key: CompositeKey): Party.Full?
|
||||
|
||||
/**
|
||||
* Returns the [Party] with the given name as it's [Party.name]
|
||||
* Returns the [Party.Full] with the given name as it's [Party.name]
|
||||
*/
|
||||
fun partyFromName(name: String): Party?
|
||||
fun partyFromName(name: String): Party.Full?
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,19 +9,19 @@ import net.corda.core.node.services.ServiceType
|
||||
* Information for an advertised service including the service specific identity information.
|
||||
* The identity can be used in flows and is distinct from the Node's legalIdentity
|
||||
*/
|
||||
data class ServiceEntry(val info: ServiceInfo, val identity: Party)
|
||||
data class ServiceEntry(val info: ServiceInfo, val identity: Party.Full)
|
||||
|
||||
/**
|
||||
* Info about a network node that acts on behalf of some form of contract party.
|
||||
*/
|
||||
data class NodeInfo(val address: SingleMessageRecipient,
|
||||
val legalIdentity: Party,
|
||||
val legalIdentity: Party.Full,
|
||||
var advertisedServices: List<ServiceEntry> = emptyList(),
|
||||
val physicalLocation: PhysicalLocation? = null) {
|
||||
init {
|
||||
require(advertisedServices.none { it.identity == legalIdentity }) { "Service identities must be different from node legal identity" }
|
||||
}
|
||||
|
||||
val notaryIdentity: Party get() = advertisedServices.single { it.info.type.isNotary() }.identity
|
||||
fun serviceIdentities(type: ServiceType): List<Party> = advertisedServices.filter { it.info.type.isSubTypeOf(type) }.map { it.identity }
|
||||
val notaryIdentity: Party.Full get() = advertisedServices.single { it.info.type.isNotary() }.identity
|
||||
fun serviceIdentities(type: ServiceType): List<Party.Full> = advertisedServices.filter { it.info.type.isSubTypeOf(type) }.map { it.identity }
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ interface PluginServiceHub : ServiceHub {
|
||||
*/
|
||||
|
||||
// TODO: remove dependency on Kotlin relfection (Kotlin KClass -> Java Class).
|
||||
fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party) -> FlowLogic<*>)
|
||||
fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party.Full) -> FlowLogic<*>)
|
||||
|
||||
/**
|
||||
* Return the flow factory that has been registered with [markerClass], or null if no factory is found.
|
||||
*/
|
||||
fun getFlowFactory(markerClass: Class<*>): ((Party) -> FlowLogic<*>)?
|
||||
fun getFlowFactory(markerClass: Class<*>): ((Party.Full) -> FlowLogic<*>)?
|
||||
}
|
||||
|
@ -4,22 +4,22 @@ import net.corda.core.crypto.CompositeKey
|
||||
import net.corda.core.crypto.Party
|
||||
|
||||
/**
|
||||
* An identity service maintains an bidirectional map of [Party]s to their associated public keys and thus supports
|
||||
* An identity service maintains an bidirectional map of [Party.Full]s to their associated public keys and thus supports
|
||||
* lookup of a party given its key. This is obviously very incomplete and does not reflect everything a real identity
|
||||
* service would provide.
|
||||
*/
|
||||
interface IdentityService {
|
||||
fun registerIdentity(party: Party)
|
||||
fun registerIdentity(party: Party.Full)
|
||||
/**
|
||||
* Get all identities known to the service. This is expensive, and [partyFromKey] or [partyFromName] should be
|
||||
* used in preference where possible.
|
||||
*/
|
||||
fun getAllIdentities(): Iterable<Party>
|
||||
fun getAllIdentities(): Iterable<Party.Full>
|
||||
|
||||
// There is no method for removing identities, as once we are made aware of a Party we want to keep track of them
|
||||
// indefinitely. It may be that in the long term we need to drop or archive very old Party information for space,
|
||||
// but for now this is not supported.
|
||||
|
||||
fun partyFromKey(key: CompositeKey): Party?
|
||||
fun partyFromName(name: String): Party?
|
||||
fun partyFromKey(key: CompositeKey): Party.Full?
|
||||
fun partyFromName(name: String): Party.Full?
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ interface NetworkMapCache {
|
||||
* Implementations might understand, for example, the correct regulator to use for specific contracts/parties,
|
||||
* or the appropriate oracle for a contract.
|
||||
*/
|
||||
fun getRecommended(type: ServiceType, contract: Contract, vararg party: Party): NodeInfo? = getNodesWithService(type).firstOrNull()
|
||||
fun getRecommended(type: ServiceType, contract: Contract, vararg party: Party.Full): NodeInfo? = getNodesWithService(type).firstOrNull()
|
||||
|
||||
/** Look up the node info for a legal name. */
|
||||
fun getNodeByLegalName(name: String): NodeInfo? = partyNodes.singleOrNull { it.legalIdentity.name == name }
|
||||
@ -87,7 +87,7 @@ interface NetworkMapCache {
|
||||
fun getPartyInfo(party: Party): PartyInfo?
|
||||
|
||||
/** Gets a notary identity by the given name. */
|
||||
fun getNotary(name: String): Party? {
|
||||
fun getNotary(name: String): Party.Full? {
|
||||
val notaryNode = notaryNodes.randomOrNull {
|
||||
it.advertisedServices.any { it.info.type.isSubTypeOf(ServiceType.notary) && it.info.name == name }
|
||||
}
|
||||
@ -98,7 +98,7 @@ interface NetworkMapCache {
|
||||
* Returns a notary identity advertised by any of the nodes on the network (chosen at random)
|
||||
* @param type Limits the result to notaries of the specified type (optional)
|
||||
*/
|
||||
fun getAnyNotary(type: ServiceType? = null): Party? {
|
||||
fun getAnyNotary(type: ServiceType? = null): Party.Full? {
|
||||
val nodes = if (type == null) {
|
||||
notaryNodes
|
||||
} else {
|
||||
@ -111,7 +111,7 @@ interface NetworkMapCache {
|
||||
}
|
||||
|
||||
/** Checks whether a given party is an advertised notary identity */
|
||||
fun isNotary(party: Party): Boolean = notaryNodes.any { it.notaryIdentity == party }
|
||||
fun isNotary(party: Party.Full): Boolean = notaryNodes.any { it.notaryIdentity == party }
|
||||
|
||||
/**
|
||||
* Add a network map service; fetches a copy of the latest map from the service and subscribes to any further
|
||||
|
@ -5,10 +5,10 @@ import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.node.ServiceEntry
|
||||
|
||||
/**
|
||||
* Holds information about a [Party], which may refer to either a specific node or a service.
|
||||
* Holds information about a [Party.Full], which may refer to either a specific node or a service.
|
||||
*/
|
||||
sealed class PartyInfo() {
|
||||
abstract val party: Party
|
||||
abstract val party: Party.Full
|
||||
class Node(val node: NodeInfo) : PartyInfo() {
|
||||
override val party = node.legalIdentity
|
||||
}
|
||||
|
@ -186,11 +186,11 @@ interface VaultService {
|
||||
fun generateSpend(tx: TransactionBuilder,
|
||||
amount: Amount<Currency>,
|
||||
to: CompositeKey,
|
||||
onlyFromParties: Set<Party>? = null): Pair<TransactionBuilder, List<CompositeKey>>
|
||||
onlyFromParties: Set<Party.Full>? = null): Pair<TransactionBuilder, List<CompositeKey>>
|
||||
}
|
||||
|
||||
inline fun <reified T : LinearState> VaultService.linearHeadsOfType() = linearHeadsOfType_(T::class.java)
|
||||
inline fun <reified T : DealState> VaultService.dealsWith(party: Party) = linearHeadsOfType<T>().values.filter {
|
||||
inline fun <reified T : DealState> VaultService.dealsWith(party: Party.Full) = linearHeadsOfType<T>().values.filter {
|
||||
// TODO: Replace name comparison with full party comparison (keys are currenty not equal)
|
||||
it.state.data.parties.any { it.name == party.name }
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import net.corda.core.crypto.SecureHash
|
||||
*/
|
||||
interface UniquenessProvider {
|
||||
/** Commits all input states of the given transaction */
|
||||
fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party)
|
||||
fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party.Full)
|
||||
|
||||
/** Specifies the consuming transaction for every conflicting state */
|
||||
data class Conflict(val stateHistory: Map<StateRef, ConsumingTx>)
|
||||
@ -26,7 +26,7 @@ interface UniquenessProvider {
|
||||
* This allows a party to just submit invalid transactions with outputs it was aware of and
|
||||
* find out where exactly they were spent.
|
||||
*/
|
||||
data class ConsumingTx(val id: SecureHash, val inputIndex: Int, val requestingParty: Party)
|
||||
data class ConsumingTx(val id: SecureHash, val inputIndex: Int, val requestingParty: Party.Full)
|
||||
}
|
||||
|
||||
class UniquenessException(val error: UniquenessProvider.Conflict) : Exception()
|
||||
|
@ -302,7 +302,7 @@ object WireTransactionSerializer : Serializer<WireTransaction>() {
|
||||
kryo.useClassLoader(classLoader) {
|
||||
val outputs = kryo.readClassAndObject(input) as List<TransactionState<ContractState>>
|
||||
val commands = kryo.readClassAndObject(input) as List<Command>
|
||||
val notary = kryo.readClassAndObject(input) as Party?
|
||||
val notary = kryo.readClassAndObject(input) as Party.Full?
|
||||
val signers = kryo.readClassAndObject(input) as List<CompositeKey>
|
||||
val transactionType = kryo.readClassAndObject(input) as TransactionType
|
||||
val timestamp = kryo.readClassAndObject(input) as Timestamp?
|
||||
@ -430,7 +430,7 @@ fun createKryo(k: Kryo = Kryo()): Kryo {
|
||||
addDefaultSerializer(SerializeAsToken::class.java, SerializeAsTokenSerializer<SerializeAsToken>())
|
||||
|
||||
// This is required to make all the unit tests pass
|
||||
register(Party::class.java)
|
||||
register(Party.Full::class.java)
|
||||
|
||||
// This ensures a NonEmptySetSerializer is constructed with an initial value.
|
||||
register(NonEmptySet::class.java, NonEmptySetSerializer)
|
||||
|
@ -45,9 +45,9 @@ class CompositeKeyGenerator : Generator<CompositeKey>(CompositeKey::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
class PartyGenerator : Generator<Party>(Party::class.java) {
|
||||
override fun generate(random: SourceOfRandomness, status: GenerationStatus): Party {
|
||||
return Party(StringGenerator().generate(random, status), CompositeKeyGenerator().generate(random, status))
|
||||
class PartyGenerator : Generator<Party.Full>(Party.Full::class.java) {
|
||||
override fun generate(random: SourceOfRandomness, status: GenerationStatus): Party.Full {
|
||||
return Party.Full(StringGenerator().generate(random, status), CompositeKeyGenerator().generate(random, status))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ abstract class BaseTransaction(
|
||||
* This is intended for issuance/genesis transactions that don't consume any other states and thus can't
|
||||
* double spend anything.
|
||||
*/
|
||||
val notary: Party?,
|
||||
val notary: Party.Full?,
|
||||
/**
|
||||
* Composite keys that need to be fulfilled by signatures in order for the transaction to be valid.
|
||||
* In a [SignedTransaction] this list is used to check whether there are any missing signatures. Note that
|
||||
|
@ -26,7 +26,7 @@ class LedgerTransaction(
|
||||
val attachments: List<Attachment>,
|
||||
/** The hash of the original serialised WireTransaction. */
|
||||
override val id: SecureHash,
|
||||
notary: Party?,
|
||||
notary: Party.Full?,
|
||||
signers: List<CompositeKey>,
|
||||
timestamp: Timestamp?,
|
||||
type: TransactionType
|
||||
|
@ -26,7 +26,7 @@ import java.util.*
|
||||
*/
|
||||
open class TransactionBuilder(
|
||||
protected val type: TransactionType = TransactionType.General(),
|
||||
var notary: Party? = null,
|
||||
var notary: Party.Full? = null,
|
||||
protected val inputs: MutableList<StateRef> = arrayListOf(),
|
||||
protected val attachments: MutableList<SecureHash> = arrayListOf(),
|
||||
protected val outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
|
||||
@ -160,7 +160,7 @@ open class TransactionBuilder(
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun addOutputState(state: ContractState, notary: Party, encumbrance: Int? = null) = addOutputState(TransactionState(state, notary, encumbrance))
|
||||
fun addOutputState(state: ContractState, notary: Party.Full, encumbrance: Int? = null) = addOutputState(TransactionState(state, notary, encumbrance))
|
||||
|
||||
/** A default notary must be specified during builder construction to use this method */
|
||||
fun addOutputState(state: ContractState): Int {
|
||||
|
@ -29,7 +29,7 @@ class WireTransaction(
|
||||
outputs: List<TransactionState<ContractState>>,
|
||||
/** Ordered list of ([CommandData], [PublicKey]) pairs that instruct the contracts what to do. */
|
||||
val commands: List<Command>,
|
||||
notary: Party?,
|
||||
notary: Party.Full?,
|
||||
signers: List<CompositeKey>,
|
||||
type: TransactionType,
|
||||
timestamp: Timestamp?
|
||||
|
@ -16,7 +16,7 @@ class ApiUtils(val rpc: CordaRPCOps) {
|
||||
* Get a party and then execute the passed function with the party public key as a parameter.
|
||||
* Usage: withParty(key) { doSomethingWith(it) }
|
||||
*/
|
||||
fun withParty(partyKeyStr: String, notFound: (String) -> Response = defaultNotFound, found: (Party) -> Response): Response {
|
||||
fun withParty(partyKeyStr: String, notFound: (String) -> Response = defaultNotFound, found: (Party.Full) -> Response): Response {
|
||||
val party = try {
|
||||
val partyKey = CompositeKey.parseFromBase58(partyKeyStr)
|
||||
ErrorOr(rpc.partyFromKey(partyKey))
|
||||
|
@ -17,4 +17,4 @@ val DUMMY_KEY_1: KeyPair by lazy { generateKeyPair() }
|
||||
val DUMMY_KEY_2: KeyPair by lazy { generateKeyPair() }
|
||||
|
||||
val DUMMY_NOTARY_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(20)) }
|
||||
val DUMMY_NOTARY: Party get() = Party("Notary Service", DUMMY_NOTARY_KEY.public)
|
||||
val DUMMY_NOTARY: Party.Full get() = Party.Full("Notary Service", DUMMY_NOTARY_KEY.public)
|
||||
|
@ -84,7 +84,7 @@ abstract class AbstractStateReplacementFlow {
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
private fun getParticipantSignature(party: Party, stx: SignedTransaction): DigitalSignature.WithKey {
|
||||
private fun getParticipantSignature(party: Party.Full, stx: SignedTransaction): DigitalSignature.WithKey {
|
||||
val proposal = Proposal(originalState.ref, modification, stx)
|
||||
val response = sendAndReceive<DigitalSignature.WithKey>(party, proposal)
|
||||
return response.unwrap {
|
||||
@ -105,7 +105,7 @@ abstract class AbstractStateReplacementFlow {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Acceptor<in T>(val otherSide: Party,
|
||||
abstract class Acceptor<in T>(val otherSide: Party.Full,
|
||||
override val progressTracker: ProgressTracker = tracker()) : FlowLogic<Unit>() {
|
||||
companion object {
|
||||
object VERIFYING : ProgressTracker.Step("Verifying state replacement proposal")
|
||||
|
@ -16,7 +16,7 @@ import net.corda.core.transactions.SignedTransaction
|
||||
* @return a list of participants who were successfully notified of the transaction.
|
||||
*/
|
||||
class BroadcastTransactionFlow(val notarisedTransaction: SignedTransaction,
|
||||
val participants: Set<Party>) : FlowLogic<Unit>() {
|
||||
val participants: Set<Party.Full>) : FlowLogic<Unit>() {
|
||||
|
||||
data class NotifyTxRequest(val tx: SignedTransaction)
|
||||
|
||||
|
@ -12,7 +12,7 @@ import java.io.InputStream
|
||||
* attachments are saved to local storage automatically.
|
||||
*/
|
||||
class FetchAttachmentsFlow(requests: Set<SecureHash>,
|
||||
otherSide: Party) : FetchDataFlow<Attachment, ByteArray>(requests, otherSide) {
|
||||
otherSide: Party.Full) : FetchDataFlow<Attachment, ByteArray>(requests, otherSide) {
|
||||
|
||||
override fun load(txid: SecureHash): Attachment? = serviceHub.storageService.attachments.openAttachment(txid)
|
||||
|
||||
|
@ -29,7 +29,7 @@ import java.util.*
|
||||
*/
|
||||
abstract class FetchDataFlow<T : NamedByHash, in W : Any>(
|
||||
protected val requests: Set<SecureHash>,
|
||||
protected val otherSide: Party) : FlowLogic<FetchDataFlow.Result<T>>() {
|
||||
protected val otherSide: Party.Full) : FlowLogic<FetchDataFlow.Result<T>>() {
|
||||
|
||||
class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : IllegalArgumentException()
|
||||
class DownloadedVsRequestedSizeMismatch(val requested: Int, val got: Int) : IllegalArgumentException()
|
||||
|
@ -12,7 +12,7 @@ import net.corda.core.transactions.SignedTransaction
|
||||
* results in a [FetchDataFlow.HashNotFound] exception. Note that returned transactions are not inserted into
|
||||
* the database, because it's up to the caller to actually verify the transactions are valid.
|
||||
*/
|
||||
class FetchTransactionsFlow(requests: Set<SecureHash>, otherSide: Party) :
|
||||
class FetchTransactionsFlow(requests: Set<SecureHash>, otherSide: Party.Full) :
|
||||
FetchDataFlow<SignedTransaction, SignedTransaction>(requests, otherSide) {
|
||||
|
||||
override fun load(txid: SecureHash): SignedTransaction? = serviceHub.storageService.validatedTransactions.getTransaction(txid)
|
||||
|
@ -15,9 +15,9 @@ import net.corda.core.utilities.ProgressTracker
|
||||
* @return a list of participants who were successfully notified of the transaction.
|
||||
*/
|
||||
class FinalityFlow(val transaction: SignedTransaction,
|
||||
val participants: Set<Party>,
|
||||
val participants: Set<Party.Full>,
|
||||
override val progressTracker: ProgressTracker) : FlowLogic<Unit>() {
|
||||
constructor(transaction: SignedTransaction, participants: Set<Party>) : this(transaction, participants, tracker())
|
||||
constructor(transaction: SignedTransaction, participants: Set<Party.Full>) : this(transaction, participants, tracker())
|
||||
|
||||
companion object {
|
||||
object NOTARISING : ProgressTracker.Step("Requesting signature by notary service")
|
||||
|
@ -22,8 +22,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
|
||||
|
||||
class Instigator<out T : ContractState>(
|
||||
originalState: StateAndRef<T>,
|
||||
newNotary: Party,
|
||||
progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator<T, Party>(originalState, newNotary, progressTracker) {
|
||||
newNotary: Party.Full,
|
||||
progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator<T, Party.Full>(originalState, newNotary, progressTracker) {
|
||||
|
||||
override fun assembleTx(): Pair<SignedTransaction, Iterable<CompositeKey>> {
|
||||
val state = originalState.state
|
||||
@ -88,8 +88,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
|
||||
|
||||
}
|
||||
|
||||
class Acceptor(otherSide: Party,
|
||||
override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor<Party>(otherSide) {
|
||||
class Acceptor(otherSide: Party.Full,
|
||||
override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor<Party.Full>(otherSide) {
|
||||
|
||||
/**
|
||||
* Check the notary change proposal.
|
||||
@ -98,7 +98,7 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
|
||||
* and is also in a geographically convenient location we can just automatically approve the change.
|
||||
* TODO: In more difficult cases this should call for human attention to manually verify and approve the proposal
|
||||
*/
|
||||
override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal<Party>): Unit {
|
||||
override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal<Party.Full>): Unit {
|
||||
val state = proposal.stateRef
|
||||
val proposedTx = proposal.stx.tx
|
||||
|
||||
|
@ -35,7 +35,7 @@ object NotaryFlow {
|
||||
fun tracker() = ProgressTracker(REQUESTING, VALIDATING)
|
||||
}
|
||||
|
||||
lateinit var notaryParty: Party
|
||||
lateinit var notaryParty: Party.Full
|
||||
|
||||
@Suspendable
|
||||
@Throws(NotaryException::class)
|
||||
@ -82,7 +82,7 @@ object NotaryFlow {
|
||||
*
|
||||
* TODO: the notary service should only be able to see timestamp commands and inputs
|
||||
*/
|
||||
open class Service(val otherSide: Party,
|
||||
open class Service(val otherSide: Party.Full,
|
||||
val timestampChecker: TimestampChecker,
|
||||
val uniquenessProvider: UniquenessProvider) : FlowLogic<Unit>() {
|
||||
|
||||
|
@ -29,7 +29,7 @@ import java.util.*
|
||||
* The flow returns a list of verified [LedgerTransaction] objects, in a depth-first order.
|
||||
*/
|
||||
class ResolveTransactionsFlow(private val txHashes: Set<SecureHash>,
|
||||
private val otherSide: Party) : FlowLogic<List<LedgerTransaction>>() {
|
||||
private val otherSide: Party.Full) : FlowLogic<List<LedgerTransaction>>() {
|
||||
|
||||
companion object {
|
||||
private fun dependencyIDs(wtx: WireTransaction) = wtx.inputs.map { it.txhash }.toSet()
|
||||
@ -77,14 +77,14 @@ class ResolveTransactionsFlow(private val txHashes: Set<SecureHash>,
|
||||
/**
|
||||
* Resolve the full history of a transaction and verify it with its dependencies.
|
||||
*/
|
||||
constructor(stx: SignedTransaction, otherSide: Party) : this(stx.tx, otherSide) {
|
||||
constructor(stx: SignedTransaction, otherSide: Party.Full) : this(stx.tx, otherSide) {
|
||||
this.stx = stx
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the full history of a transaction and verify it with its dependencies.
|
||||
*/
|
||||
constructor(wtx: WireTransaction, otherSide: Party) : this(dependencyIDs(wtx), otherSide) {
|
||||
constructor(wtx: WireTransaction, otherSide: Party.Full) : this(dependencyIDs(wtx), otherSide) {
|
||||
this.wtx = wtx
|
||||
}
|
||||
|
||||
|
@ -71,10 +71,10 @@ object TwoPartyDealFlow {
|
||||
|
||||
abstract val payload: Any
|
||||
abstract val notaryNode: NodeInfo
|
||||
abstract val otherParty: Party
|
||||
abstract val otherParty: Party.Full
|
||||
abstract val myKeyPair: KeyPair
|
||||
|
||||
override fun getCounterpartyMarker(party: Party): Class<*> {
|
||||
override fun getCounterpartyMarker(party: Party.Full): Class<*> {
|
||||
return if (serviceHub.networkMapCache.regulatorNodes.any { it.legalIdentity == party }) {
|
||||
MarkerForBogusRegulatorFlow::class.java
|
||||
} else {
|
||||
@ -202,7 +202,7 @@ object TwoPartyDealFlow {
|
||||
fun tracker() = ProgressTracker(RECEIVING, VERIFYING, SIGNING, SWAPPING_SIGNATURES, RECORDING)
|
||||
}
|
||||
|
||||
abstract val otherParty: Party
|
||||
abstract val otherParty: Party.Full
|
||||
|
||||
@Suspendable
|
||||
override fun call(): SignedTransaction {
|
||||
@ -263,13 +263,13 @@ object TwoPartyDealFlow {
|
||||
}
|
||||
|
||||
|
||||
data class AutoOffer(val notary: Party, val dealBeingOffered: DealState)
|
||||
data class AutoOffer(val notary: Party.Full, val dealBeingOffered: DealState)
|
||||
|
||||
|
||||
/**
|
||||
* One side of the flow for inserting a pre-agreed deal.
|
||||
*/
|
||||
open class Instigator(override val otherParty: Party,
|
||||
open class Instigator(override val otherParty: Party.Full,
|
||||
override val payload: AutoOffer,
|
||||
override val myKeyPair: KeyPair,
|
||||
override val progressTracker: ProgressTracker = Primary.tracker()) : Primary() {
|
||||
@ -281,7 +281,7 @@ object TwoPartyDealFlow {
|
||||
/**
|
||||
* One side of the flow for inserting a pre-agreed deal.
|
||||
*/
|
||||
open class Acceptor(override val otherParty: Party,
|
||||
open class Acceptor(override val otherParty: Party.Full,
|
||||
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<AutoOffer>() {
|
||||
|
||||
override fun validateHandshake(handshake: Handshake<AutoOffer>): Handshake<AutoOffer> {
|
||||
|
@ -15,7 +15,7 @@ import java.security.SignatureException
|
||||
* has its input states "blocked" by a transaction from another party, and needs to establish whether that transaction was
|
||||
* indeed valid.
|
||||
*/
|
||||
class ValidatingNotaryFlow(otherSide: Party,
|
||||
class ValidatingNotaryFlow(otherSide: Party.Full,
|
||||
timestampChecker: TimestampChecker,
|
||||
uniquenessProvider: UniquenessProvider) :
|
||||
NotaryFlow.Service(otherSide, timestampChecker, uniquenessProvider) {
|
||||
|
Binary file not shown.
@ -111,7 +111,7 @@ class TransactionTests {
|
||||
|
||||
@Test
|
||||
fun `general transactions cannot change notary`() {
|
||||
val notary: Party = DUMMY_NOTARY
|
||||
val notary: Party.Full = DUMMY_NOTARY
|
||||
val inState = TransactionState(DummyContract.SingleOwnerState(0, ALICE_PUBKEY), notary)
|
||||
val outState = inState.copy(notary = ALICE)
|
||||
val inputs = listOf(StateAndRef(inState, StateRef(SecureHash.randomSHA256(), 0)))
|
||||
|
@ -28,7 +28,7 @@ class ResolveTransactionsFlowTest {
|
||||
lateinit var net: MockNetwork
|
||||
lateinit var a: MockNetwork.MockNode
|
||||
lateinit var b: MockNetwork.MockNode
|
||||
lateinit var notary: Party
|
||||
lateinit var notary: Party.Full
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
@ -23,7 +23,7 @@ import kotlin.test.assertFailsWith
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
interface DummyContractBackdoor {
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party.Full): TransactionBuilder
|
||||
fun inspectState(state: ContractState): Int
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ class AttachmentClassLoaderTests {
|
||||
// The "empty contract"
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("")
|
||||
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder {
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party.Full): TransactionBuilder {
|
||||
val state = State(magicNumber)
|
||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.Create(), owner.party.owningKey))
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ object FxTransactionDemoTutorial {
|
||||
|
||||
private data class FxRequest(val tradeId: String,
|
||||
val amount: Amount<Issued<Currency>>,
|
||||
val owner: Party,
|
||||
val counterparty: Party,
|
||||
val notary: Party? = null)
|
||||
val owner: Party.Full,
|
||||
val counterparty: Party.Full,
|
||||
val notary: Party.Full? = null)
|
||||
|
||||
private data class FxResponse(val inputs: List<StateAndRef<Cash.State>>,
|
||||
val outputs: List<Cash.State>)
|
||||
@ -39,7 +39,7 @@ private data class FxResponse(val inputs: List<StateAndRef<Cash.State>>,
|
||||
// Which is brought here to make the filtering logic more visible in the example
|
||||
private fun gatherOurInputs(serviceHub: ServiceHub,
|
||||
amountRequired: Amount<Issued<Currency>>,
|
||||
notary: Party?): Pair<List<StateAndRef<Cash.State>>, Long> {
|
||||
notary: Party.Full?): Pair<List<StateAndRef<Cash.State>>, Long> {
|
||||
// Collect cash type inputs
|
||||
val cashStates = serviceHub.vaultService.currentVault.statesOfType<Cash.State>()
|
||||
// extract our key identity for convenience
|
||||
@ -56,7 +56,7 @@ private fun gatherOurInputs(serviceHub: ServiceHub,
|
||||
// For simplicity we just filter on the first notary encountered
|
||||
// A production quality flow would need to migrate notary if the
|
||||
// the amounts were not sufficient in any one notary
|
||||
val sourceNotary: Party = notary ?: suitableCashStates.first().state.notary
|
||||
val sourceNotary: Party.Full = notary ?: suitableCashStates.first().state.notary
|
||||
|
||||
val inputsList = mutableListOf<StateAndRef<Cash.State>>()
|
||||
// Iterate over filtered cash states to gather enough to pay
|
||||
@ -102,8 +102,8 @@ private fun prepareOurInputsAndOutputs(serviceHub: ServiceHub, request: FxReques
|
||||
class ForeignExchangeFlow(val tradeId: String,
|
||||
val baseCurrencyAmount: Amount<Issued<Currency>>,
|
||||
val quoteCurrencyAmount: Amount<Issued<Currency>>,
|
||||
val baseCurrencyBuyer: Party,
|
||||
val baseCurrencySeller: Party) : FlowLogic<SecureHash>() {
|
||||
val baseCurrencyBuyer: Party.Full,
|
||||
val baseCurrencySeller: Party.Full) : FlowLogic<SecureHash>() {
|
||||
@Suspendable
|
||||
override fun call(): SecureHash {
|
||||
// Select correct sides of the Fx exchange to query for.
|
||||
@ -208,7 +208,7 @@ class ForeignExchangeFlow(val tradeId: String,
|
||||
// DOCEND 3
|
||||
}
|
||||
|
||||
class ForeignExchangeRemoteFlow(val source: Party) : FlowLogic<Unit>() {
|
||||
class ForeignExchangeRemoteFlow(val source: Party.Full) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
// Initial receive from remote party
|
||||
|
@ -51,13 +51,13 @@ data class TradeApprovalContract(override val legalContractReference: SecureHash
|
||||
* Truly minimal state that just records a tradeId string and the parties involved.
|
||||
*/
|
||||
data class State(val tradeId: String,
|
||||
val source: Party,
|
||||
val counterparty: Party,
|
||||
val source: Party.Full,
|
||||
val counterparty: Party.Full,
|
||||
val state: WorkflowState = WorkflowState.NEW,
|
||||
override val linearId: UniqueIdentifier = UniqueIdentifier(tradeId),
|
||||
override val contract: TradeApprovalContract = TradeApprovalContract()) : LinearState {
|
||||
|
||||
val parties: List<Party> get() = listOf(source, counterparty)
|
||||
val parties: List<Party.Full> get() = listOf(source, counterparty)
|
||||
override val participants: List<CompositeKey> get() = parties.map { it.owningKey }
|
||||
|
||||
override fun isRelevant(ourKeys: Set<PublicKey>): Boolean {
|
||||
@ -110,7 +110,7 @@ data class TradeApprovalContract(override val legalContractReference: SecureHash
|
||||
* as their approval/rejection is to follow.
|
||||
*/
|
||||
class SubmitTradeApprovalFlow(val tradeId: String,
|
||||
val counterparty: Party) : FlowLogic<StateAndRef<TradeApprovalContract.State>>() {
|
||||
val counterparty: Party.Full) : FlowLogic<StateAndRef<TradeApprovalContract.State>>() {
|
||||
@Suspendable
|
||||
override fun call(): StateAndRef<TradeApprovalContract.State> {
|
||||
// Manufacture an initial state
|
||||
@ -225,7 +225,7 @@ class SubmitCompletionFlow(val ref: StateRef, val verdict: WorkflowState) : Flow
|
||||
* Then after checking to sign it and eventually store the fully notarised
|
||||
* transaction to the ledger.
|
||||
*/
|
||||
class RecordCompletionFlow(val source: Party) : FlowLogic<Unit>() {
|
||||
class RecordCompletionFlow(val source: Party.Full) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call(): Unit {
|
||||
// DOCSTART 3
|
||||
|
@ -24,7 +24,7 @@ class Zero() : Arrangement {
|
||||
//
|
||||
// TODO: should be replaced with something that uses Corda assets and/or cash?
|
||||
// TODO: should only be allowed to transfer non-negative amounts
|
||||
data class Obligation(val amount: Perceivable<BigDecimal>, val currency: Currency, val from: Party, val to: Party) : Arrangement
|
||||
data class Obligation(val amount: Perceivable<BigDecimal>, val currency: Currency, val from: Party.Full, val to: Party.Full) : Arrangement
|
||||
|
||||
// A combinator over a list of arrangements. Each arrangement in list will create a separate independent arrangement state.
|
||||
// The ``And`` combinator cannot be root in a arrangement.
|
||||
|
@ -4,7 +4,7 @@ import net.corda.core.crypto.Party
|
||||
import java.math.BigDecimal
|
||||
import java.util.*
|
||||
|
||||
fun swap(partyA: Party, amountA: BigDecimal, currencyA: Currency, partyB: Party, amountB: BigDecimal, currencyB: Currency) =
|
||||
fun swap(partyA: Party.Full, amountA: BigDecimal, currencyA: Currency, partyB: Party.Full, amountB: BigDecimal, currencyB: Currency) =
|
||||
arrange {
|
||||
partyA.owes(partyB, amountA, currencyA)
|
||||
partyB.owes(partyA, amountB, currencyB)
|
||||
@ -12,7 +12,7 @@ fun swap(partyA: Party, amountA: BigDecimal, currencyA: Currency, partyB: Party,
|
||||
|
||||
fun fx_swap(expiry: String, notional: BigDecimal, strike: BigDecimal,
|
||||
foreignCurrency: Currency, domesticCurrency: Currency,
|
||||
partyA: Party, partyB: Party) =
|
||||
partyA: Party.Full, partyB: Party.Full) =
|
||||
arrange {
|
||||
actions {
|
||||
(partyA or partyB).may {
|
||||
@ -26,6 +26,6 @@ fun fx_swap(expiry: String, notional: BigDecimal, strike: BigDecimal,
|
||||
// building an fx swap using abstract swap
|
||||
fun fx_swap2(expiry: String, notional: Long, strike: Double,
|
||||
foreignCurrency: Currency, domesticCurrency: Currency,
|
||||
partyA: Party, partyB: Party) =
|
||||
partyA: Party.Full, partyB: Party.Full) =
|
||||
Action("execute", after(expiry) and (signedBy(partyA) or signedBy(partyB)),
|
||||
swap(partyA, BigDecimal(notional * strike), domesticCurrency, partyB, BigDecimal(notional), foreignCurrency))
|
||||
|
@ -23,14 +23,14 @@ class ActionsBuilder {
|
||||
else
|
||||
Actions(actions.toSet())
|
||||
|
||||
infix fun Party.may(init: ActionBuilder.() -> Action): Action {
|
||||
infix fun Party.Full.may(init: ActionBuilder.() -> Action): Action {
|
||||
val builder = ActionBuilder(setOf(this))
|
||||
builder.init()
|
||||
actions.addAll(builder.actions)
|
||||
return builder.actions.first()
|
||||
}
|
||||
|
||||
infix fun Set<Party>.may(init: ActionBuilder.() -> Action): Action {
|
||||
infix fun Set<Party.Full>.may(init: ActionBuilder.() -> Action): Action {
|
||||
val builder = ActionBuilder(this)
|
||||
builder.init()
|
||||
actions.addAll(builder.actions)
|
||||
@ -38,8 +38,8 @@ class ActionsBuilder {
|
||||
return builder.actions.first()
|
||||
}
|
||||
|
||||
infix fun Party.or(party: Party) = setOf(this, party)
|
||||
infix fun Set<Party>.or(party: Party) = this.plus(party)
|
||||
infix fun Party.Full.or(party: Party.Full) = setOf(this, party)
|
||||
infix fun Set<Party.Full>.or(party: Party.Full) = this.plus(party)
|
||||
|
||||
fun String.givenThat(condition: Perceivable<Boolean>, init: ContractBuilder.() -> Arrangement): Action {
|
||||
val b = ContractBuilder()
|
||||
@ -67,13 +67,13 @@ open class ContractBuilder {
|
||||
return c
|
||||
}
|
||||
|
||||
fun Party.owes(beneficiary: Party, amount: BigDecimal, currency: Currency): Obligation {
|
||||
fun Party.Full.owes(beneficiary: Party.Full, amount: BigDecimal, currency: Currency): Obligation {
|
||||
val c = Obligation(const(amount), currency, this, beneficiary)
|
||||
contracts.add(c)
|
||||
return c
|
||||
}
|
||||
|
||||
fun Party.owes(beneficiary: Party, amount: Perceivable<BigDecimal>, currency: Currency): Obligation {
|
||||
fun Party.Full.owes(beneficiary: Party.Full, amount: Perceivable<BigDecimal>, currency: Currency): Obligation {
|
||||
val c = Obligation(amount, currency, this, beneficiary)
|
||||
contracts.add(c)
|
||||
return c
|
||||
@ -81,7 +81,7 @@ open class ContractBuilder {
|
||||
|
||||
@Deprecated(level = DeprecationLevel.ERROR, message = "Not allowed")
|
||||
fun Action(@Suppress("UNUSED_PARAMETER") name: String, @Suppress("UNUSED_PARAMETER") condition: Perceivable<Boolean>,
|
||||
@Suppress("UNUSED_PARAMETER") actors: Set<Party>, @Suppress("UNUSED_PARAMETER") arrangement: Arrangement) {
|
||||
@Suppress("UNUSED_PARAMETER") actors: Set<Party.Full>, @Suppress("UNUSED_PARAMETER") arrangement: Arrangement) {
|
||||
}
|
||||
|
||||
@Deprecated(level = DeprecationLevel.ERROR, message = "Not available")
|
||||
@ -97,11 +97,11 @@ open class ContractBuilder {
|
||||
}
|
||||
|
||||
@Deprecated(level = DeprecationLevel.ERROR, message = "Not available")
|
||||
fun Party.may(init: ActionBuilder.() -> Action) {
|
||||
fun Party.Full.may(init: ActionBuilder.() -> Action) {
|
||||
}
|
||||
|
||||
@Deprecated(level = DeprecationLevel.ERROR, message = "Not available")
|
||||
fun Set<Party>.may(init: ActionBuilder.() -> Action) {
|
||||
fun Set<Party.Full>.may(init: ActionBuilder.() -> Action) {
|
||||
}
|
||||
|
||||
val start = StartDate()
|
||||
@ -152,7 +152,7 @@ interface GivenThatResolve {
|
||||
fun resolve(contract: Arrangement)
|
||||
}
|
||||
|
||||
class ActionBuilder(val actors: Set<Party>) {
|
||||
class ActionBuilder(val actors: Set<Party.Full>) {
|
||||
internal val actions = mutableListOf<Action>()
|
||||
|
||||
fun String.givenThat(condition: Perceivable<Boolean>, init: ContractBuilder.() -> Arrangement): Action {
|
||||
|
@ -75,10 +75,10 @@ class EndDate : Perceivable<Instant> {
|
||||
}
|
||||
}
|
||||
|
||||
data class ActorPerceivable(val actor: Party) : Perceivable<Boolean>
|
||||
fun signedBy(actor: Party) : Perceivable<Boolean> = ActorPerceivable(actor)
|
||||
data class ActorPerceivable(val actor: Party.Full) : Perceivable<Boolean>
|
||||
fun signedBy(actor: Party.Full) : Perceivable<Boolean> = ActorPerceivable(actor)
|
||||
|
||||
fun signedByOneOf(actors: Collection<Party>): Perceivable<Boolean> =
|
||||
fun signedByOneOf(actors: Collection<Party.Full>): Perceivable<Boolean> =
|
||||
if (actors.size == 0)
|
||||
const(true)
|
||||
else
|
||||
@ -149,7 +149,7 @@ operator fun Perceivable<BigDecimal>.div(n: Double) = PerceivableOperation(this,
|
||||
operator fun Perceivable<Int>.plus(n: Int) = PerceivableOperation(this, Operation.PLUS, const(n))
|
||||
operator fun Perceivable<Int>.minus(n: Int) = PerceivableOperation(this, Operation.MINUS, const(n))
|
||||
|
||||
data class TerminalEvent(val reference: Party, val source: CompositeKey) : Perceivable<Boolean>
|
||||
data class TerminalEvent(val reference: Party.Full, val source: CompositeKey) : Perceivable<Boolean>
|
||||
|
||||
// todo: holidays
|
||||
data class Interest(val amount: Perceivable<BigDecimal>, val dayCountConvention: String,
|
||||
|
@ -44,7 +44,7 @@ private class PrettyPrint(arr : Arrangement) {
|
||||
val partyMap = mutableMapOf<CompositeKey, String>()
|
||||
val usedPartyNames = mutableSetOf<String>()
|
||||
|
||||
fun createPartyName(party : Party) : String
|
||||
fun createPartyName(party : Party.Full) : String
|
||||
{
|
||||
val parts = party.name.toLowerCase().split(' ')
|
||||
|
||||
|
@ -25,7 +25,7 @@ class UniversalContract : Contract {
|
||||
|
||||
// replace parties
|
||||
// must be signed by all parties present in contract before and after command
|
||||
class Move(val from: Party, val to: Party) : TypeOnlyCommandData(), Commands
|
||||
class Move(val from: Party.Full, val to: Party.Full) : TypeOnlyCommandData(), Commands
|
||||
|
||||
// must be signed by all liable parties present in contract
|
||||
class Issue : TypeOnlyCommandData(), Commands
|
||||
|
@ -12,14 +12,14 @@ fun Instant.toLocalDate(): LocalDate = LocalDate.ofEpochDay(this.epochSecond / 6
|
||||
|
||||
fun LocalDate.toInstant(): Instant = Instant.ofEpochSecond(this.toEpochDay() * 60 * 60 * 24)
|
||||
|
||||
private fun signingParties(perceivable: Perceivable<Boolean>) : ImmutableSet<Party> =
|
||||
private fun signingParties(perceivable: Perceivable<Boolean>) : ImmutableSet<Party.Full> =
|
||||
when (perceivable) {
|
||||
is ActorPerceivable -> ImmutableSet.of( perceivable.actor )
|
||||
is PerceivableAnd -> Sets.union( signingParties( perceivable.left ), signingParties(perceivable.right) ).immutableCopy()
|
||||
is PerceivableOr -> Sets.union( signingParties( perceivable.left ), signingParties(perceivable.right) ).immutableCopy()
|
||||
is TimePerceivable -> ImmutableSet.of<Party>()
|
||||
is TimePerceivable -> ImmutableSet.of<Party.Full>()
|
||||
is TerminalEvent -> ImmutableSet.of( perceivable.reference )
|
||||
is PerceivableComparison<*> -> ImmutableSet.of<Party>() // todo
|
||||
is PerceivableComparison<*> -> ImmutableSet.of<Party.Full>() // todo
|
||||
else -> throw IllegalArgumentException("signingParties " + perceivable)
|
||||
}
|
||||
|
||||
@ -47,26 +47,26 @@ private fun liablePartiesVisitor(action: Action): ImmutableSet<CompositeKey> {
|
||||
/** Returns list of potentially liable parties for a given contract */
|
||||
fun liableParties(contract: Arrangement): Set<CompositeKey> = liablePartiesVisitor(contract)
|
||||
|
||||
private fun involvedPartiesVisitor(action: Action): Set<Party> =
|
||||
private fun involvedPartiesVisitor(action: Action): Set<Party.Full> =
|
||||
Sets.union(involvedPartiesVisitor(action.arrangement), signingParties(action.condition)).immutableCopy()
|
||||
|
||||
private fun involvedPartiesVisitor(arrangement: Arrangement): ImmutableSet<Party> =
|
||||
private fun involvedPartiesVisitor(arrangement: Arrangement): ImmutableSet<Party.Full> =
|
||||
when (arrangement) {
|
||||
is Zero -> ImmutableSet.of<Party>()
|
||||
is Zero -> ImmutableSet.of<Party.Full>()
|
||||
is Obligation -> ImmutableSet.of(arrangement.from, arrangement.to)
|
||||
is RollOut -> involvedPartiesVisitor(arrangement.template)
|
||||
is Continuation -> ImmutableSet.of<Party>()
|
||||
is Continuation -> ImmutableSet.of<Party.Full>()
|
||||
is And ->
|
||||
arrangement.arrangements.fold(ImmutableSet.builder<Party>(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build()
|
||||
arrangement.arrangements.fold(ImmutableSet.builder<Party.Full>(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build()
|
||||
is Actions ->
|
||||
arrangement.actions.fold(ImmutableSet.builder<Party>(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build()
|
||||
arrangement.actions.fold(ImmutableSet.builder<Party.Full>(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build()
|
||||
else -> throw IllegalArgumentException(arrangement.toString())
|
||||
}
|
||||
|
||||
/** returns list of involved parties for a given contract */
|
||||
fun involvedParties(arrangement: Arrangement): Set<Party> = involvedPartiesVisitor(arrangement)
|
||||
fun involvedParties(arrangement: Arrangement): Set<Party.Full> = involvedPartiesVisitor(arrangement)
|
||||
|
||||
fun replaceParty(perceivable: Perceivable<Boolean>, from: Party, to: Party): Perceivable<Boolean> =
|
||||
fun replaceParty(perceivable: Perceivable<Boolean>, from: Party.Full, to: Party.Full): Perceivable<Boolean> =
|
||||
when (perceivable) {
|
||||
is ActorPerceivable ->
|
||||
if (perceivable.actor == from)
|
||||
@ -79,14 +79,14 @@ fun replaceParty(perceivable: Perceivable<Boolean>, from: Party, to: Party): Per
|
||||
else -> throw IllegalArgumentException("replaceParty " + perceivable)
|
||||
}
|
||||
|
||||
fun replaceParty(action: Action, from: Party, to: Party): Action =
|
||||
fun replaceParty(action: Action, from: Party.Full, to: Party.Full): Action =
|
||||
Action(action.name, replaceParty(action.condition, from, to), replaceParty(action.arrangement, from, to))
|
||||
//if (action.actors.contains(from)) {
|
||||
// Action(action.name, action.condition, action.actors - from + to, replaceParty(action.arrangement, from, to))
|
||||
//} else
|
||||
// Action(action.name, action.condition, replaceParty(action.arrangement, from, to))
|
||||
|
||||
fun replaceParty(arrangement: Arrangement, from: Party, to: Party): Arrangement = when (arrangement) {
|
||||
fun replaceParty(arrangement: Arrangement, from: Party.Full, to: Party.Full): Arrangement = when (arrangement) {
|
||||
is Zero -> arrangement
|
||||
is Obligation -> Obligation(arrangement.amount, arrangement.currency,
|
||||
if (arrangement.from == from) to else arrangement.from,
|
||||
@ -169,7 +169,7 @@ fun <T> debugCompare(perLeft: Perceivable<T>, perRight: Perceivable<T>) {
|
||||
assert(false)
|
||||
}
|
||||
|
||||
fun debugCompare(parLeft: Party, parRight: Party) {
|
||||
fun debugCompare(parLeft: Party.Full, parRight: Party.Full) {
|
||||
assert(parLeft == parRight)
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ fun debugCompare(left: LocalDate, right: LocalDate) {
|
||||
assert(left == right)
|
||||
}
|
||||
|
||||
fun debugCompare(parLeft: Set<Party>, parRight: Set<Party>) {
|
||||
fun debugCompare(parLeft: Set<Party.Full>, parRight: Set<Party.Full>) {
|
||||
if (parLeft == parRight) return
|
||||
|
||||
assert(parLeft == parRight)
|
||||
|
@ -7,9 +7,9 @@ import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
// Test parties
|
||||
val acmeCorp = Party("ACME Corporation", generateKeyPair().public)
|
||||
val highStreetBank = Party("High Street Bank", generateKeyPair().public)
|
||||
val momAndPop = Party("Mom and Pop", generateKeyPair().public)
|
||||
val acmeCorp = Party.Full("ACME Corporation", generateKeyPair().public)
|
||||
val highStreetBank = Party.Full("High Street Bank", generateKeyPair().public)
|
||||
val momAndPop = Party.Full("Mom and Pop", generateKeyPair().public)
|
||||
|
||||
val acmeCorporationHasDefaulted = TerminalEvent(acmeCorp, generateKeyPair().public.composite)
|
||||
|
||||
|
@ -28,7 +28,7 @@ class AnotherDummyContract : Contract, net.corda.core.node.DummyContractBackdoor
|
||||
// The "empty contract"
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://anotherdummy.org")
|
||||
|
||||
override fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder {
|
||||
override fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party.Full): TransactionBuilder {
|
||||
val state = State(magicNumber)
|
||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.Create(), owner.party.owningKey))
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.crypto.Party
|
||||
|
||||
interface DummyContractBackdoor {
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder
|
||||
fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party.Full): TransactionBuilder
|
||||
|
||||
fun inspectState(state: ContractState): Int
|
||||
}
|
||||
|
@ -297,13 +297,13 @@ public class JavaCommercialPaper implements Contract {
|
||||
return SecureHash.sha256("https://en.wikipedia.org/wiki/Commercial_paper");
|
||||
}
|
||||
|
||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount<Issued<Currency>> faceValue, @Nullable Instant maturityDate, @NotNull Party notary, Integer encumbrance) {
|
||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount<Issued<Currency>> faceValue, @Nullable Instant maturityDate, @NotNull Party.Full notary, Integer encumbrance) {
|
||||
State state = new State(issuance, issuance.getParty().getOwningKey(), faceValue, maturityDate);
|
||||
TransactionState output = new TransactionState<>(state, notary, encumbrance);
|
||||
return new TransactionType.General.Builder(notary).withItems(output, new Command(new Commands.Issue(), issuance.getParty().getOwningKey()));
|
||||
}
|
||||
|
||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount<Issued<Currency>> faceValue, @Nullable Instant maturityDate, @NotNull Party notary) {
|
||||
public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount<Issued<Currency>> faceValue, @Nullable Instant maturityDate, @NotNull Party.Full notary) {
|
||||
return generateIssue(issuance, faceValue, maturityDate, notary, null);
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class CommercialPaper : Contract {
|
||||
* an existing transaction because you aren't able to issue multiple pieces of CP in a single transaction
|
||||
* at the moment: this restriction is not fundamental and may be lifted later.
|
||||
*/
|
||||
fun generateIssue(issuance: PartyAndReference, faceValue: Amount<Issued<Currency>>, maturityDate: Instant, notary: Party): TransactionBuilder {
|
||||
fun generateIssue(issuance: PartyAndReference, faceValue: Amount<Issued<Currency>>, maturityDate: Instant, notary: Party.Full): TransactionBuilder {
|
||||
val state = TransactionState(State(issuance, issuance.party.owningKey, faceValue, maturityDate), notary)
|
||||
return TransactionType.General.Builder(notary = notary).withItems(state, Command(Commands.Issue(), issuance.party.owningKey))
|
||||
}
|
||||
@ -224,7 +224,7 @@ class CommercialPaper : Contract {
|
||||
}
|
||||
|
||||
infix fun CommercialPaper.State.`owned by`(owner: CompositeKey) = copy(owner = owner)
|
||||
infix fun CommercialPaper.State.`with notary`(notary: Party) = TransactionState(this, notary)
|
||||
infix fun CommercialPaper.State.`with notary`(notary: Party.Full) = TransactionState(this, notary)
|
||||
infix fun ICommercialPaperState.`owned by`(newOwner: CompositeKey) = withOwner(newOwner)
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ class CommercialPaperLegacy : Contract {
|
||||
}
|
||||
|
||||
fun generateIssue(issuance: PartyAndReference, faceValue: Amount<Issued<Currency>>, maturityDate: Instant,
|
||||
notary: Party): TransactionBuilder {
|
||||
notary: Party.Full): TransactionBuilder {
|
||||
val state = State(issuance, issuance.party.owningKey, faceValue, maturityDate)
|
||||
return TransactionBuilder(notary = notary).withItems(state, Command(Commands.Issue(), issuance.party.owningKey))
|
||||
}
|
||||
|
@ -143,13 +143,13 @@ class Cash : OnLedgerAsset<Currency, Cash.Commands, Cash.State>() {
|
||||
/**
|
||||
* Puts together an issuance transaction from the given template, that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder, tokenDef: Issued<Currency>, pennies: Long, owner: CompositeKey, notary: Party)
|
||||
fun generateIssue(tx: TransactionBuilder, tokenDef: Issued<Currency>, pennies: Long, owner: CompositeKey, notary: Party.Full)
|
||||
= generateIssue(tx, Amount(pennies, tokenDef), owner, notary)
|
||||
|
||||
/**
|
||||
* Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount<Issued<Currency>>, owner: CompositeKey, notary: Party) {
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount<Issued<Currency>>, owner: CompositeKey, notary: Party.Full) {
|
||||
check(tx.inputStates().isEmpty())
|
||||
check(tx.outputStates().map { it.data }.sumCashOrNull() == null)
|
||||
val at = amount.token.issuer
|
||||
@ -192,12 +192,12 @@ fun Iterable<ContractState>.sumCashOrZero(currency: Issued<Currency>): Amount<Is
|
||||
}
|
||||
|
||||
fun Cash.State.ownedBy(owner: CompositeKey) = copy(owner = owner)
|
||||
fun Cash.State.issuedBy(party: Party) = copy(amount = Amount(amount.quantity, amount.token.copy(issuer = amount.token.issuer.copy(party = party))))
|
||||
fun Cash.State.issuedBy(party: Party.Full) = copy(amount = Amount(amount.quantity, amount.token.copy(issuer = amount.token.issuer.copy(party = party))))
|
||||
fun Cash.State.issuedBy(deposit: PartyAndReference) = copy(amount = Amount(amount.quantity, amount.token.copy(issuer = deposit)))
|
||||
fun Cash.State.withDeposit(deposit: PartyAndReference): Cash.State = copy(amount = amount.copy(token = amount.token.copy(issuer = deposit)))
|
||||
|
||||
infix fun Cash.State.`owned by`(owner: CompositeKey) = ownedBy(owner)
|
||||
infix fun Cash.State.`issued by`(party: Party) = issuedBy(party)
|
||||
infix fun Cash.State.`issued by`(party: Party.Full) = issuedBy(party)
|
||||
infix fun Cash.State.`issued by`(deposit: PartyAndReference) = issuedBy(deposit)
|
||||
infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = withDeposit(deposit)
|
||||
|
||||
@ -206,7 +206,7 @@ infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = wi
|
||||
/** A randomly generated key. */
|
||||
val DUMMY_CASH_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
|
||||
/** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */
|
||||
val DUMMY_CASH_ISSUER by lazy { Party("Snake Oil Issuer", DUMMY_CASH_ISSUER_KEY.public.composite).ref(1) }
|
||||
val DUMMY_CASH_ISSUER by lazy { Party.Full("Snake Oil Issuer", DUMMY_CASH_ISSUER_KEY.public.composite).ref(1) }
|
||||
/** An extension property that lets you write 100.DOLLARS.CASH */
|
||||
val Amount<Currency>.CASH: Cash.State get() = Cash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NullCompositeKey)
|
||||
/** An extension property that lets you get a cash state from an issued token, under the [NullPublicKey] */
|
||||
|
@ -144,13 +144,13 @@ class CommodityContract : OnLedgerAsset<Commodity, CommodityContract.Commands, C
|
||||
/**
|
||||
* Puts together an issuance transaction from the given template, that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder, tokenDef: Issued<Commodity>, pennies: Long, owner: CompositeKey, notary: Party)
|
||||
fun generateIssue(tx: TransactionBuilder, tokenDef: Issued<Commodity>, pennies: Long, owner: CompositeKey, notary: Party.Full)
|
||||
= generateIssue(tx, Amount(pennies, tokenDef), owner, notary)
|
||||
|
||||
/**
|
||||
* Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount<Issued<Commodity>>, owner: CompositeKey, notary: Party) {
|
||||
fun generateIssue(tx: TransactionBuilder, amount: Amount<Issued<Commodity>>, owner: CompositeKey, notary: Party.Full) {
|
||||
check(tx.inputStates().isEmpty())
|
||||
check(tx.outputStates().map { it.data }.sumCashOrNull() == null)
|
||||
val at = amount.token.issuer
|
||||
|
@ -266,7 +266,7 @@ class Obligation<P> : Contract {
|
||||
data class State<P>(
|
||||
var lifecycle: Lifecycle = Lifecycle.NORMAL,
|
||||
/** Where the debt originates from (obligor) */
|
||||
val obligor: Party,
|
||||
val obligor: Party.Full,
|
||||
val template: Terms<P>,
|
||||
val quantity: Long,
|
||||
/** The public key of the entity the contract pays to */
|
||||
@ -456,11 +456,11 @@ class Obligation<P> : Contract {
|
||||
* Puts together an issuance transaction for the specified amount that starts out being owned by the given pubkey.
|
||||
*/
|
||||
fun generateIssue(tx: TransactionBuilder,
|
||||
obligor: Party,
|
||||
obligor: Party.Full,
|
||||
issuanceDef: Terms<P>,
|
||||
pennies: Long,
|
||||
beneficiary: CompositeKey,
|
||||
notary: Party) {
|
||||
notary: Party.Full) {
|
||||
check(tx.inputStates().isEmpty())
|
||||
check(tx.outputStates().map { it.data }.sumObligationsOrNull<P>() == null)
|
||||
tx.addOutputState(State(Lifecycle.NORMAL, obligor, issuanceDef, pennies, beneficiary), notary)
|
||||
@ -469,13 +469,13 @@ class Obligation<P> : Contract {
|
||||
|
||||
fun generatePaymentNetting(tx: TransactionBuilder,
|
||||
issued: Issued<Obligation.Terms<P>>,
|
||||
notary: Party,
|
||||
notary: Party.Full,
|
||||
vararg states: State<P>) {
|
||||
requireThat {
|
||||
"all states are in the normal lifecycle state " by (states.all { it.lifecycle == Lifecycle.NORMAL })
|
||||
}
|
||||
val groups = states.groupBy { it.multilateralNetState }
|
||||
val partyLookup = HashMap<CompositeKey, Party>()
|
||||
val partyLookup = HashMap<CompositeKey, Party.Full>()
|
||||
val signers = states.map { it.beneficiary }.union(states.map { it.obligor.owningKey }).toSet()
|
||||
|
||||
// Create a lookup table of the party that each public key represents.
|
||||
@ -509,7 +509,7 @@ class Obligation<P> : Contract {
|
||||
fun generateSetLifecycle(tx: TransactionBuilder,
|
||||
statesAndRefs: List<StateAndRef<State<P>>>,
|
||||
lifecycle: Lifecycle,
|
||||
notary: Party) {
|
||||
notary: Party.Full) {
|
||||
val states = statesAndRefs.map { it.state.data }
|
||||
val issuanceDef = getTermsOrThrow(states)
|
||||
val existingLifecycle = when (lifecycle) {
|
||||
@ -545,7 +545,7 @@ class Obligation<P> : Contract {
|
||||
statesAndRefs: Iterable<StateAndRef<State<P>>>,
|
||||
assetStatesAndRefs: Iterable<StateAndRef<FungibleAsset<P>>>,
|
||||
moveCommand: MoveCommand,
|
||||
notary: Party) {
|
||||
notary: Party.Full) {
|
||||
val states = statesAndRefs.map { it.state }
|
||||
val obligationIssuer = states.first().data.obligor
|
||||
val obligationOwner = states.first().data.beneficiary
|
||||
@ -700,18 +700,18 @@ fun <P> Iterable<ContractState>.sumObligationsOrZero(issuanceDef: Issued<Obligat
|
||||
= filterIsInstance<Obligation.State<P>>().filter { it.lifecycle == Obligation.Lifecycle.NORMAL }.map { it.amount }.sumOrZero(issuanceDef)
|
||||
|
||||
infix fun <T> Obligation.State<T>.at(dueBefore: Instant) = copy(template = template.copy(dueBefore = dueBefore))
|
||||
infix fun <T> Obligation.State<T>.between(parties: Pair<Party, CompositeKey>) = copy(obligor = parties.first, beneficiary = parties.second)
|
||||
infix fun <T> Obligation.State<T>.between(parties: Pair<Party.Full, CompositeKey>) = copy(obligor = parties.first, beneficiary = parties.second)
|
||||
infix fun <T> Obligation.State<T>.`owned by`(owner: CompositeKey) = copy(beneficiary = owner)
|
||||
infix fun <T> Obligation.State<T>.`issued by`(party: Party) = copy(obligor = party)
|
||||
infix fun <T> Obligation.State<T>.`issued by`(party: Party.Full) = copy(obligor = party)
|
||||
// For Java users:
|
||||
@Suppress("unused") fun <T> Obligation.State<T>.ownedBy(owner: CompositeKey) = copy(beneficiary = owner)
|
||||
|
||||
@Suppress("unused") fun <T> Obligation.State<T>.issuedBy(party: Party) = copy(obligor = party)
|
||||
@Suppress("unused") fun <T> Obligation.State<T>.issuedBy(party: Party.Full) = copy(obligor = party)
|
||||
|
||||
/** A randomly generated key. */
|
||||
val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
|
||||
/** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */
|
||||
val DUMMY_OBLIGATION_ISSUER by lazy { Party("Snake Oil Issuer", DUMMY_OBLIGATION_ISSUER_KEY.public.composite) }
|
||||
val DUMMY_OBLIGATION_ISSUER by lazy { Party.Full("Snake Oil Issuer", DUMMY_OBLIGATION_ISSUER_KEY.public.composite) }
|
||||
|
||||
val Issued<Currency>.OBLIGATION_DEF: Obligation.Terms<Currency>
|
||||
get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME)
|
||||
|
@ -31,7 +31,7 @@ import java.util.*
|
||||
* @return a vault object that represents the generated states (it will NOT be the full vault from the service hub!).
|
||||
*/
|
||||
fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
||||
outputNotary: Party = DUMMY_NOTARY,
|
||||
outputNotary: Party.Full = DUMMY_NOTARY,
|
||||
atLeastThisManyStates: Int = 3,
|
||||
atMostThisManyStates: Int = 10,
|
||||
rng: Random = Random(),
|
||||
|
@ -93,7 +93,7 @@ class CashFlow(val command: CashCommand, override val progressTracker: ProgressT
|
||||
|
||||
// TODO: Is it safe to drop participants we don't know how to contact? Does not knowing how to contact them
|
||||
// count as a reason to fail?
|
||||
val participants: Set<Party> = inputStates
|
||||
val participants: Set<Party.Full> = inputStates
|
||||
.filterIsInstance<Cash.State>()
|
||||
.map { serviceHub.identityService.partyFromKey(it.owner) }
|
||||
.filterNotNull()
|
||||
@ -106,7 +106,7 @@ class CashFlow(val command: CashCommand, override val progressTracker: ProgressT
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
private fun finaliseTx(participants: Set<Party>, tx: SignedTransaction, message: String) {
|
||||
private fun finaliseTx(participants: Set<Party.Full>, tx: SignedTransaction, message: String) {
|
||||
try {
|
||||
subFlow(FinalityFlow(tx, participants))
|
||||
} catch (e: NotaryException) {
|
||||
@ -145,8 +145,8 @@ sealed class CashCommand {
|
||||
*/
|
||||
class IssueCash(val amount: Amount<Currency>,
|
||||
val issueRef: OpaqueBytes,
|
||||
val recipient: Party,
|
||||
val notary: Party) : CashCommand()
|
||||
val recipient: Party.Full,
|
||||
val notary: Party.Full) : CashCommand()
|
||||
|
||||
/**
|
||||
* Pay cash to someone else.
|
||||
@ -154,7 +154,7 @@ sealed class CashCommand {
|
||||
* @param amount the amount of currency to issue on to the ledger.
|
||||
* @param recipient the party to issue the cash to.
|
||||
*/
|
||||
class PayCash(val amount: Amount<Issued<Currency>>, val recipient: Party) : CashCommand()
|
||||
class PayCash(val amount: Amount<Issued<Currency>>, val recipient: Party.Full) : CashCommand()
|
||||
|
||||
/**
|
||||
* Exit cash from the ledger.
|
||||
|
@ -19,14 +19,14 @@ import java.util.*
|
||||
* useful for creation of fake assets.
|
||||
*/
|
||||
object IssuerFlow {
|
||||
data class IssuanceRequestState(val amount: Amount<Currency>, val issueToParty: Party, val issuerPartyRef: OpaqueBytes)
|
||||
data class IssuanceRequestState(val amount: Amount<Currency>, val issueToParty: Party.Full, val issuerPartyRef: OpaqueBytes)
|
||||
|
||||
/**
|
||||
* IssuanceRequester should be used by a client to ask a remote node to issue some [FungibleAsset] with the given details.
|
||||
* Returns the transaction created by the Issuer to move the cash to the Requester.
|
||||
*/
|
||||
class IssuanceRequester(val amount: Amount<Currency>, val issueToParty: Party, val issueToPartyRef: OpaqueBytes,
|
||||
val issuerBankParty: Party): FlowLogic<SignedTransaction>() {
|
||||
class IssuanceRequester(val amount: Amount<Currency>, val issueToParty: Party.Full, val issueToPartyRef: OpaqueBytes,
|
||||
val issuerBankParty: Party.Full): FlowLogic<SignedTransaction>() {
|
||||
@Suspendable
|
||||
@Throws(CashException::class)
|
||||
override fun call(): SignedTransaction {
|
||||
@ -39,7 +39,7 @@ object IssuerFlow {
|
||||
* Issuer refers to a Node acting as a Bank Issuer of [FungibleAsset], and processes requests from a [IssuanceRequester] client.
|
||||
* Returns the generated transaction representing the transfer of the [Issued] [FungibleAsset] to the issue requester.
|
||||
*/
|
||||
class Issuer(val otherParty: Party): FlowLogic<SignedTransaction>() {
|
||||
class Issuer(val otherParty: Party.Full): FlowLogic<SignedTransaction>() {
|
||||
companion object {
|
||||
object AWAITING_REQUEST : ProgressTracker.Step("Awaiting issuance request")
|
||||
object ISSUING : ProgressTracker.Step("Self issuing asset")
|
||||
@ -71,7 +71,7 @@ object IssuerFlow {
|
||||
// state references (thus causing Notarisation double spend exceptions).
|
||||
@Suspendable
|
||||
private fun issueCashTo(amount: Amount<Currency>,
|
||||
issueTo: Party,
|
||||
issueTo: Party.Full,
|
||||
issuerPartyRef: OpaqueBytes): SignedTransaction {
|
||||
// TODO: pass notary in as request parameter
|
||||
val notaryParty = serviceHub.networkMapCache.notaryNodes[0].notaryIdentity
|
||||
|
@ -58,7 +58,7 @@ object TwoPartyTradeFlow {
|
||||
data class SignaturesFromSeller(val sellerSig: DigitalSignature.WithKey,
|
||||
val notarySig: DigitalSignature.WithKey)
|
||||
|
||||
open class Seller(val otherParty: Party,
|
||||
open class Seller(val otherParty: Party.Full,
|
||||
val notaryNode: NodeInfo,
|
||||
val assetToSell: StateAndRef<OwnableState>,
|
||||
val price: Amount<Currency>,
|
||||
@ -166,8 +166,8 @@ object TwoPartyTradeFlow {
|
||||
}
|
||||
|
||||
// DOCSTART 2
|
||||
open class Buyer(val otherParty: Party,
|
||||
val notary: Party,
|
||||
open class Buyer(val otherParty: Party.Full,
|
||||
val notary: Party.Full,
|
||||
val acceptablePrice: Amount<Currency>,
|
||||
val typeToBuy: Class<out OwnableState>) : FlowLogic<SignedTransaction>() {
|
||||
|
||||
|
@ -35,8 +35,8 @@ import kotlin.test.assertTrue
|
||||
|
||||
interface ICommercialPaperTestTemplate {
|
||||
fun getPaper(): ICommercialPaperState
|
||||
fun getIssueCommand(notary: Party): CommandData
|
||||
fun getRedeemCommand(notary: Party): CommandData
|
||||
fun getIssueCommand(notary: Party.Full): CommandData
|
||||
fun getRedeemCommand(notary: Party.Full): CommandData
|
||||
fun getMoveCommand(): CommandData
|
||||
}
|
||||
|
||||
@ -48,8 +48,8 @@ class JavaCommercialPaperTest() : ICommercialPaperTestTemplate {
|
||||
TEST_TX_TIME + 7.days
|
||||
)
|
||||
|
||||
override fun getIssueCommand(notary: Party): CommandData = JavaCommercialPaper.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party): CommandData = JavaCommercialPaper.Commands.Redeem()
|
||||
override fun getIssueCommand(notary: Party.Full): CommandData = JavaCommercialPaper.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party.Full): CommandData = JavaCommercialPaper.Commands.Redeem()
|
||||
override fun getMoveCommand(): CommandData = JavaCommercialPaper.Commands.Move()
|
||||
}
|
||||
|
||||
@ -61,8 +61,8 @@ class KotlinCommercialPaperTest() : ICommercialPaperTestTemplate {
|
||||
maturityDate = TEST_TX_TIME + 7.days
|
||||
)
|
||||
|
||||
override fun getIssueCommand(notary: Party): CommandData = CommercialPaper.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party): CommandData = CommercialPaper.Commands.Redeem()
|
||||
override fun getIssueCommand(notary: Party.Full): CommandData = CommercialPaper.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party.Full): CommandData = CommercialPaper.Commands.Redeem()
|
||||
override fun getMoveCommand(): CommandData = CommercialPaper.Commands.Move()
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ class KotlinCommercialPaperLegacyTest() : ICommercialPaperTestTemplate {
|
||||
maturityDate = TEST_TX_TIME + 7.days
|
||||
)
|
||||
|
||||
override fun getIssueCommand(notary: Party): CommandData = CommercialPaperLegacy.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party): CommandData = CommercialPaperLegacy.Commands.Redeem()
|
||||
override fun getIssueCommand(notary: Party.Full): CommandData = CommercialPaperLegacy.Commands.Issue()
|
||||
override fun getRedeemCommand(notary: Party.Full): CommandData = CommercialPaperLegacy.Commands.Redeem()
|
||||
override fun getMoveCommand(): CommandData = CommercialPaperLegacy.Commands.Move()
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ class CashTests {
|
||||
|
||||
val THEIR_PUBKEY_1 = DUMMY_PUBKEY_2
|
||||
|
||||
fun makeCash(amount: Amount<Currency>, corp: Party, depositRef: Byte = 1) =
|
||||
fun makeCash(amount: Amount<Currency>, corp: Party.Full, depositRef: Byte = 1) =
|
||||
StateAndRef(
|
||||
Cash.State(amount `issued by` corp.ref(depositRef), OUR_PUBKEY_1) `with notary` DUMMY_NOTARY,
|
||||
StateRef(SecureHash.randomSHA256(), Random().nextInt(32))
|
||||
@ -475,7 +475,7 @@ class CashTests {
|
||||
/**
|
||||
* Generate an exit transaction, removing some amount of cash from the ledger.
|
||||
*/
|
||||
fun makeExit(amount: Amount<Currency>, corp: Party, depositRef: Byte = 1): WireTransaction {
|
||||
fun makeExit(amount: Amount<Currency>, corp: Party.Full, depositRef: Byte = 1): WireTransaction {
|
||||
val tx = TransactionType.General.Builder(DUMMY_NOTARY)
|
||||
Cash().generateExit(tx, Amount(amount.quantity, Issued(corp.ref(depositRef), amount.token)), WALLET)
|
||||
return tx.toWireTransaction()
|
||||
|
@ -30,7 +30,7 @@ class DistributedServiceTests : DriverBasedTest() {
|
||||
lateinit var alice: NodeHandle
|
||||
lateinit var notaries: List<NodeHandle>
|
||||
lateinit var aliceProxy: CordaRPCOps
|
||||
lateinit var raftNotaryIdentity: Party
|
||||
lateinit var raftNotaryIdentity: Party.Full
|
||||
lateinit var notaryStateMachines: Observable<Pair<NodeInfo, StateMachineUpdate>>
|
||||
|
||||
override fun setup() = driver {
|
||||
@ -80,7 +80,7 @@ class DistributedServiceTests : DriverBasedTest() {
|
||||
}
|
||||
|
||||
// The state machines added in the notaries should map one-to-one to notarisation requests
|
||||
val notarisationsPerNotary = HashMap<Party, Int>()
|
||||
val notarisationsPerNotary = HashMap<Party.Full, Int>()
|
||||
notaryStateMachines.expectEvents(isStrict = false) {
|
||||
replicate<Pair<NodeInfo, StateMachineUpdate>>(50) {
|
||||
expect(match = { it.second is StateMachineUpdate.Added }) {
|
||||
@ -119,7 +119,7 @@ class DistributedServiceTests : DriverBasedTest() {
|
||||
paySelf(5.POUNDS)
|
||||
}
|
||||
|
||||
val notarisationsPerNotary = HashMap<Party, Int>()
|
||||
val notarisationsPerNotary = HashMap<Party.Full, Int>()
|
||||
notaryStateMachines.expectEvents(isStrict = false) {
|
||||
replicate<Pair<NodeInfo, StateMachineUpdate>>(30) {
|
||||
expect(match = { it.second is StateMachineUpdate.Added }) {
|
||||
|
@ -56,7 +56,7 @@ class RaftNotaryServiceTests : NodeBasedTest() {
|
||||
assertEquals(error.tx, secondSpendTx.tx)
|
||||
}
|
||||
|
||||
private fun issueState(node: AbstractNode, notary: Party, notaryKey: KeyPair): StateAndRef<*> {
|
||||
private fun issueState(node: AbstractNode, notary: Party.Full, notaryKey: KeyPair): StateAndRef<*> {
|
||||
return databaseTransaction(node.database) {
|
||||
val tx = DummyContract.generateInitial(node.info.legalIdentity.ref(0), Random().nextInt(), notary)
|
||||
tx.signWith(node.services.legalIdentityKey)
|
||||
|
@ -226,7 +226,7 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
.withMessageContaining(permission)
|
||||
}
|
||||
|
||||
private fun startBobAndCommunicateWithAlice(): Party {
|
||||
private fun startBobAndCommunicateWithAlice(): Party.Full {
|
||||
val bob = startNode("Bob").getOrThrow()
|
||||
bob.services.registerFlowInitiator(SendFlow::class, ::ReceiveFlow)
|
||||
val bobParty = bob.info.legalIdentity
|
||||
@ -235,12 +235,12 @@ abstract class MQSecurityTest : NodeBasedTest() {
|
||||
return bobParty
|
||||
}
|
||||
|
||||
private class SendFlow(val otherParty: Party, val payload: Any) : FlowLogic<Unit>() {
|
||||
private class SendFlow(val otherParty: Party.Full, val payload: Any) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() = send(otherParty, payload)
|
||||
}
|
||||
|
||||
private class ReceiveFlow(val otherParty: Party) : FlowLogic<Any>() {
|
||||
private class ReceiveFlow(val otherParty: Party.Full) : FlowLogic<Any>() {
|
||||
@Suspendable
|
||||
override fun call() = receive<Any>(otherParty).unwrap { it }
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class P2PSecurityTest : NodeBasedTest() {
|
||||
}
|
||||
|
||||
private fun SimpleNode.registerWithNetworkMap(registrationName: String): ListenableFuture<NetworkMapService.RegistrationResponse> {
|
||||
val nodeInfo = NodeInfo(net.myAddress, Party(registrationName, identity.public))
|
||||
val nodeInfo = NodeInfo(net.myAddress, Party.Full(registrationName, identity.public))
|
||||
val registration = NodeRegistration(nodeInfo, System.currentTimeMillis(), AddOrRemove.ADD, Instant.MAX)
|
||||
val request = RegistrationRequest(registration.toWire(identity.private), net.myAddress)
|
||||
return net.sendRequest<NetworkMapService.RegistrationResponse>(REGISTER_FLOW_TOPIC, request, networkMapNode.net.myAddress)
|
||||
|
@ -59,7 +59,7 @@ interface DriverDSLExposedInterface {
|
||||
/**
|
||||
* Starts a [Node] in a separate process.
|
||||
*
|
||||
* @param providedName Optional name of the node, which will be its legal name in [Party]. Defaults to something
|
||||
* @param providedName Optional name of the node, which will be its legal name in [Party.Full]. Defaults to something
|
||||
* random. Note that this must be unique as the driver uses it as a primary key!
|
||||
* @param advertisedServices The set of services to be advertised by the node. Defaults to empty set.
|
||||
* @param rpcUsers List of users who are authorised to use the RPC system. Defaults to empty list.
|
||||
@ -77,13 +77,13 @@ interface DriverDSLExposedInterface {
|
||||
* @param clusterSize Number of nodes to create for the cluster.
|
||||
* @param type The advertised notary service type. Currently the only supported type is [RaftValidatingNotaryService.type].
|
||||
* @param rpcUsers List of users who are authorised to use the RPC system. Defaults to empty list.
|
||||
* @return The [Party] identity of the distributed notary service, and the [NodeInfo]s of the notaries in the cluster.
|
||||
* @return The [Party.Full] identity of the distributed notary service, and the [NodeInfo]s of the notaries in the cluster.
|
||||
*/
|
||||
fun startNotaryCluster(
|
||||
notaryName: String,
|
||||
clusterSize: Int = 3,
|
||||
type: ServiceType = RaftValidatingNotaryService.type,
|
||||
rpcUsers: List<User> = emptyList()): Future<Pair<Party, List<NodeHandle>>>
|
||||
rpcUsers: List<User> = emptyList()): Future<Pair<Party.Full, List<NodeHandle>>>
|
||||
|
||||
/**
|
||||
* Starts a web server for a node
|
||||
@ -386,7 +386,7 @@ open class DriverDSL(
|
||||
clusterSize: Int,
|
||||
type: ServiceType,
|
||||
rpcUsers: List<User>
|
||||
): ListenableFuture<Pair<Party, List<NodeHandle>>> {
|
||||
): ListenableFuture<Pair<Party.Full, List<NodeHandle>>> {
|
||||
val nodeNames = (1..clusterSize).map { "Notary Node $it" }
|
||||
val paths = nodeNames.map { driverDirectory / it }
|
||||
ServiceIdentityGenerator.generateToDisk(paths, type.id, notaryName)
|
||||
|
@ -104,7 +104,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
// low-performance prototyping period.
|
||||
protected abstract val serverThread: AffinityExecutor
|
||||
|
||||
private val flowFactories = ConcurrentHashMap<Class<*>, (Party) -> FlowLogic<*>>()
|
||||
private val flowFactories = ConcurrentHashMap<Class<*>, (Party.Full) -> FlowLogic<*>>()
|
||||
protected val partyKeys = mutableSetOf<KeyPair>()
|
||||
|
||||
val services = object : ServiceHubInternal() {
|
||||
@ -127,13 +127,13 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
return serverThread.fetchFrom { smm.add(logic) }
|
||||
}
|
||||
|
||||
override fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party) -> FlowLogic<*>) {
|
||||
override fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party.Full) -> FlowLogic<*>) {
|
||||
require(markerClass !in flowFactories) { "${markerClass.java.name} has already been used to register a flow" }
|
||||
log.info("Registering flow ${markerClass.java.name}")
|
||||
flowFactories[markerClass.java] = flowFactory
|
||||
}
|
||||
|
||||
override fun getFlowFactory(markerClass: Class<*>): ((Party) -> FlowLogic<*>)? {
|
||||
override fun getFlowFactory(markerClass: Class<*>): ((Party.Full) -> FlowLogic<*>)? {
|
||||
return flowFactories[markerClass]
|
||||
}
|
||||
|
||||
@ -491,10 +491,10 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
stateMachineRecordedTransactionMappingStorage: StateMachineRecordedTransactionMappingStorage) =
|
||||
StorageServiceImpl(attachments, transactionStorage, stateMachineRecordedTransactionMappingStorage)
|
||||
|
||||
protected fun obtainLegalIdentity(): Party = obtainKeyPair(configuration.baseDirectory, PRIVATE_KEY_FILE_NAME, PUBLIC_IDENTITY_FILE_NAME).first
|
||||
protected fun obtainLegalIdentity(): Party.Full = obtainKeyPair(configuration.baseDirectory, PRIVATE_KEY_FILE_NAME, PUBLIC_IDENTITY_FILE_NAME).first
|
||||
protected fun obtainLegalIdentityKey(): KeyPair = obtainKeyPair(configuration.baseDirectory, PRIVATE_KEY_FILE_NAME, PUBLIC_IDENTITY_FILE_NAME).second
|
||||
|
||||
private fun obtainKeyPair(dir: Path, privateKeyFileName: String, publicKeyFileName: String, serviceName: String? = null): Pair<Party, KeyPair> {
|
||||
private fun obtainKeyPair(dir: Path, privateKeyFileName: String, publicKeyFileName: String, serviceName: String? = null): Pair<Party.Full, KeyPair> {
|
||||
// Load the private identity key, creating it if necessary. The identity key is a long term well known key that
|
||||
// is distributed to other peers and we use it (or a key signed by it) when we need to do something
|
||||
// "permissioned". The identity file is what gets distributed and contains the node's legal name along with
|
||||
@ -508,7 +508,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
log.info("Identity key not found, generating fresh key!")
|
||||
val keyPair: KeyPair = generateKeyPair()
|
||||
keyPair.serialize().writeToFile(privKeyFile)
|
||||
val myIdentity = Party(identityName, keyPair.public)
|
||||
val myIdentity = Party.Full(identityName, keyPair.public)
|
||||
// We include the Party class with the file here to help catch mixups when admins provide files of the
|
||||
// wrong type by mistake.
|
||||
myIdentity.serialize().writeToFile(pubIdentityFile)
|
||||
@ -517,7 +517,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
// Check that the identity in the config file matches the identity file we have stored to disk.
|
||||
// This is just a sanity check. It shouldn't fail unless the admin has fiddled with the files and messed
|
||||
// things up for us.
|
||||
val myIdentity = pubIdentityFile.readAll().deserialize<Party>()
|
||||
val myIdentity = pubIdentityFile.readAll().deserialize<Party.Full>()
|
||||
if (myIdentity.name != identityName)
|
||||
throw ConfigurationException("The legal name in the config file doesn't match the stored identity file:" +
|
||||
"$identityName vs ${myIdentity.name}")
|
||||
|
@ -13,17 +13,17 @@ import javax.annotation.concurrent.ThreadSafe
|
||||
*/
|
||||
@ThreadSafe
|
||||
class InMemoryIdentityService() : SingletonSerializeAsToken(), IdentityService {
|
||||
private val keyToParties = ConcurrentHashMap<CompositeKey, Party>()
|
||||
private val nameToParties = ConcurrentHashMap<String, Party>()
|
||||
private val keyToParties = ConcurrentHashMap<CompositeKey, Party.Full>()
|
||||
private val nameToParties = ConcurrentHashMap<String, Party.Full>()
|
||||
|
||||
override fun registerIdentity(party: Party) {
|
||||
override fun registerIdentity(party: Party.Full) {
|
||||
keyToParties[party.owningKey] = party
|
||||
nameToParties[party.name] = party
|
||||
}
|
||||
|
||||
// We give the caller a copy of the data set to avoid any locking problems
|
||||
override fun getAllIdentities(): Iterable<Party> = ArrayList(keyToParties.values)
|
||||
override fun getAllIdentities(): Iterable<Party.Full> = ArrayList(keyToParties.values)
|
||||
|
||||
override fun partyFromKey(key: CompositeKey): Party? = keyToParties[key]
|
||||
override fun partyFromName(name: String): Party? = nameToParties[name]
|
||||
override fun partyFromKey(key: CompositeKey): Party.Full? = keyToParties[key]
|
||||
override fun partyFromName(name: String): Party.Full? = nameToParties[name]
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ private class RPCKryo(observableSerializer: Serializer<Observable<Any>>? = null)
|
||||
register(SignedTransaction::class.java, ImmutableClassSerializer(SignedTransaction::class))
|
||||
register(WireTransaction::class.java, WireTransactionSerializer)
|
||||
register(SerializedBytes::class.java, SerializedBytesSerializer)
|
||||
register(Party::class.java)
|
||||
register(Party.Full::class.java)
|
||||
register(Array<Any>(0,{}).javaClass)
|
||||
register(Class::class.java, ClassSerializer)
|
||||
|
||||
|
@ -75,7 +75,7 @@ interface NetworkMapService {
|
||||
|
||||
data class FetchMapResponse(val nodes: Collection<NodeRegistration>?, val version: Int)
|
||||
|
||||
class QueryIdentityRequest(val identity: Party,
|
||||
class QueryIdentityRequest(val identity: Party.Full,
|
||||
override val replyTo: SingleMessageRecipient,
|
||||
override val sessionID: Long) : ServiceRequestMessage
|
||||
|
||||
@ -100,7 +100,7 @@ interface NetworkMapService {
|
||||
@ThreadSafe
|
||||
class InMemoryNetworkMapService(services: ServiceHubInternal) : AbstractNetworkMapService(services) {
|
||||
|
||||
override val registeredNodes: MutableMap<Party, NodeRegistrationInfo> = ConcurrentHashMap()
|
||||
override val registeredNodes: MutableMap<Party.Full, NodeRegistrationInfo> = ConcurrentHashMap()
|
||||
override val subscribers = ThreadBox(mutableMapOf<SingleMessageRecipient, LastAcknowledgeInfo>())
|
||||
|
||||
init {
|
||||
@ -117,7 +117,7 @@ class InMemoryNetworkMapService(services: ServiceHubInternal) : AbstractNetworkM
|
||||
@ThreadSafe
|
||||
abstract class AbstractNetworkMapService
|
||||
(services: ServiceHubInternal) : NetworkMapService, AbstractNodeService(services) {
|
||||
protected abstract val registeredNodes: MutableMap<Party, NodeRegistrationInfo>
|
||||
protected abstract val registeredNodes: MutableMap<Party.Full, NodeRegistrationInfo>
|
||||
|
||||
// Map from subscriber address, to most recently acknowledged update map version.
|
||||
protected abstract val subscribers: ThreadBox<MutableMap<SingleMessageRecipient, LastAcknowledgeInfo>>
|
||||
@ -275,7 +275,7 @@ abstract class AbstractNetworkMapService
|
||||
// Update the current value atomically, so that if multiple updates come
|
||||
// in on different threads, there is no risk of a race condition while checking
|
||||
// sequence numbers.
|
||||
val registrationInfo = registeredNodes.compute(node.legalIdentity, { mapKey: Party, existing: NodeRegistrationInfo? ->
|
||||
val registrationInfo = registeredNodes.compute(node.legalIdentity, { mapKey: Party.Full, existing: NodeRegistrationInfo? ->
|
||||
changed = existing == null || existing.reg.serial < change.serial
|
||||
if (changed) {
|
||||
when (change.type) {
|
||||
|
@ -23,17 +23,17 @@ class PersistentNetworkMapService(services: ServiceHubInternal) : AbstractNetwor
|
||||
val registrationInfo = blob("node_registration_info")
|
||||
}
|
||||
|
||||
override val registeredNodes: MutableMap<Party, NodeRegistrationInfo> = synchronizedMap(object : AbstractJDBCHashMap<Party, NodeRegistrationInfo, Table>(Table, loadOnInit = true) {
|
||||
override fun keyFromRow(row: ResultRow): Party = Party(row[table.nodeParty.name], row[table.nodeParty.owningKey])
|
||||
override val registeredNodes: MutableMap<Party.Full, NodeRegistrationInfo> = synchronizedMap(object : AbstractJDBCHashMap<Party.Full, NodeRegistrationInfo, Table>(Table, loadOnInit = true) {
|
||||
override fun keyFromRow(row: ResultRow): Party.Full = Party.Full(row[table.nodeParty.name], row[table.nodeParty.owningKey])
|
||||
|
||||
override fun valueFromRow(row: ResultRow): NodeRegistrationInfo = deserializeFromBlob(row[table.registrationInfo])
|
||||
|
||||
override fun addKeyToInsert(insert: InsertStatement, entry: Map.Entry<Party, NodeRegistrationInfo>, finalizables: MutableList<() -> Unit>) {
|
||||
override fun addKeyToInsert(insert: InsertStatement, entry: Map.Entry<Party.Full, NodeRegistrationInfo>, finalizables: MutableList<() -> Unit>) {
|
||||
insert[table.nodeParty.name] = entry.key.name
|
||||
insert[table.nodeParty.owningKey] = entry.key.owningKey
|
||||
}
|
||||
|
||||
override fun addValueToInsert(insert: InsertStatement, entry: Map.Entry<Party, NodeRegistrationInfo>, finalizables: MutableList<() -> Unit>) {
|
||||
override fun addValueToInsert(insert: InsertStatement, entry: Map.Entry<Party.Full, NodeRegistrationInfo>, finalizables: MutableList<() -> Unit>) {
|
||||
insert[table.registrationInfo] = serializeToBlob(entry.value, finalizables)
|
||||
}
|
||||
})
|
||||
|
@ -40,20 +40,20 @@ object DataVending {
|
||||
services.registerFlowInitiator(BroadcastTransactionFlow::class, ::NotifyTransactionHandler)
|
||||
}
|
||||
|
||||
private class FetchTransactionsHandler(otherParty: Party) : FetchDataHandler<SignedTransaction>(otherParty) {
|
||||
private class FetchTransactionsHandler(otherParty: Party.Full) : FetchDataHandler<SignedTransaction>(otherParty) {
|
||||
override fun getData(id: SecureHash): SignedTransaction? {
|
||||
return serviceHub.storageService.validatedTransactions.getTransaction(id)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use Artemis message streaming support here, called "large messages". This avoids the need to buffer.
|
||||
private class FetchAttachmentsHandler(otherParty: Party) : FetchDataHandler<ByteArray>(otherParty) {
|
||||
private class FetchAttachmentsHandler(otherParty: Party.Full) : FetchDataHandler<ByteArray>(otherParty) {
|
||||
override fun getData(id: SecureHash): ByteArray? {
|
||||
return serviceHub.storageService.attachments.openAttachment(id)?.open()?.readBytes()
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class FetchDataHandler<out T>(val otherParty: Party) : FlowLogic<Unit>() {
|
||||
private abstract class FetchDataHandler<out T>(val otherParty: Party.Full) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
@Throws(FetchDataFlow.HashNotFound::class)
|
||||
override fun call() {
|
||||
@ -75,7 +75,7 @@ object DataVending {
|
||||
// includes us in any outside that list. Potentially just if it includes any outside that list at all.
|
||||
// TODO: Do we want to be able to reject specific transactions on more complex rules, for example reject incoming
|
||||
// cash without from unknown parties?
|
||||
class NotifyTransactionHandler(val otherParty: Party) : FlowLogic<Unit>() {
|
||||
class NotifyTransactionHandler(val otherParty: Party.Full) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val request = receive<BroadcastTransactionFlow.NotifyTxRequest>(otherParty).unwrap { it }
|
||||
|
@ -72,7 +72,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
}
|
||||
}
|
||||
|
||||
internal val openSessions = HashMap<Pair<FlowLogic<*>, Party>, FlowSession>()
|
||||
internal val openSessions = HashMap<Pair<FlowLogic<*>, Party.Full>, FlowSession>()
|
||||
|
||||
init {
|
||||
logic.stateMachine = this
|
||||
@ -133,7 +133,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
|
||||
@Suspendable
|
||||
override fun <T : Any> sendAndReceive(receiveType: Class<T>,
|
||||
otherParty: Party,
|
||||
otherParty: Party.Full,
|
||||
payload: Any,
|
||||
sessionFlow: FlowLogic<*>): UntrustworthyData<T> {
|
||||
val session = getConfirmedSession(otherParty, sessionFlow)
|
||||
@ -147,14 +147,14 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
|
||||
@Suspendable
|
||||
override fun <T : Any> receive(receiveType: Class<T>,
|
||||
otherParty: Party,
|
||||
otherParty: Party.Full,
|
||||
sessionFlow: FlowLogic<*>): UntrustworthyData<T> {
|
||||
val session = getConfirmedSession(otherParty, sessionFlow) ?: startNewSession(otherParty, sessionFlow, null, waitForConfirmation = true)
|
||||
return receiveInternal<SessionData>(session).checkPayloadIs(receiveType)
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun send(otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>) {
|
||||
override fun send(otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>) {
|
||||
val session = getConfirmedSession(otherParty, sessionFlow)
|
||||
if (session == null) {
|
||||
// Don't send the payload again if it was already piggy-backed on a session init
|
||||
@ -203,7 +203,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
private fun getConfirmedSession(otherParty: Party, sessionFlow: FlowLogic<*>): FlowSession? {
|
||||
private fun getConfirmedSession(otherParty: Party.Full, sessionFlow: FlowLogic<*>): FlowSession? {
|
||||
return openSessions[Pair(sessionFlow, otherParty)]?.apply {
|
||||
if (state is FlowSessionState.Initiating) {
|
||||
// Session still initiating, try to retrieve the init response.
|
||||
@ -219,7 +219,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
* multiple public keys, but we **don't support multiple nodes advertising the same legal identity**.
|
||||
*/
|
||||
@Suspendable
|
||||
private fun startNewSession(otherParty: Party, sessionFlow: FlowLogic<*>, firstPayload: Any?, waitForConfirmation: Boolean): FlowSession {
|
||||
private fun startNewSession(otherParty: Party.Full, sessionFlow: FlowLogic<*>, firstPayload: Any?, waitForConfirmation: Boolean): FlowSession {
|
||||
logger.trace { "Initiating a new session with $otherParty" }
|
||||
val session = FlowSession(sessionFlow, random63BitValue(), FlowSessionState.Initiating(otherParty))
|
||||
openSessions[Pair(sessionFlow, otherParty)] = session
|
||||
|
@ -31,7 +31,7 @@ data class SessionData(override val recipientSessionId: Long, val payload: Any)
|
||||
|
||||
data class SessionEnd(override val recipientSessionId: Long, val errorResponse: FlowException?) : ExistingSessionMessage
|
||||
|
||||
data class ReceivedSessionMessage<out M : ExistingSessionMessage>(val sender: Party, val message: M)
|
||||
data class ReceivedSessionMessage<out M : ExistingSessionMessage>(val sender: Party.Full, val message: M)
|
||||
|
||||
fun <T> ReceivedSessionMessage<SessionData>.checkPayloadIs(type: Class<T>): UntrustworthyData<T> {
|
||||
if (type.isInstance(message.payload)) {
|
||||
|
@ -117,7 +117,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
|
||||
private val totalFinishedFlows = metrics.counter("Flows.Finished")
|
||||
|
||||
private val openSessions = ConcurrentHashMap<Long, FlowSession>()
|
||||
private val recentlyClosedSessions = ConcurrentHashMap<Long, Party>()
|
||||
private val recentlyClosedSessions = ConcurrentHashMap<Long, Party.Full>()
|
||||
|
||||
// Context for tokenized services in checkpoints
|
||||
private val serializationContext = SerializeAsTokenContext(tokenizableServices, quasarKryo())
|
||||
@ -238,7 +238,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
|
||||
}
|
||||
}
|
||||
|
||||
private fun onExistingSessionMessage(message: ExistingSessionMessage, sender: Party) {
|
||||
private fun onExistingSessionMessage(message: ExistingSessionMessage, sender: Party.Full) {
|
||||
val session = openSessions[message.recipientSessionId]
|
||||
if (session != null) {
|
||||
session.fiber.logger.trace { "Received $message on $session" }
|
||||
@ -267,7 +267,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSessionInit(sessionInit: SessionInit, sender: Party) {
|
||||
private fun onSessionInit(sessionInit: SessionInit, sender: Party.Full) {
|
||||
logger.trace { "Received $sessionInit $sender" }
|
||||
val otherPartySessionId = sessionInit.initiatorSessionId
|
||||
|
||||
@ -472,7 +472,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendSessionMessage(party: Party, message: SessionMessage, fiber: FlowStateMachineImpl<*>? = null) {
|
||||
private fun sendSessionMessage(party: Party.Full, message: SessionMessage, fiber: FlowStateMachineImpl<*>? = null) {
|
||||
val partyInfo = serviceHub.networkMapCache.getPartyInfo(party)
|
||||
?: throw IllegalArgumentException("Don't know about party $party")
|
||||
val address = serviceHub.networkService.getAddressOfParty(partyInfo)
|
||||
@ -484,23 +484,24 @@ class StateMachineManager(val serviceHub: ServiceHubInternal,
|
||||
/**
|
||||
* [FlowSessionState] describes the session's state.
|
||||
*
|
||||
* [Initiating] is pre-handshake. [Initiating.otherParty] at this point holds a [Party] corresponding to either a
|
||||
* [Initiating] is pre-handshake. [Initiating.otherParty] at this point holds a [Party.Full] corresponding to either a
|
||||
* specific peer or a service.
|
||||
* [Initiated] is post-handshake. At this point [Initiating.otherParty] will have been resolved to a specific peer
|
||||
* [Initiated.peerParty], and the peer's sessionId has been initialised.
|
||||
*/
|
||||
sealed class FlowSessionState {
|
||||
abstract val sendToParty: Party
|
||||
abstract val sendToParty: Party.Full
|
||||
class Initiating(
|
||||
val otherParty: Party /** This may be a specific peer or a service party */
|
||||
val otherParty: Party.Full
|
||||
/** This may be a specific peer or a service party */
|
||||
) : FlowSessionState() {
|
||||
override val sendToParty: Party get() = otherParty
|
||||
override val sendToParty: Party.Full get() = otherParty
|
||||
}
|
||||
class Initiated(
|
||||
val peerParty: Party, /** This must be a peer party */
|
||||
val peerParty: Party.Full,/** This must be a peer party */
|
||||
val peerSessionId: Long
|
||||
) : FlowSessionState() {
|
||||
override val sendToParty: Party get() = peerParty
|
||||
override val sendToParty: Party.Full get() = peerParty
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class InMemoryUniquenessProvider() : UniquenessProvider {
|
||||
/** For each input state store the consuming transaction information */
|
||||
private val committedStates = ThreadBox(HashMap<StateRef, UniquenessProvider.ConsumingTx>())
|
||||
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party) {
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party.Full) {
|
||||
committedStates.locked {
|
||||
val conflictingStates = LinkedHashMap<StateRef, UniquenessProvider.ConsumingTx>()
|
||||
for (inputState in states) {
|
||||
|
@ -21,6 +21,6 @@ abstract class NotaryService(services: ServiceHubInternal) : SingletonSerializeA
|
||||
}
|
||||
|
||||
/** Implement a factory that specifies the transaction commit flow for the notary service to use */
|
||||
abstract fun createFlow(otherParty: Party): NotaryFlow.Service
|
||||
abstract fun createFlow(otherParty: Party.Full): NotaryFlow.Service
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsT
|
||||
override fun valueFromRow(row: ResultRow): UniquenessProvider.ConsumingTx = UniquenessProvider.ConsumingTx(
|
||||
row[table.consumingTxHash],
|
||||
row[table.consumingIndex],
|
||||
Party(row[table.requestingParty.name], row[table.requestingParty.owningKey])
|
||||
Party.Full(row[table.requestingParty.name], row[table.requestingParty.owningKey])
|
||||
)
|
||||
|
||||
override fun addKeyToInsert(insert: InsertStatement,
|
||||
@ -58,7 +58,7 @@ class PersistentUniquenessProvider() : UniquenessProvider, SingletonSerializeAsT
|
||||
}
|
||||
})
|
||||
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party) {
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party.Full) {
|
||||
val conflict = committedStates.locked {
|
||||
val conflictingStates = LinkedHashMap<StateRef, UniquenessProvider.ConsumingTx>()
|
||||
for (inputState in states) {
|
||||
|
@ -107,7 +107,7 @@ class RaftUniquenessProvider(storagePath: Path, myAddress: HostAndPort, clusterA
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party) {
|
||||
override fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party.Full) {
|
||||
val entries = states.mapIndexed { i, stateRef -> stateRef to UniquenessProvider.ConsumingTx(txId, i, callerIdentity) }
|
||||
|
||||
log.debug("Attempting to commit input states: ${states.joinToString()}")
|
||||
|
@ -13,7 +13,7 @@ class RaftValidatingNotaryService(services: ServiceHubInternal,
|
||||
val type = ValidatingNotaryService.type.getSubType("raft")
|
||||
}
|
||||
|
||||
override fun createFlow(otherParty: Party): ValidatingNotaryFlow {
|
||||
override fun createFlow(otherParty: Party.Full): ValidatingNotaryFlow {
|
||||
return ValidatingNotaryFlow(otherParty, timestampChecker, uniquenessProvider)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class SimpleNotaryService(services: ServiceHubInternal,
|
||||
val type = ServiceType.notary.getSubType("simple")
|
||||
}
|
||||
|
||||
override fun createFlow(otherParty: Party): NotaryFlow.Service {
|
||||
override fun createFlow(otherParty: Party.Full): NotaryFlow.Service {
|
||||
return NotaryFlow.Service(otherParty, timestampChecker, uniquenessProvider)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class ValidatingNotaryService(services: ServiceHubInternal,
|
||||
val type = ServiceType.notary.getSubType("validating")
|
||||
}
|
||||
|
||||
override fun createFlow(otherParty: Party): ValidatingNotaryFlow {
|
||||
override fun createFlow(otherParty: Party.Full): ValidatingNotaryFlow {
|
||||
return ValidatingNotaryFlow(otherParty, timestampChecker, uniquenessProvider)
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT
|
||||
override fun generateSpend(tx: TransactionBuilder,
|
||||
amount: Amount<Currency>,
|
||||
to: CompositeKey,
|
||||
onlyFromParties: Set<Party>?): Pair<TransactionBuilder, List<CompositeKey>> {
|
||||
onlyFromParties: Set<Party.Full>?): Pair<TransactionBuilder, List<CompositeKey>> {
|
||||
// Discussion
|
||||
//
|
||||
// This code is analogous to the Wallet.send() set of methods in bitcoinj, and has the same general outline.
|
||||
|
@ -29,11 +29,11 @@ import java.time.LocalDateTime
|
||||
*/
|
||||
object JsonSupport {
|
||||
interface PartyObjectMapper {
|
||||
fun partyFromName(partyName: String): Party?
|
||||
fun partyFromName(partyName: String): Party.Full?
|
||||
}
|
||||
|
||||
class RpcObjectMapper(val rpc: CordaRPCOps) : PartyObjectMapper, ObjectMapper() {
|
||||
override fun partyFromName(partyName: String): Party? = rpc.partyFromName(partyName)
|
||||
override fun partyFromName(partyName: String): Party.Full? = rpc.partyFromName(partyName)
|
||||
}
|
||||
class IdentityObjectMapper(val identityService: IdentityService) : PartyObjectMapper, ObjectMapper(){
|
||||
override fun partyFromName(partyName: String) = identityService.partyFromName(partyName)
|
||||
@ -53,8 +53,8 @@ object JsonSupport {
|
||||
|
||||
val cordaModule: Module by lazy {
|
||||
SimpleModule("core").apply {
|
||||
addSerializer(Party::class.java, PartySerializer)
|
||||
addDeserializer(Party::class.java, PartyDeserializer)
|
||||
addSerializer(Party.Full::class.java, PartySerializer)
|
||||
addDeserializer(Party.Full::class.java, PartyDeserializer)
|
||||
addSerializer(BigDecimal::class.java, ToStringSerializer)
|
||||
addDeserializer(BigDecimal::class.java, NumberDeserializers.BigDecimalDeserializer())
|
||||
addSerializer(SecureHash::class.java, SecureHashSerializer)
|
||||
@ -120,14 +120,14 @@ object JsonSupport {
|
||||
|
||||
}
|
||||
|
||||
object PartySerializer : JsonSerializer<Party>() {
|
||||
override fun serialize(obj: Party, generator: JsonGenerator, provider: SerializerProvider) {
|
||||
object PartySerializer : JsonSerializer<Party.Full>() {
|
||||
override fun serialize(obj: Party.Full, generator: JsonGenerator, provider: SerializerProvider) {
|
||||
generator.writeString(obj.name)
|
||||
}
|
||||
}
|
||||
|
||||
object PartyDeserializer : JsonDeserializer<Party>() {
|
||||
override fun deserialize(parser: JsonParser, context: DeserializationContext): Party {
|
||||
object PartyDeserializer : JsonDeserializer<Party.Full>() {
|
||||
override fun deserialize(parser: JsonParser, context: DeserializationContext): Party.Full {
|
||||
if (parser.currentToken == JsonToken.FIELD_NAME) {
|
||||
parser.nextToken()
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ object ServiceIdentityGenerator {
|
||||
|
||||
val keyPairs = (1..dirs.size).map { generateKeyPair() }
|
||||
val notaryKey = CompositeKey.Builder().addKeys(keyPairs.map { it.public.composite }).build(threshold)
|
||||
val notaryParty = Party(serviceName, notaryKey).serialize()
|
||||
val notaryParty = Party.Full(serviceName, notaryKey).serialize()
|
||||
|
||||
keyPairs.zip(dirs) { keyPair, dir ->
|
||||
Files.createDirectories(dir)
|
||||
|
@ -490,8 +490,8 @@ class TwoPartyTradeFlowTests {
|
||||
private fun LedgerDSL<TestTransactionDSLInterpreter, TestLedgerDSLInterpreter>.fillUpForBuyer(
|
||||
withError: Boolean,
|
||||
owner: CompositeKey,
|
||||
issuer: Party,
|
||||
notary: Party): Pair<Vault, List<WireTransaction>> {
|
||||
issuer: Party.Full,
|
||||
notary: Party.Full): Pair<Vault, List<WireTransaction>> {
|
||||
val interimOwnerKey = MEGA_CORP_PUBKEY
|
||||
// Bob (Buyer) has some cash he got from the Bank of Elbonia, Alice (Seller) has some commercial paper she
|
||||
// wants to sell to Bob.
|
||||
@ -538,7 +538,7 @@ class TwoPartyTradeFlowTests {
|
||||
owner: CompositeKey,
|
||||
amount: Amount<Issued<Currency>>,
|
||||
attachmentID: SecureHash?,
|
||||
notary: Party): Pair<Vault, List<WireTransaction>> {
|
||||
notary: Party.Full): Pair<Vault, List<WireTransaction>> {
|
||||
val ap = transaction(transactionBuilder = TransactionBuilder(notary = notary)) {
|
||||
output("alice's paper", notary = notary) {
|
||||
CommercialPaper.State(MEGA_CORP.ref(1, 2, 3), owner, amount, TEST_TX_TIME + 7.days)
|
||||
|
@ -65,7 +65,7 @@ open class MockServiceHubInternal(
|
||||
private val txStorageService: TxWritableStorageService
|
||||
get() = storage ?: throw UnsupportedOperationException()
|
||||
|
||||
private val flowFactories = ConcurrentHashMap<Class<*>, (Party) -> FlowLogic<*>>()
|
||||
private val flowFactories = ConcurrentHashMap<Class<*>, (Party.Full) -> FlowLogic<*>>()
|
||||
|
||||
lateinit var smm: StateMachineManager
|
||||
|
||||
@ -83,11 +83,11 @@ open class MockServiceHubInternal(
|
||||
return smm.executor.fetchFrom { smm.add(logic) }
|
||||
}
|
||||
|
||||
override fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party) -> FlowLogic<*>) {
|
||||
override fun registerFlowInitiator(markerClass: KClass<*>, flowFactory: (Party.Full) -> FlowLogic<*>) {
|
||||
flowFactories[markerClass.java] = flowFactory
|
||||
}
|
||||
|
||||
override fun getFlowFactory(markerClass: Class<*>): ((Party) -> FlowLogic<*>)? {
|
||||
override fun getFlowFactory(markerClass: Class<*>): ((Party.Full) -> FlowLogic<*>)? {
|
||||
return flowFactories[markerClass]
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class NotaryChangeTests {
|
||||
@Test
|
||||
fun `should throw when a participant refuses to change Notary`() {
|
||||
val state = issueMultiPartyState(clientNodeA, clientNodeB, oldNotaryNode)
|
||||
val newEvilNotary = Party("Evil Notary", generateKeyPair().public)
|
||||
val newEvilNotary = Party.Full("Evil Notary", generateKeyPair().public)
|
||||
val flow = Instigator(state, newEvilNotary)
|
||||
val future = clientNodeA.services.startFlow(flow)
|
||||
|
||||
@ -177,7 +177,7 @@ fun issueMultiPartyState(nodeA: AbstractNode, nodeB: AbstractNode, notaryNode: A
|
||||
return stateAndRef
|
||||
}
|
||||
|
||||
fun issueInvalidState(node: AbstractNode, notary: Party): StateAndRef<*> {
|
||||
fun issueInvalidState(node: AbstractNode, notary: Party.Full): StateAndRef<*> {
|
||||
val tx = DummyContract.generateInitial(node.info.legalIdentity.ref(0), Random().nextInt(), notary)
|
||||
tx.setTime(Instant.now(), 30.seconds)
|
||||
val nodeKey = node.services.legalIdentityKey
|
||||
|
@ -31,8 +31,8 @@ class ScheduledFlowTests {
|
||||
lateinit var nodeB: MockNetwork.MockNode
|
||||
|
||||
data class ScheduledState(val creationTime: Instant,
|
||||
val source: Party,
|
||||
val destination: Party,
|
||||
val source: Party.Full,
|
||||
val destination: Party.Full,
|
||||
val processed: Boolean = false,
|
||||
override val linearId: UniqueIdentifier = UniqueIdentifier(),
|
||||
override val contract: Contract = DummyContract()) : SchedulableState, LinearState {
|
||||
@ -52,7 +52,7 @@ class ScheduledFlowTests {
|
||||
}
|
||||
}
|
||||
|
||||
class InsertInitialStateFlow(val destination: Party) : FlowLogic<Unit>() {
|
||||
class InsertInitialStateFlow(val destination: Party.Full) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val scheduledState = ScheduledState(serviceHub.clock.instant(),
|
||||
@ -87,7 +87,7 @@ class ScheduledFlowTests {
|
||||
|
||||
class ScheduledFlowTestPlugin : CordaPluginRegistry() {
|
||||
override val requiredFlows: Map<String, Set<String>> = mapOf(
|
||||
InsertInitialStateFlow::class.java.name to setOf(Party::class.java.name),
|
||||
InsertInitialStateFlow::class.java.name to setOf(Party.Full::class.java.name),
|
||||
ScheduledFlow::class.java.name to setOf(StateRef::class.java.name)
|
||||
)
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class DataVendingServiceTests {
|
||||
}
|
||||
|
||||
|
||||
private class NotifyTxFlow(val otherParty: Party, val stx: SignedTransaction) : FlowLogic<Unit>() {
|
||||
private class NotifyTxFlow(val otherParty: Party.Full, val stx: SignedTransaction) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() = send(otherParty, NotifyTxRequest(stx))
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ class StateMachineManagerTests {
|
||||
assertThat((sessionTransfers.last().message as SessionEnd).errorResponse!!.stackTrace).isEmpty()
|
||||
}
|
||||
|
||||
private class SendAndReceiveFlow(val otherParty: Party, val payload: Any) : FlowLogic<Unit>() {
|
||||
private class SendAndReceiveFlow(val otherParty: Party.Full, val payload: Any) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
sendAndReceive<Any>(otherParty, payload)
|
||||
@ -434,7 +434,7 @@ class StateMachineManagerTests {
|
||||
)
|
||||
}
|
||||
|
||||
private class ConditionalExceptionFlow(val otherParty: Party, val sendPayload: Any) : FlowLogic<Unit>() {
|
||||
private class ConditionalExceptionFlow(val otherParty: Party.Full, val sendPayload: Any) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val throwException = receive<Boolean>(otherParty).unwrap { it }
|
||||
@ -447,12 +447,12 @@ class StateMachineManagerTests {
|
||||
|
||||
@Test
|
||||
fun `retry subFlow due to receiving FlowException`() {
|
||||
class AskForExceptionFlow(val otherParty: Party, val throwException: Boolean) : FlowLogic<String>() {
|
||||
class AskForExceptionFlow(val otherParty: Party.Full, val throwException: Boolean) : FlowLogic<String>() {
|
||||
@Suspendable
|
||||
override fun call(): String = sendAndReceive<String>(otherParty, throwException).unwrap { it }
|
||||
}
|
||||
|
||||
class RetryOnExceptionFlow(val otherParty: Party) : FlowLogic<String>() {
|
||||
class RetryOnExceptionFlow(val otherParty: Party.Full) : FlowLogic<String>() {
|
||||
@Suspendable
|
||||
override fun call(): String {
|
||||
return try {
|
||||
@ -541,7 +541,7 @@ class StateMachineManagerTests {
|
||||
}
|
||||
|
||||
|
||||
private class SendFlow(val payload: Any, vararg val otherParties: Party) : FlowLogic<Unit>() {
|
||||
private class SendFlow(val payload: Any, vararg val otherParties: Party.Full) : FlowLogic<Unit>() {
|
||||
init {
|
||||
require(otherParties.isNotEmpty())
|
||||
}
|
||||
@ -551,7 +551,7 @@ class StateMachineManagerTests {
|
||||
}
|
||||
|
||||
|
||||
private class ReceiveFlow(vararg val otherParties: Party) : FlowLogic<Unit>() {
|
||||
private class ReceiveFlow(vararg val otherParties: Party.Full) : FlowLogic<Unit>() {
|
||||
private var nonTerminating: Boolean = false
|
||||
|
||||
init {
|
||||
@ -574,7 +574,7 @@ class StateMachineManagerTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class PingPongFlow(val otherParty: Party, val payload: Long) : FlowLogic<Unit>() {
|
||||
private class PingPongFlow(val otherParty: Party.Full, val payload: Long) : FlowLogic<Unit>() {
|
||||
@Transient var receivedPayload: Long? = null
|
||||
@Transient var receivedPayload2: Long? = null
|
||||
|
||||
|
@ -59,7 +59,7 @@ val PROSPECTUS_HASH = SecureHash.parse("decd098666b9657314870e192ced0c3519c2c9d3
|
||||
|
||||
fun sender(rpc: CordaRPCOps) {
|
||||
// Get the identity key of the other side (the recipient).
|
||||
val otherSide: Party = rpc.partyFromName("Bank B")!!
|
||||
val otherSide: Party.Full = rpc.partyFromName("Bank B")!!
|
||||
|
||||
// Make sure we have the file in storage
|
||||
// TODO: We should have our own demo file, not share the trader demo file
|
||||
|
@ -13,7 +13,7 @@ class BankOfCordaPlugin : CordaPluginRegistry() {
|
||||
override val webApis = listOf(Function(::BankOfCordaWebApi))
|
||||
// A list of flow that are required for this cordapp
|
||||
override val requiredFlows: Map<String, Set<String>> =
|
||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
|
||||
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party.Full::class.java.name, OpaqueBytes::class.java.name, Party.Full::class.java.name)
|
||||
)
|
||||
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ object NodeInterestRates {
|
||||
services.registerFlowInitiator(RatesFixFlow.FixQueryFlow::class) { FixQueryHandler(it, this) }
|
||||
}
|
||||
|
||||
private class FixSignHandler(val otherParty: Party, val service: Service) : FlowLogic<Unit>() {
|
||||
private class FixSignHandler(val otherParty: Party.Full, val service: Service) : FlowLogic<Unit>() {
|
||||
@Suspendable
|
||||
override fun call() {
|
||||
val request = receive<RatesFixFlow.SignRequest>(otherParty).unwrap { it }
|
||||
@ -82,7 +82,7 @@ object NodeInterestRates {
|
||||
}
|
||||
}
|
||||
|
||||
private class FixQueryHandler(val otherParty: Party, val service: Service) : FlowLogic<Unit>() {
|
||||
private class FixQueryHandler(val otherParty: Party.Full, val service: Service) : FlowLogic<Unit>() {
|
||||
companion object {
|
||||
object RECEIVED : ProgressTracker.Step("Received fix request")
|
||||
object SENDING : ProgressTracker.Step("Sending fix response")
|
||||
@ -123,7 +123,7 @@ object NodeInterestRates {
|
||||
* The oracle will try to interpolate the missing value of a tenor for the given fix name and date.
|
||||
*/
|
||||
@ThreadSafe
|
||||
class Oracle(val identity: Party, private val signingKey: KeyPair, val clock: Clock) {
|
||||
class Oracle(val identity: Party.Full, private val signingKey: KeyPair, val clock: Clock) {
|
||||
private object Table : JDBCHashedTable("demo_interest_rate_fixes") {
|
||||
val name = varchar("index_name", length = 255)
|
||||
val forDay = localDate("for_day")
|
||||
|
@ -304,7 +304,7 @@ class InterestRateSwap() : Contract {
|
||||
}
|
||||
|
||||
open class FixedLeg(
|
||||
var fixedRatePayer: Party,
|
||||
var fixedRatePayer: Party.Full,
|
||||
notional: Amount<Currency>,
|
||||
paymentFrequency: Frequency,
|
||||
effectiveDate: LocalDate,
|
||||
@ -343,7 +343,7 @@ class InterestRateSwap() : Contract {
|
||||
override fun hashCode() = super.hashCode() + 31 * Objects.hash(fixedRatePayer, fixedRate, rollConvention)
|
||||
|
||||
// Can't autogenerate as not a data class :-(
|
||||
fun copy(fixedRatePayer: Party = this.fixedRatePayer,
|
||||
fun copy(fixedRatePayer: Party.Full = this.fixedRatePayer,
|
||||
notional: Amount<Currency> = this.notional,
|
||||
paymentFrequency: Frequency = this.paymentFrequency,
|
||||
effectiveDate: LocalDate = this.effectiveDate,
|
||||
@ -365,7 +365,7 @@ class InterestRateSwap() : Contract {
|
||||
}
|
||||
|
||||
open class FloatingLeg(
|
||||
var floatingRatePayer: Party,
|
||||
var floatingRatePayer: Party.Full,
|
||||
notional: Amount<Currency>,
|
||||
paymentFrequency: Frequency,
|
||||
effectiveDate: LocalDate,
|
||||
@ -423,7 +423,7 @@ class InterestRateSwap() : Contract {
|
||||
index, indexSource, indexTenor)
|
||||
|
||||
|
||||
fun copy(floatingRatePayer: Party = this.floatingRatePayer,
|
||||
fun copy(floatingRatePayer: Party.Full = this.floatingRatePayer,
|
||||
notional: Amount<Currency> = this.notional,
|
||||
paymentFrequency: Frequency = this.paymentFrequency,
|
||||
effectiveDate: LocalDate = this.effectiveDate,
|
||||
@ -672,7 +672,7 @@ class InterestRateSwap() : Contract {
|
||||
return fixedLeg.fixedRatePayer.owningKey.containsAny(ourKeys) || floatingLeg.floatingRatePayer.owningKey.containsAny(ourKeys)
|
||||
}
|
||||
|
||||
override val parties: List<Party>
|
||||
override val parties: List<Party.Full>
|
||||
get() = listOf(fixedLeg.fixedRatePayer, floatingLeg.floatingRatePayer)
|
||||
|
||||
override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
|
||||
@ -683,7 +683,7 @@ class InterestRateSwap() : Contract {
|
||||
return ScheduledActivity(flowLogicRefFactory.create(FixingFlow.FixingRoleDecider::class.java, thisStateRef), instant)
|
||||
}
|
||||
|
||||
override fun generateAgreement(notary: Party): TransactionBuilder = InterestRateSwap().generateAgreement(floatingLeg, fixedLeg, calculation, common, notary)
|
||||
override fun generateAgreement(notary: Party.Full): TransactionBuilder = InterestRateSwap().generateAgreement(floatingLeg, fixedLeg, calculation, common, notary)
|
||||
|
||||
override fun generateFix(ptx: TransactionBuilder, oldState: StateAndRef<*>, fix: Fix) {
|
||||
InterestRateSwap().generateFix(ptx, StateAndRef(TransactionState(this, oldState.state.notary), oldState.ref), fix)
|
||||
@ -728,7 +728,7 @@ class InterestRateSwap() : Contract {
|
||||
* Note: The day count, interest rate calculation etc are not finished yet, but they are demonstrable.
|
||||
*/
|
||||
fun generateAgreement(floatingLeg: FloatingLeg, fixedLeg: FixedLeg, calculation: Calculation,
|
||||
common: Common, notary: Party): TransactionBuilder {
|
||||
common: Common, notary: Party.Full): TransactionBuilder {
|
||||
|
||||
val fixedLegPaymentSchedule = LinkedHashMap<LocalDate, FixedRatePaymentEvent>()
|
||||
var dates = BusinessCalendar.createGenericSchedule(fixedLeg.effectiveDate, fixedLeg.paymentFrequency, fixedLeg.paymentCalendar, fixedLeg.rollConvention, endDate = fixedLeg.terminationDate)
|
||||
|
@ -78,8 +78,8 @@ object AutoOfferFlow {
|
||||
return stx
|
||||
}
|
||||
|
||||
private fun notUs(parties: List<Party>): List<Party> {
|
||||
val notUsParties: MutableList<Party> = arrayListOf()
|
||||
private fun notUs(parties: List<Party.Full>): List<Party.Full> {
|
||||
val notUsParties: MutableList<Party.Full> = arrayListOf()
|
||||
for (party in parties) {
|
||||
if (serviceHub.myInfo.legalIdentity != party) {
|
||||
notUsParties.add(party)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user