From 1b86ddfd6effd0a757e24872014ac0ce34ffddab Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Wed, 1 Feb 2017 11:13:50 +0000 Subject: [PATCH] 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 --- .../net/corda/client/mock/EventGenerator.kt | 6 ++-- .../net/corda/core/contracts/ContractsDSL.kt | 4 +-- .../net/corda/core/contracts/DummyContract.kt | 2 +- .../net/corda/core/contracts/Structures.kt | 18 +++++------ .../corda/core/contracts/TransactionTypes.kt | 4 +-- .../core/contracts/TransactionVerification.kt | 4 +-- .../net/corda/core/crypto/CryptoUtilities.kt | 6 ++-- .../kotlin/net/corda/core/crypto/Party.kt | 19 ++++++----- .../kotlin/net/corda/core/flows/FlowLogic.kt | 12 +++---- .../net/corda/core/flows/FlowStateMachine.kt | 6 ++-- .../net/corda/core/messaging/CordaRPCOps.kt | 8 ++--- .../kotlin/net/corda/core/node/NodeInfo.kt | 8 ++--- .../net/corda/core/node/PluginServiceHub.kt | 4 +-- .../core/node/services/IdentityService.kt | 10 +++--- .../core/node/services/NetworkMapCache.kt | 8 ++--- .../net/corda/core/node/services/PartyInfo.kt | 4 +-- .../net/corda/core/node/services/Services.kt | 4 +-- .../core/node/services/UniquenessProvider.kt | 4 +-- .../net/corda/core/serialization/Kryo.kt | 4 +-- .../net/corda/core/testing/Generators.kt | 6 ++-- .../core/transactions/BaseTransaction.kt | 2 +- .../core/transactions/LedgerTransaction.kt | 2 +- .../core/transactions/TransactionBuilder.kt | 4 +-- .../core/transactions/WireTransaction.kt | 2 +- .../net/corda/core/utilities/ApiUtils.kt | 2 +- .../net/corda/core/utilities/TestConstants.kt | 2 +- .../flows/AbstractStateReplacementFlow.kt | 4 +-- .../corda/flows/BroadcastTransactionFlow.kt | 2 +- .../net/corda/flows/FetchAttachmentsFlow.kt | 2 +- .../kotlin/net/corda/flows/FetchDataFlow.kt | 2 +- .../net/corda/flows/FetchTransactionsFlow.kt | 2 +- .../kotlin/net/corda/flows/FinalityFlow.kt | 4 +-- .../net/corda/flows/NotaryChangeFlow.kt | 10 +++--- .../main/kotlin/net/corda/flows/NotaryFlow.kt | 4 +-- .../corda/flows/ResolveTransactionsFlow.kt | 6 ++-- .../net/corda/flows/TwoPartyDealFlow.kt | 12 +++---- .../net/corda/flows/ValidatingNotaryFlow.kt | 2 +- .../net/corda/core/node/isolated.jar | Bin 7968 -> 7889 bytes .../corda/core/contracts/TransactionTests.kt | 2 +- .../core/flows/ResolveTransactionsFlowTest.kt | 2 +- .../core/node/AttachmentClassLoaderTests.kt | 4 +-- .../corda/docs/FxTransactionBuildTutorial.kt | 16 +++++----- .../docs/WorkflowTransactionBuildTutorial.kt | 10 +++--- .../corda/contracts/universal/Arrangement.kt | 2 +- .../contracts/universal/ContractFunctions.kt | 6 ++-- .../net/corda/contracts/universal/Literal.kt | 20 ++++++------ .../corda/contracts/universal/Perceivable.kt | 8 ++--- .../corda/contracts/universal/PrettyPrint.kt | 2 +- .../contracts/universal/UniversalContract.kt | 2 +- .../net/corda/contracts/universal/Util.kt | 30 +++++++++--------- .../contracts/universal/ContractDefinition.kt | 6 ++-- .../corda/contracts/AnotherDummyContract.kt | 2 +- .../corda/core/node/DummyContractBackdoor.kt | 2 +- .../corda/contracts/JavaCommercialPaper.java | 4 +-- .../net/corda/contracts/CommercialPaper.kt | 4 +-- .../corda/contracts/CommercialPaperLegacy.kt | 2 +- .../kotlin/net/corda/contracts/asset/Cash.kt | 10 +++--- .../contracts/asset/CommodityContract.kt | 4 +-- .../net/corda/contracts/asset/Obligation.kt | 22 ++++++------- .../corda/contracts/testing/VaultFiller.kt | 2 +- .../main/kotlin/net/corda/flows/CashFlow.kt | 10 +++--- .../main/kotlin/net/corda/flows/IssuerFlow.kt | 10 +++--- .../net/corda/flows/TwoPartyTradeFlow.kt | 6 ++-- .../corda/contracts/CommercialPaperTests.kt | 16 +++++----- .../net/corda/contracts/asset/CashTests.kt | 4 +-- .../node/services/DistributedServiceTests.kt | 6 ++-- .../node/services/RaftNotaryServiceTests.kt | 2 +- .../services/messaging/MQSecurityTest.kt | 6 ++-- .../services/messaging/P2PSecurityTest.kt | 2 +- .../kotlin/net/corda/node/driver/Driver.kt | 8 ++--- .../net/corda/node/internal/AbstractNode.kt | 14 ++++---- .../identity/InMemoryIdentityService.kt | 12 +++---- .../node/services/messaging/RPCStructures.kt | 2 +- .../services/network/NetworkMapService.kt | 8 ++--- .../network/PersistentNetworkMapService.kt | 8 ++--- .../persistence/DataVendingService.kt | 8 ++--- .../statemachine/FlowStateMachineImpl.kt | 12 +++---- .../services/statemachine/SessionMessage.kt | 2 +- .../statemachine/StateMachineManager.kt | 21 ++++++------ .../InMemoryUniquenessProvider.kt | 2 +- .../services/transactions/NotaryService.kt | 2 +- .../PersistentUniquenessProvider.kt | 4 +-- .../transactions/RaftUniquenessProvider.kt | 2 +- .../RaftValidatingNotaryService.kt | 2 +- .../transactions/SimpleNotaryService.kt | 2 +- .../transactions/ValidatingNotaryService.kt | 2 +- .../node/services/vault/NodeVaultService.kt | 2 +- .../net/corda/node/utilities/JsonSupport.kt | 16 +++++----- .../utilities/ServiceIdentityGenerator.kt | 2 +- .../node/messaging/TwoPartyTradeFlowTests.kt | 6 ++-- .../node/services/MockServiceHubInternal.kt | 6 ++-- .../corda/node/services/NotaryChangeTests.kt | 4 +-- .../corda/node/services/ScheduledFlowTests.kt | 8 ++--- .../persistence/DataVendingServiceTests.kt | 2 +- .../statemachine/StateMachineManagerTests.kt | 14 ++++---- .../corda/attachmentdemo/AttachmentDemo.kt | 2 +- .../corda/bank/plugin/BankOfCordaPlugin.kt | 2 +- .../net/corda/irs/api/NodeInterestRates.kt | 6 ++-- .../main/kotlin/net/corda/irs/contract/IRS.kt | 14 ++++---- .../net/corda/irs/flows/AutoOfferFlow.kt | 4 +-- .../net/corda/irs/flows/ExitServerFlow.kt | 2 +- .../kotlin/net/corda/irs/flows/FixingFlow.kt | 4 +-- .../net/corda/irs/flows/RatesFixFlow.kt | 6 ++-- .../corda/irs/flows/UpdateBusinessDayFlow.kt | 2 +- .../kotlin/net/corda/irs/plugin/IRSPlugin.kt | 2 +- .../irs/testing/NodeInterestRatesTest.kt | 2 +- .../notarydemo/flows/DummyIssueAndMove.kt | 2 +- .../notarydemo/plugin/NotaryDemoPlugin.kt | 2 +- .../kotlin/net/corda/vega/api/PortfolioApi.kt | 14 ++++---- .../net/corda/vega/api/PortfolioApiUtils.kt | 2 +- .../net/corda/vega/api/SwapDataModel.kt | 2 +- .../kotlin/net/corda/vega/api/SwapDataView.kt | 2 +- .../net/corda/vega/contracts/IRSState.kt | 8 ++--- .../corda/vega/contracts/PortfolioState.kt | 10 +++--- .../corda/vega/contracts/RevisionedState.kt | 2 +- .../net/corda/vega/contracts/SwapData.kt | 2 +- .../net/corda/vega/flows/IRSTradeFlow.kt | 6 ++-- .../kotlin/net/corda/vega/flows/SimmFlow.kt | 18 +++++------ .../net/corda/vega/flows/StateRevisionFlow.kt | 2 +- .../net/corda/vega/portfolio/Portfolio.kt | 2 +- .../net/corda/vega/services/SimmService.kt | 4 +-- .../net/corda/traderdemo/flow/BuyerFlow.kt | 2 +- .../net/corda/traderdemo/flow/SellerFlow.kt | 6 ++-- .../traderdemo/plugin/TraderDemoPlugin.kt | 2 +- .../kotlin/net/corda/testing/CoreTestUtils.kt | 14 ++++---- .../main/kotlin/net/corda/testing/TestDSL.kt | 2 +- .../testing/TransactionDSLInterpreter.kt | 4 +-- .../corda/testing/node/MockNetworkMapCache.kt | 6 ++-- .../kotlin/net/corda/testing/node/MockNode.kt | 4 +-- .../net/corda/testing/node/MockServices.kt | 16 +++++----- .../corda/explorer/plugin/ExplorerPlugin.kt | 2 +- .../net/corda/explorer/views/Network.kt | 2 +- .../views/cordapps/cash/CashViewer.kt | 2 +- .../views/cordapps/cash/NewTransaction.kt | 2 +- .../net/corda/loadtest/tests/CrossCashTest.kt | 24 +++++++------- .../corda/loadtest/tests/GenerateHelpers.kt | 8 ++--- .../net/corda/loadtest/tests/SelfIssueTest.kt | 6 ++-- 137 files changed, 415 insertions(+), 411 deletions(-) diff --git a/client/src/main/kotlin/net/corda/client/mock/EventGenerator.kt b/client/src/main/kotlin/net/corda/client/mock/EventGenerator.kt index 487bde0c56..b554d17e65 100644 --- a/client/src/main/kotlin/net/corda/client/mock/EventGenerator.kt +++ b/client/src/main/kotlin/net/corda/client/mock/EventGenerator.kt @@ -13,10 +13,10 @@ import java.util.* * state/ref pairs, but it doesn't necessarily generate "correct" events! */ class EventGenerator( - val parties: List, - val notary: Party, + val parties: List, + val notary: Party.Full, val currencies: List = listOf(USD, GBP, CHF), - val issuers: List = parties + val issuers: List = parties ) { private var vault = listOf>() diff --git a/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt b/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt index 922d222403..beec58bdf5 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/ContractsDSL.kt @@ -65,7 +65,7 @@ inline fun requireThat(body: Requirements.() -> R) = Requirements.body() /** Filters the command list by type, party and public key all at once. */ inline fun Collection>.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 Collection /** Filters the command list by type, parties and public keys all at once. */ inline fun Collection>.select(signers: Collection?, - parties: Collection?) = + parties: Collection?) = 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) }. diff --git a/core/src/main/kotlin/net/corda/core/contracts/DummyContract.kt b/core/src/main/kotlin/net/corda/core/contracts/DummyContract.kt index ac27958ec9..5d81e4d654 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/DummyContract.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/DummyContract.kt @@ -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)) } diff --git a/core/src/main/kotlin/net/corda/core/contracts/Structures.kt b/core/src/main/kotlin/net/corda/core/contracts/Structures.kt index 3aa1298d62..d8927e5232 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/Structures.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/Structures.kt @@ -124,7 +124,7 @@ data class TransactionState @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 @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.`with notary`(newNotary: Party) = withNotary(newNotary) +infix fun T.`with notary`(newNotary: Party.Full) = withNotary(newNotary) -infix fun T.withNotary(newNotary: Party) = TransactionState(this, newNotary) +infix fun 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 + val parties: List /** * 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 Iterable>.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( val signers: List, /** If any public keys were recognised, the looked up institutions are available here */ - val signingParties: List, + val signingParties: List, val value: T ) diff --git a/core/src/main/kotlin/net/corda/core/contracts/TransactionTypes.kt b/core/src/main/kotlin/net/corda/core/contracts/TransactionTypes.kt index 3570bc35e1..207d1f5774 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/TransactionTypes.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/TransactionTypes.kt @@ -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) diff --git a/core/src/main/kotlin/net/corda/core/contracts/TransactionVerification.kt b/core/src/main/kotlin/net/corda/core/contracts/TransactionVerification.kt index 060d8c49f5..86609771ca 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/TransactionVerification.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/TransactionVerification.kt @@ -17,7 +17,7 @@ data class TransactionForContract(val inputs: List, val attachments: List, val commands: List>, 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}" } diff --git a/core/src/main/kotlin/net/corda/core/crypto/CryptoUtilities.kt b/core/src/main/kotlin/net/corda/core/crypto/CryptoUtilities.kt index 17d438b75c..d9a4597986 100644 --- a/core/src/main/kotlin/net/corda/core/crypto/CryptoUtilities.kt +++ b/core/src/main/kotlin/net/corda/core/crypto/CryptoUtilities.kt @@ -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 { @@ -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) diff --git a/core/src/main/kotlin/net/corda/core/crypto/Party.kt b/core/src/main/kotlin/net/corda/core/crypto/Party.kt index a8f0dd7378..075f801d35 100644 --- a/core/src/main/kotlin/net/corda/core/crypto/Party.kt +++ b/core/src/main/kotlin/net/corda/core/crypto/Party.kt @@ -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)) + } } \ No newline at end of file diff --git a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt index 519a1c0149..ae0425ec96 100644 --- a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt +++ b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt @@ -44,7 +44,7 @@ abstract class FlowLogic { * 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 { * * @returns an [UntrustworthyData] wrapper around the received object. */ - inline fun sendAndReceive(otherParty: Party, payload: Any) = sendAndReceive(R::class.java, otherParty, payload) + inline fun 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 { * @returns an [UntrustworthyData] wrapper around the received object. */ @Suspendable - open fun sendAndReceive(receiveType: Class, otherParty: Party, payload: Any): UntrustworthyData { + open fun sendAndReceive(receiveType: Class, otherParty: Party.Full, payload: Any): UntrustworthyData { return stateMachine.sendAndReceive(receiveType, otherParty, payload, sessionFlow) } @@ -84,7 +84,7 @@ abstract class FlowLogic { * 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 receive(otherParty: Party): UntrustworthyData = receive(R::class.java, otherParty) + inline fun receive(otherParty: Party.Full): UntrustworthyData = receive(R::class.java, otherParty) /** * Suspends until the specified [otherParty] sends us a message of type [receiveType]. @@ -96,7 +96,7 @@ abstract class FlowLogic { * @returns an [UntrustworthyData] wrapper around the received object. */ @Suspendable - open fun receive(receiveType: Class, otherParty: Party): UntrustworthyData { + open fun receive(receiveType: Class, otherParty: Party.Full): UntrustworthyData { return stateMachine.receive(receiveType, otherParty, sessionFlow) } @@ -108,7 +108,7 @@ abstract class FlowLogic { * 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 diff --git a/core/src/main/kotlin/net/corda/core/flows/FlowStateMachine.kt b/core/src/main/kotlin/net/corda/core/flows/FlowStateMachine.kt index 25aa753a9c..36bf2e9279 100644 --- a/core/src/main/kotlin/net/corda/core/flows/FlowStateMachine.kt +++ b/core/src/main/kotlin/net/corda/core/flows/FlowStateMachine.kt @@ -25,15 +25,15 @@ data class StateMachineRunId private constructor(val uuid: UUID) { interface FlowStateMachine { @Suspendable fun sendAndReceive(receiveType: Class, - otherParty: Party, + otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>): UntrustworthyData @Suspendable - fun receive(receiveType: Class, otherParty: Party, sessionFlow: FlowLogic<*>): UntrustworthyData + fun receive(receiveType: Class, otherParty: Party.Full, sessionFlow: FlowLogic<*>): UntrustworthyData @Suspendable - fun send(otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>) + fun send(otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>) val serviceHub: ServiceHub val logger: Logger diff --git a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt index 7b2818abdc..69eea24dc5 100644 --- a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt +++ b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt @@ -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? } /** diff --git a/core/src/main/kotlin/net/corda/core/node/NodeInfo.kt b/core/src/main/kotlin/net/corda/core/node/NodeInfo.kt index 468a8244b3..d841ef9eb6 100644 --- a/core/src/main/kotlin/net/corda/core/node/NodeInfo.kt +++ b/core/src/main/kotlin/net/corda/core/node/NodeInfo.kt @@ -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 = 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 = 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 = advertisedServices.filter { it.info.type.isSubTypeOf(type) }.map { it.identity } } diff --git a/core/src/main/kotlin/net/corda/core/node/PluginServiceHub.kt b/core/src/main/kotlin/net/corda/core/node/PluginServiceHub.kt index f8a2398e58..e48e331175 100644 --- a/core/src/main/kotlin/net/corda/core/node/PluginServiceHub.kt +++ b/core/src/main/kotlin/net/corda/core/node/PluginServiceHub.kt @@ -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<*>)? } diff --git a/core/src/main/kotlin/net/corda/core/node/services/IdentityService.kt b/core/src/main/kotlin/net/corda/core/node/services/IdentityService.kt index e3a17ba222..3ab2ee26c1 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/IdentityService.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/IdentityService.kt @@ -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 + fun getAllIdentities(): Iterable // 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? } diff --git a/core/src/main/kotlin/net/corda/core/node/services/NetworkMapCache.kt b/core/src/main/kotlin/net/corda/core/node/services/NetworkMapCache.kt index 86c6fdbae3..92d1643e87 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/NetworkMapCache.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/NetworkMapCache.kt @@ -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 diff --git a/core/src/main/kotlin/net/corda/core/node/services/PartyInfo.kt b/core/src/main/kotlin/net/corda/core/node/services/PartyInfo.kt index b34086992a..b778fe898d 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/PartyInfo.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/PartyInfo.kt @@ -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 } diff --git a/core/src/main/kotlin/net/corda/core/node/services/Services.kt b/core/src/main/kotlin/net/corda/core/node/services/Services.kt index 997331c1fd..4b60dea7da 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/Services.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/Services.kt @@ -186,11 +186,11 @@ interface VaultService { fun generateSpend(tx: TransactionBuilder, amount: Amount, to: CompositeKey, - onlyFromParties: Set? = null): Pair> + onlyFromParties: Set? = null): Pair> } inline fun VaultService.linearHeadsOfType() = linearHeadsOfType_(T::class.java) -inline fun VaultService.dealsWith(party: Party) = linearHeadsOfType().values.filter { +inline fun VaultService.dealsWith(party: Party.Full) = linearHeadsOfType().values.filter { // TODO: Replace name comparison with full party comparison (keys are currenty not equal) it.state.data.parties.any { it.name == party.name } } diff --git a/core/src/main/kotlin/net/corda/core/node/services/UniquenessProvider.kt b/core/src/main/kotlin/net/corda/core/node/services/UniquenessProvider.kt index 516f9d7e88..cab2fe8f59 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/UniquenessProvider.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/UniquenessProvider.kt @@ -12,7 +12,7 @@ import net.corda.core.crypto.SecureHash */ interface UniquenessProvider { /** Commits all input states of the given transaction */ - fun commit(states: List, txId: SecureHash, callerIdentity: Party) + fun commit(states: List, txId: SecureHash, callerIdentity: Party.Full) /** Specifies the consuming transaction for every conflicting state */ data class Conflict(val stateHistory: Map) @@ -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() diff --git a/core/src/main/kotlin/net/corda/core/serialization/Kryo.kt b/core/src/main/kotlin/net/corda/core/serialization/Kryo.kt index d02e0b35bc..e03faf97ab 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/Kryo.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/Kryo.kt @@ -302,7 +302,7 @@ object WireTransactionSerializer : Serializer() { kryo.useClassLoader(classLoader) { val outputs = kryo.readClassAndObject(input) as List> val commands = kryo.readClassAndObject(input) as List - val notary = kryo.readClassAndObject(input) as Party? + val notary = kryo.readClassAndObject(input) as Party.Full? val signers = kryo.readClassAndObject(input) as List 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()) // 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) diff --git a/core/src/main/kotlin/net/corda/core/testing/Generators.kt b/core/src/main/kotlin/net/corda/core/testing/Generators.kt index 5247506ee1..280fcfa880 100644 --- a/core/src/main/kotlin/net/corda/core/testing/Generators.kt +++ b/core/src/main/kotlin/net/corda/core/testing/Generators.kt @@ -45,9 +45,9 @@ class CompositeKeyGenerator : Generator(CompositeKey::class.java) } } -class PartyGenerator : Generator(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::class.java) { + override fun generate(random: SourceOfRandomness, status: GenerationStatus): Party.Full { + return Party.Full(StringGenerator().generate(random, status), CompositeKeyGenerator().generate(random, status)) } } diff --git a/core/src/main/kotlin/net/corda/core/transactions/BaseTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/BaseTransaction.kt index bd90a0455a..3b50175f18 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/BaseTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/BaseTransaction.kt @@ -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 diff --git a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt index 26c44f711f..64588b7151 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/LedgerTransaction.kt @@ -26,7 +26,7 @@ class LedgerTransaction( val attachments: List, /** The hash of the original serialised WireTransaction. */ override val id: SecureHash, - notary: Party?, + notary: Party.Full?, signers: List, timestamp: Timestamp?, type: TransactionType diff --git a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt index 0adfb19ef1..566f342048 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt @@ -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 = arrayListOf(), protected val attachments: MutableList = arrayListOf(), protected val outputs: MutableList> = 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 { diff --git a/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt b/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt index eb67965b46..6ea5cb8156 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/WireTransaction.kt @@ -29,7 +29,7 @@ class WireTransaction( outputs: List>, /** Ordered list of ([CommandData], [PublicKey]) pairs that instruct the contracts what to do. */ val commands: List, - notary: Party?, + notary: Party.Full?, signers: List, type: TransactionType, timestamp: Timestamp? diff --git a/core/src/main/kotlin/net/corda/core/utilities/ApiUtils.kt b/core/src/main/kotlin/net/corda/core/utilities/ApiUtils.kt index 77d6e23004..b7a81974b4 100644 --- a/core/src/main/kotlin/net/corda/core/utilities/ApiUtils.kt +++ b/core/src/main/kotlin/net/corda/core/utilities/ApiUtils.kt @@ -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)) diff --git a/core/src/main/kotlin/net/corda/core/utilities/TestConstants.kt b/core/src/main/kotlin/net/corda/core/utilities/TestConstants.kt index ae281e0554..90d85b7595 100644 --- a/core/src/main/kotlin/net/corda/core/utilities/TestConstants.kt +++ b/core/src/main/kotlin/net/corda/core/utilities/TestConstants.kt @@ -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) diff --git a/core/src/main/kotlin/net/corda/flows/AbstractStateReplacementFlow.kt b/core/src/main/kotlin/net/corda/flows/AbstractStateReplacementFlow.kt index a05f15dd1f..aa5f49cdfb 100644 --- a/core/src/main/kotlin/net/corda/flows/AbstractStateReplacementFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/AbstractStateReplacementFlow.kt @@ -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(party, proposal) return response.unwrap { @@ -105,7 +105,7 @@ abstract class AbstractStateReplacementFlow { } } - abstract class Acceptor(val otherSide: Party, + abstract class Acceptor(val otherSide: Party.Full, override val progressTracker: ProgressTracker = tracker()) : FlowLogic() { companion object { object VERIFYING : ProgressTracker.Step("Verifying state replacement proposal") diff --git a/core/src/main/kotlin/net/corda/flows/BroadcastTransactionFlow.kt b/core/src/main/kotlin/net/corda/flows/BroadcastTransactionFlow.kt index 952bb80afb..6a54a26aa3 100644 --- a/core/src/main/kotlin/net/corda/flows/BroadcastTransactionFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/BroadcastTransactionFlow.kt @@ -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) : FlowLogic() { + val participants: Set) : FlowLogic() { data class NotifyTxRequest(val tx: SignedTransaction) diff --git a/core/src/main/kotlin/net/corda/flows/FetchAttachmentsFlow.kt b/core/src/main/kotlin/net/corda/flows/FetchAttachmentsFlow.kt index e562a0a94e..2e08cc9485 100644 --- a/core/src/main/kotlin/net/corda/flows/FetchAttachmentsFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/FetchAttachmentsFlow.kt @@ -12,7 +12,7 @@ import java.io.InputStream * attachments are saved to local storage automatically. */ class FetchAttachmentsFlow(requests: Set, - otherSide: Party) : FetchDataFlow(requests, otherSide) { + otherSide: Party.Full) : FetchDataFlow(requests, otherSide) { override fun load(txid: SecureHash): Attachment? = serviceHub.storageService.attachments.openAttachment(txid) diff --git a/core/src/main/kotlin/net/corda/flows/FetchDataFlow.kt b/core/src/main/kotlin/net/corda/flows/FetchDataFlow.kt index 0be2b1a081..f06d39907b 100644 --- a/core/src/main/kotlin/net/corda/flows/FetchDataFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/FetchDataFlow.kt @@ -29,7 +29,7 @@ import java.util.* */ abstract class FetchDataFlow( protected val requests: Set, - protected val otherSide: Party) : FlowLogic>() { + protected val otherSide: Party.Full) : FlowLogic>() { class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : IllegalArgumentException() class DownloadedVsRequestedSizeMismatch(val requested: Int, val got: Int) : IllegalArgumentException() diff --git a/core/src/main/kotlin/net/corda/flows/FetchTransactionsFlow.kt b/core/src/main/kotlin/net/corda/flows/FetchTransactionsFlow.kt index a8a1913ea0..c85f8534e9 100644 --- a/core/src/main/kotlin/net/corda/flows/FetchTransactionsFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/FetchTransactionsFlow.kt @@ -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, otherSide: Party) : +class FetchTransactionsFlow(requests: Set, otherSide: Party.Full) : FetchDataFlow(requests, otherSide) { override fun load(txid: SecureHash): SignedTransaction? = serviceHub.storageService.validatedTransactions.getTransaction(txid) diff --git a/core/src/main/kotlin/net/corda/flows/FinalityFlow.kt b/core/src/main/kotlin/net/corda/flows/FinalityFlow.kt index 5dac3167b5..acafac7ee2 100644 --- a/core/src/main/kotlin/net/corda/flows/FinalityFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/FinalityFlow.kt @@ -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, + val participants: Set, override val progressTracker: ProgressTracker) : FlowLogic() { - constructor(transaction: SignedTransaction, participants: Set) : this(transaction, participants, tracker()) + constructor(transaction: SignedTransaction, participants: Set) : this(transaction, participants, tracker()) companion object { object NOTARISING : ProgressTracker.Step("Requesting signature by notary service") diff --git a/core/src/main/kotlin/net/corda/flows/NotaryChangeFlow.kt b/core/src/main/kotlin/net/corda/flows/NotaryChangeFlow.kt index f6cbd6f175..67453017c9 100644 --- a/core/src/main/kotlin/net/corda/flows/NotaryChangeFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/NotaryChangeFlow.kt @@ -22,8 +22,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() { class Instigator( originalState: StateAndRef, - newNotary: Party, - progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator(originalState, newNotary, progressTracker) { + newNotary: Party.Full, + progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator(originalState, newNotary, progressTracker) { override fun assembleTx(): Pair> { val state = originalState.state @@ -88,8 +88,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() { } - class Acceptor(otherSide: Party, - override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor(otherSide) { + class Acceptor(otherSide: Party.Full, + override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor(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): Unit { + override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal): Unit { val state = proposal.stateRef val proposedTx = proposal.stx.tx diff --git a/core/src/main/kotlin/net/corda/flows/NotaryFlow.kt b/core/src/main/kotlin/net/corda/flows/NotaryFlow.kt index af6df1cf54..ac8226eb39 100644 --- a/core/src/main/kotlin/net/corda/flows/NotaryFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/NotaryFlow.kt @@ -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() { diff --git a/core/src/main/kotlin/net/corda/flows/ResolveTransactionsFlow.kt b/core/src/main/kotlin/net/corda/flows/ResolveTransactionsFlow.kt index 07f573ab67..9196e72cdf 100644 --- a/core/src/main/kotlin/net/corda/flows/ResolveTransactionsFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/ResolveTransactionsFlow.kt @@ -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, - private val otherSide: Party) : FlowLogic>() { + private val otherSide: Party.Full) : FlowLogic>() { companion object { private fun dependencyIDs(wtx: WireTransaction) = wtx.inputs.map { it.txhash }.toSet() @@ -77,14 +77,14 @@ class ResolveTransactionsFlow(private val txHashes: Set, /** * 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 } diff --git a/core/src/main/kotlin/net/corda/flows/TwoPartyDealFlow.kt b/core/src/main/kotlin/net/corda/flows/TwoPartyDealFlow.kt index f8ae8c5905..7f8db16808 100644 --- a/core/src/main/kotlin/net/corda/flows/TwoPartyDealFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/TwoPartyDealFlow.kt @@ -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() { override fun validateHandshake(handshake: Handshake): Handshake { diff --git a/core/src/main/kotlin/net/corda/flows/ValidatingNotaryFlow.kt b/core/src/main/kotlin/net/corda/flows/ValidatingNotaryFlow.kt index 41897c40b7..65159106c4 100644 --- a/core/src/main/kotlin/net/corda/flows/ValidatingNotaryFlow.kt +++ b/core/src/main/kotlin/net/corda/flows/ValidatingNotaryFlow.kt @@ -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) { diff --git a/core/src/main/resources/net/corda/core/node/isolated.jar b/core/src/main/resources/net/corda/core/node/isolated.jar index 1b898104509733aba0b3967813598182d35b8fc2..236f20a8537d8ada2d673f18e38ffffcc3aad073 100644 GIT binary patch delta 3899 zcmV-B55(}GKG8j}8wY>iQxjJd{_Z9un-Cz0hzeMvpoV}3uvQeb@b=Y2_4p8r)K{+)iq?sViK~C5L|vlP{^(SgBB08+C^} zXE=@d!5G5J%Bqso6(gUVUR+kQ+z$`KnOaCot--B8xCnI&a%GU=!sLOe3^H^~npQr! ztnx)m(F{AO804pL%_MuuC%tIjPw~Ol-yE zx@Hi(u2bfm1smP5Cy3b*hJacq@--0>!ZEZ2aTKkzoCPJXWv5DoMb%2 ziFc(!Xvc9OEXLp)(hQAXBZcu)*Q_%>8^S4c2I0kN%Km?W1q+5}8QN&(;i>7n<2N!3 zWB1bOxrIBK>06oM^g?PZgf5YaI1)5LJe8VsH7~CglA6I)%TV;>nEFsD>7qPrZk4j! zw9<;TqFRGxf*m52=Y-WGtRzD)YZi*8p&Go8%PP8V$G+6~Qp}YU zQ>=WcKr3d)XtG!pC#D%OQSmWO4l3`7JuDec{auNP6_GK(a5!G0Xog#wk#|#bC5TI) z{nn2QA~jd(IN@g5gQ2-n^tEveM|Ss(lr%l3T7G{F2QeZlG3rQ<*Od5G8DmtzO0lRK zIfirl5!%z`;u5`^xFw*+8QMja{Fmcx;W$BCs!K*Xgb#6DbWD@5CB*Dye?J5UG@TTIEVk;R?x?3acJE^6AW$799&T$qKb{RKqW~9-RqFM=q_FpPARHF0@!ubNZXXIq z$R^jS6LqspbGVLd-~H`xy%Z$Vbgf?5AC@zbDw5k72nRE*;rdoN>Wxah4ZWd(SvSf@ zqmALF?Vo&6p`f23{^oPJQqUwkRDA7t?A(77Y^@c!Ns+Y8ZH=oF>KX+$R5r{)fo>Xx zz5{P6KNcD493oVR`+1ySq21q>DH&WVs3~Jrv$aKC9p1Uq=)fsgL3GljZ8ob|nnE6T z#eI6cCbSdj>`GcGy0F0+vt(t}o0@2ZQigw_ zTBEvR+bR(}=F*?tLmqv!OTCl;AHAdE)+75N)uNBy0eVNpg+cEIYSSf3UU_OIMXl1i zF7Y#>>tsk+qGzbwi9=|nx8}kCO|_8WVFD7K0x0GJ$%zd#ZXvwxY=fQ1MtUAb3p|eZ zdDq+f0&Tlz_3oK9f@Q~N1J-CXw(Awf0p3eta^;Idu~ zD(eeW^#xpgwb@SLeOz>*23&0?&i#RgSGY76y}XH`U&~5mL1?IL1J}wE2!Vb`jT7{E zErU!P!mgS)jS1rIuP`#ViP7kd4WtCn1}39ZWN+ZkI?9LZN7Xfm>|O&goWYDcJWinE zK#nK6f555k-yl7~@$M~1Y2kn0L;vsK_x=d4hw|fn>Umn_+X(O9h!NrI>@P_4Nri%w zI2DGIaylE4MUKAPOllXXeV5k!-aI@h%$9%nxYD{$Kg@})2lHSy=JClq4%uk7@u`h= z8=u+eu;I5M+X&jIxAC5h6E+r{q0em`w$Vac+(y3*y{Ba+(YzGjYxUMQx?^etGuEC!c)qL0t+i zSt_e9y8KZt_e?H?J8`XK_L)8V?8~?JK4<^)?{9wq=*3qIJsLOVm~O-sdTOSj#7rTp zLQg3skIMs^ZYH^Lb3UD38p?f^z!-e9%7P-N6n`xtkI&3&Vnv+CGnYYlHjroV_2vD75UD=&OF;z1Ss3}t3g6$}@`C8vVi z?kO1(hT0TQD5*SSfq4aE{^X zK{7bGl;MHfHdv`Z&Ql3(3}?3EwH*T6UWW(mIM2|$N0+A4iWZm9#V}BMu(|CbFn?rl zJM3--XKU7YuLnK2Kozo|@tcaNNVvq%e(*AoaD~B5b!mUus|<@k@!}f#Jh+Pf9U$2% zE#U@(mn@7gYSh7ZI9WNns}%|*qYKsKBu92$#cLkCf&qrnJ&L<1{{DmL&Eh)bfsC6B z6^p8w44FJlC&{hW>FuXb$!*|85P!F=k{PCk5LO*CTr2&I%C-Pue7=;vW;m2q5^8L0 zK0U(?1{T`=bSlaz<%o{y48@f<;1v z;eke0nq&42(mcayCCp}1Z`O3J)Ba@AHmjJrY>Qn5V_kWSx^}{-%XYzydw&cytvg>A zXYhsxleo`tn5uBJ7#nJ_kQZ-a+B#1jFdR5!D&d1kN_gZ!nbp3#G|I;5E@6g>(JE9$ zBh+?E`_?Uif;81!9J~TCJf=(}O*13P znc>Dx0PpW(WO#tKlY=RwJ%5-3MRp{dtCdl1DsiiAX^KcMIBB$^3CS^IuRygsM{n^S zhQHUBgC0k{W8?46Q>RVWmkY$_&cEe_Y_4O2>#Sd2?sarC`aAj@b@hYgFTZs;e9n<( zpS#h~UD50Ed59h&>Lpr9^f1w?;o1?O&zIvIA?mj|M`=|}oEoCF!+*6C)xI)XmEV8) zbs6ckylE_RyL{5i?_3R5JiXRnwQu4 zn)(>}{{MX@VVP#W9UFJfWH>f4ubFC^MwkUvs52=(urXlLbw5PmGWf%KOi4{ChN_Un zr1hZbC#-5b+r~LgV1KKw!jQR1X(a_2n;TU!xow_^K5xW$P_nj*s#jVH+LK~i3B(1gR#t7~ZT%^AcXAmb5w!I2s6k|3DL9}3;JhD8t zfb*i6cDHQu+JC~L%9(pXA(Xp#J%`ByJ1;;}hkt^C=!pJ>$~8Ai8cbjjPo~i*P$RG;@UB3wK%GFnK!dRO#|7RKI4KYo7!`P5phaL@;I6=k zz(auwo9Pv(6?iJ}OyGn608mQ@2(=d*gIfjw00$3~kQN-XPZT@@e_KxzK@|RGTehVX zS-cidK|msETd@U8GBd^W4gZb5!3RTp^hX)b_7b#sBbnWA z&UMar&iVHJ^A`YB+-F!{< zT(!fOts@b+0&)y9e{G?J;ZD?*bdo0wA0ITv5=X;yHhjg6>usudPaFy(R3vKk3(lr@ z?DW8Mb-SA+we@iqN~SF3lUmvE^|`Rsl}Rj2jbWvsO*=diu4T9+C$5xsd=Svou9>A} z$h-H_GCUg3|K~-5xw9YpNr6)OB9@+)3)xUw5bV!Py zGPtwThb6D#mAv5Wv_vPn{{%sCBzZ+|s4X5=&Q7b|2HRZ}4f0-gI@2q|Ox| zlAlN`TZz~_UnqvvaVt%Zr@{&Ii(6@5cTFU=WkREv8^*l3kk2Pl$YG z0A{g(+XuK}F==tf(hA|OMag2yqTJVzX~rV3xN33DV(|x1O9u#Yj$r6C0ssJ81d|aS z9<%2e>H-SW_-|hB1pokJ43pa&Y8$l|8-rU0000LM001`t2><{900000000007n5Ke zZ35&IlVKe*lL8()0YQ^K9z_C;7L(8(7L%JE84YrdVCXag003JA001wOb{-{@<{mT# Jd>H@$001S=YMKB5 delta 3982 zcmV;94{`9(J)l0Y8wY<~QxjJhe$FP4O$-nsegSF})PNrWtrZ2Wh+h!`HYgQsOP6E~ z3!B}z=LF@Z8PKo$0g}Uf@gxM`v0}XL`|})ai8kp50A=!1y_n?7rum_dMr) z-mkNN|M%)Q04MQ?;f$q=RL*wt8a*xHXgR@C2DeR3==s#3Ws83q-ML&Y78i#6<<4S+Hdz;eF&@o~=h19Gr zrX9_&cuKQKPZNes@~ACF%ce~LdS+)FV`*mUvVLDHn=(DPaLPGh zI~mQH)17|Lzz!M8<5D^%rIg3@ij^axj%MX_h8-3Ex|NV7-~w%D=zLRdQetY;rVQAr zcdM69-_U<_v1IZPK4CbYe0w^2S+SLUQS{=|2u|Y+!#e{pL~?eqWLvr=dMTJWyR^VC zKr#J@jEzc^&b&vD;k)DqV^N4}TT=hWSaxI$?Y70srIPK?p0SedxM95VD5saC5W;5+ zW8-C7NaQrrx_ZunK-+4n=Sgl;ZsukcoMfnyIio4ThEtDe3QH*i}1ssce{e-3j4F1jDip z<1Y2&x&lA1B1847l}fsmXE?rh%X@&Ez$Xsf7A2Lvy9bGrG|7n$U>0Qk)Oag-17*GVMyBL*{6d zryPE@^7wE>*{!($mB$e!rbZOi8!BoYjT04FU45eNUU_^{>0y_e;;O2|lvbrDu=-=Y z5)0l4$6|7H{m&eB$H}YiKbb$C02h&a{Zmv?}M~SrQ=$IYAB{=o2y9vWH=Vd zw#K%#s_|f4>1pVR_D%S^>S?tx*0lOdeOxj)$t0U-X+y{F+*HrbLP^+E%v8JF5c;sb zKz?bcRKZk{8WcnCdsj*bvkY}^&QNx3rEy}8O1dpuwuDjC)7HGf4QhLXYpsyFh!=m_ z_=rulGod+#Y>c<$gKo1C!_vJ(^k>53M#0iV*&(@a)6F*UF3c}T?qqasE~Axv*vPnD zc5?bvLk^;8%hH`8Q{!AG1NZpmPi!)tdZ0Q_TE8>eJC@9f0>P>%QJ6h=dz=r{v)hqnn z|M*{Mc#Vsb@k`6N^1J6URT_UZ(6)qY-T~56At;T*^w^LJOtxsBO_J86;q9+6Jh_aK z_~;U{5@-px<6n@xgvmwUnRlx`Xs-2vT)u}d{pITfD%*9k`{++Nc=Qh_PqFvt3Y3i0 zKSuu_5DNZ`V1NQ0d=_|CwYL$$e~}=AFS382(B~$~Zm5cwcXNk2C+1mT(l_lx8W(B& z75V(@dkCa4<^AwYWu(y$({d_z4~!!Z{T{Y+v~Zl|Xy>@k(ZLboP&pzT+c@@d?B^)B zOEVlhICgTJqbJMr)C;T+!V4Z^t58~gxsg;W{Mj(vzg4|K>o7? z#^9S#<`p@ue`ra0YyEMlgeKKwO_(%FwdKOw$uw-n2%)5}!@zx*PAYP6fH$b!bW$s?$8Fqzj61{+JtFi*trk z+rW&)Ia8OTJf1c9kRnnvyDrJi$SwfEP|N-hUeutr3=W)Ns7P{+8x&wzQ%zMN2A}Sc zWMbT0f9%r|#T9$QyDVp0_HJ{=T&H9cKmA!Xo!|yVSE?_NLvA!t-C1Q~EV|LmaOKds z2}Y^LxP;RLbX}$BUZG5f!dB|f;H(EhoMX6pkmOA)&hg-Fo2PUz@2P|qhQM~JHbrkQ z)#gDf&Xe&Ty_v}d#yy6rf6&gS!Wq2b!36Fz9Hjyr*+>iZRM?9*F=g!? z4;T&{GF9)vEG0bhpv3CeZJWi`O)uC0RibkyMl<}=of<lQ=`zEOoe19F$LLTWO(zG_$apXde~Ro_ zBws5d+*A@)$I@jXGw-Au6kUWI)Ak5dwzKq>=wkSLZE4WssCBIW-395i<=RqF_}qoJ zf|0FttZSXMYfIgZPDX!6kE5oxzx3s|E{D%K9Pqj89i3&}E}w_w5t3e#lmlrzjQHCye3_bt<0F$spSGye>ch;mMV?3*w zYKCqq^Qus%)4Xr}9!W?00ENrokLYnFJ*gO~LKYL&gDyD{RpYrf&TE2Of3b>p$xWc; z6l8pMM48J^^F;Nm5$A)d_2La{bR`%_D?)Ixt;<7BZgY-~U+FUC2DCPZwn1~GzBn}tC%V~jkqJhq7QB0#g7H+gMwe^KGgzn~b(UA&&> zNA{zCaGCSv}{6~z8rLvR^yeNW$=8|ZH+y466gKHNlq5TE77_awZ% zH5GInqo=iOKb&?nm8~mKT7N>)uP#GhL;M#stY-kCt zEctU!s(^bh;wTzDSJG+6zDV1fjfJ0>u<1j?8toYPoRtpPO;U;$be(H7qoU>@6@$f!&h=<7WLmj1XkJu zWkVsoSKP9IS%x|q4KuhhxB;{~y#bOKpcFhKU?<~8MOvjr>Q2T*Jjwkxa0_#Z7HFz1 zoKz>{2Cb8WO_#3GdZyvHS;QQogP2DwATI6i9Jp>V)szs+`+qy%zc|au+YOS`QNR3t zEDNJTWE*^la6brC|2plb15052D3(@4xY|QuL^tHSXS+mTd(nzRV-dGp|KV0VR`W zZN&Gey^i^AbV4B0f}67gx8_n653DAtwGI#i>u|dRR}3r}*f6+4aK}K=K*>OPszFo5 zfNS8Yfolft{sK@-2MC#h=ch6P002=0lVBPivzQs`0tz1d@v=b%004gtlZ+f{8;SMF z0a*qB0PYR|05<>$00000000000001LlMx+l0yPwqfE{iDl9TTpMU#IX7?VsM8625{ o=ch6P002=0001ul2><{90000000000FBg-69!dtw82|tP07}}DjQ{`u diff --git a/core/src/test/kotlin/net/corda/core/contracts/TransactionTests.kt b/core/src/test/kotlin/net/corda/core/contracts/TransactionTests.kt index 91edea17d5..be820733dd 100644 --- a/core/src/test/kotlin/net/corda/core/contracts/TransactionTests.kt +++ b/core/src/test/kotlin/net/corda/core/contracts/TransactionTests.kt @@ -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))) diff --git a/core/src/test/kotlin/net/corda/core/flows/ResolveTransactionsFlowTest.kt b/core/src/test/kotlin/net/corda/core/flows/ResolveTransactionsFlowTest.kt index a2c6aeadbb..125717bdc9 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ResolveTransactionsFlowTest.kt +++ b/core/src/test/kotlin/net/corda/core/flows/ResolveTransactionsFlowTest.kt @@ -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() { diff --git a/core/src/test/kotlin/net/corda/core/node/AttachmentClassLoaderTests.kt b/core/src/test/kotlin/net/corda/core/node/AttachmentClassLoaderTests.kt index 38f6f54a82..98fbd215a6 100644 --- a/core/src/test/kotlin/net/corda/core/node/AttachmentClassLoaderTests.kt +++ b/core/src/test/kotlin/net/corda/core/node/AttachmentClassLoaderTests.kt @@ -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)) } diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/FxTransactionBuildTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/FxTransactionBuildTutorial.kt index a75ff24521..1c8dbe2ec3 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/FxTransactionBuildTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/FxTransactionBuildTutorial.kt @@ -27,9 +27,9 @@ object FxTransactionDemoTutorial { private data class FxRequest(val tradeId: String, val amount: Amount>, - 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>, val outputs: List) @@ -39,7 +39,7 @@ private data class FxResponse(val inputs: List>, // Which is brought here to make the filtering logic more visible in the example private fun gatherOurInputs(serviceHub: ServiceHub, amountRequired: Amount>, - notary: Party?): Pair>, Long> { + notary: Party.Full?): Pair>, Long> { // Collect cash type inputs val cashStates = serviceHub.vaultService.currentVault.statesOfType() // 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>() // 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>, val quoteCurrencyAmount: Amount>, - val baseCurrencyBuyer: Party, - val baseCurrencySeller: Party) : FlowLogic() { + val baseCurrencyBuyer: Party.Full, + val baseCurrencySeller: Party.Full) : FlowLogic() { @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() { +class ForeignExchangeRemoteFlow(val source: Party.Full) : FlowLogic() { @Suspendable override fun call() { // Initial receive from remote party diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/WorkflowTransactionBuildTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/WorkflowTransactionBuildTutorial.kt index dae7c1efe8..85e2272cf1 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/WorkflowTransactionBuildTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/WorkflowTransactionBuildTutorial.kt @@ -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 get() = listOf(source, counterparty) + val parties: List get() = listOf(source, counterparty) override val participants: List get() = parties.map { it.owningKey } override fun isRelevant(ourKeys: Set): 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>() { + val counterparty: Party.Full) : FlowLogic>() { @Suspendable override fun call(): StateAndRef { // 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() { +class RecordCompletionFlow(val source: Party.Full) : FlowLogic() { @Suspendable override fun call(): Unit { // DOCSTART 3 diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/Arrangement.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/Arrangement.kt index 0b4713da58..8206d4cbe4 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/Arrangement.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/Arrangement.kt @@ -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, val currency: Currency, val from: Party, val to: Party) : Arrangement +data class Obligation(val amount: Perceivable, 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. diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/ContractFunctions.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/ContractFunctions.kt index 63b816c111..7271288fd6 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/ContractFunctions.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/ContractFunctions.kt @@ -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)) diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/Literal.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/Literal.kt index 7b8b0ccea7..ca55095eba 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/Literal.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/Literal.kt @@ -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.may(init: ActionBuilder.() -> Action): Action { + infix fun Set.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.or(party: Party) = this.plus(party) + infix fun Party.Full.or(party: Party.Full) = setOf(this, party) + infix fun Set.or(party: Party.Full) = this.plus(party) fun String.givenThat(condition: Perceivable, 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, currency: Currency): Obligation { + fun Party.Full.owes(beneficiary: Party.Full, amount: Perceivable, 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, - @Suppress("UNUSED_PARAMETER") actors: Set, @Suppress("UNUSED_PARAMETER") arrangement: Arrangement) { + @Suppress("UNUSED_PARAMETER") actors: Set, @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.may(init: ActionBuilder.() -> Action) { + fun Set.may(init: ActionBuilder.() -> Action) { } val start = StartDate() @@ -152,7 +152,7 @@ interface GivenThatResolve { fun resolve(contract: Arrangement) } -class ActionBuilder(val actors: Set) { +class ActionBuilder(val actors: Set) { internal val actions = mutableListOf() fun String.givenThat(condition: Perceivable, init: ContractBuilder.() -> Arrangement): Action { diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/Perceivable.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/Perceivable.kt index a36bda41bb..12b9ad0520 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/Perceivable.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/Perceivable.kt @@ -75,10 +75,10 @@ class EndDate : Perceivable { } } -data class ActorPerceivable(val actor: Party) : Perceivable -fun signedBy(actor: Party) : Perceivable = ActorPerceivable(actor) +data class ActorPerceivable(val actor: Party.Full) : Perceivable +fun signedBy(actor: Party.Full) : Perceivable = ActorPerceivable(actor) -fun signedByOneOf(actors: Collection): Perceivable = +fun signedByOneOf(actors: Collection): Perceivable = if (actors.size == 0) const(true) else @@ -149,7 +149,7 @@ operator fun Perceivable.div(n: Double) = PerceivableOperation(this, operator fun Perceivable.plus(n: Int) = PerceivableOperation(this, Operation.PLUS, const(n)) operator fun Perceivable.minus(n: Int) = PerceivableOperation(this, Operation.MINUS, const(n)) -data class TerminalEvent(val reference: Party, val source: CompositeKey) : Perceivable +data class TerminalEvent(val reference: Party.Full, val source: CompositeKey) : Perceivable // todo: holidays data class Interest(val amount: Perceivable, val dayCountConvention: String, diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/PrettyPrint.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/PrettyPrint.kt index 65860c85c1..a42689ecef 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/PrettyPrint.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/PrettyPrint.kt @@ -44,7 +44,7 @@ private class PrettyPrint(arr : Arrangement) { val partyMap = mutableMapOf() val usedPartyNames = mutableSetOf() - fun createPartyName(party : Party) : String + fun createPartyName(party : Party.Full) : String { val parts = party.name.toLowerCase().split(' ') diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/UniversalContract.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/UniversalContract.kt index c0ff6828c3..b5f0a03b4d 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/UniversalContract.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/UniversalContract.kt @@ -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 diff --git a/experimental/src/main/kotlin/net/corda/contracts/universal/Util.kt b/experimental/src/main/kotlin/net/corda/contracts/universal/Util.kt index f64b9ac829..be14315f54 100644 --- a/experimental/src/main/kotlin/net/corda/contracts/universal/Util.kt +++ b/experimental/src/main/kotlin/net/corda/contracts/universal/Util.kt @@ -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) : ImmutableSet = +private fun signingParties(perceivable: Perceivable) : ImmutableSet = 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() + is TimePerceivable -> ImmutableSet.of() is TerminalEvent -> ImmutableSet.of( perceivable.reference ) - is PerceivableComparison<*> -> ImmutableSet.of() // todo + is PerceivableComparison<*> -> ImmutableSet.of() // todo else -> throw IllegalArgumentException("signingParties " + perceivable) } @@ -47,26 +47,26 @@ private fun liablePartiesVisitor(action: Action): ImmutableSet { /** Returns list of potentially liable parties for a given contract */ fun liableParties(contract: Arrangement): Set = liablePartiesVisitor(contract) -private fun involvedPartiesVisitor(action: Action): Set = +private fun involvedPartiesVisitor(action: Action): Set = Sets.union(involvedPartiesVisitor(action.arrangement), signingParties(action.condition)).immutableCopy() -private fun involvedPartiesVisitor(arrangement: Arrangement): ImmutableSet = +private fun involvedPartiesVisitor(arrangement: Arrangement): ImmutableSet = when (arrangement) { - is Zero -> ImmutableSet.of() + is Zero -> ImmutableSet.of() is Obligation -> ImmutableSet.of(arrangement.from, arrangement.to) is RollOut -> involvedPartiesVisitor(arrangement.template) - is Continuation -> ImmutableSet.of() + is Continuation -> ImmutableSet.of() is And -> - arrangement.arrangements.fold(ImmutableSet.builder(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build() + arrangement.arrangements.fold(ImmutableSet.builder(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build() is Actions -> - arrangement.actions.fold(ImmutableSet.builder(), { builder, k -> builder.addAll(involvedPartiesVisitor(k)) }).build() + arrangement.actions.fold(ImmutableSet.builder(), { 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 = involvedPartiesVisitor(arrangement) +fun involvedParties(arrangement: Arrangement): Set = involvedPartiesVisitor(arrangement) -fun replaceParty(perceivable: Perceivable, from: Party, to: Party): Perceivable = +fun replaceParty(perceivable: Perceivable, from: Party.Full, to: Party.Full): Perceivable = when (perceivable) { is ActorPerceivable -> if (perceivable.actor == from) @@ -79,14 +79,14 @@ fun replaceParty(perceivable: Perceivable, 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 debugCompare(perLeft: Perceivable, perRight: Perceivable) { 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, parRight: Set) { +fun debugCompare(parLeft: Set, parRight: Set) { if (parLeft == parRight) return assert(parLeft == parRight) diff --git a/experimental/src/test/kotlin/net/corda/contracts/universal/ContractDefinition.kt b/experimental/src/test/kotlin/net/corda/contracts/universal/ContractDefinition.kt index 4c733af6da..67381d1cab 100644 --- a/experimental/src/test/kotlin/net/corda/contracts/universal/ContractDefinition.kt +++ b/experimental/src/test/kotlin/net/corda/contracts/universal/ContractDefinition.kt @@ -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) diff --git a/finance/isolated/src/main/kotlin/net/corda/contracts/AnotherDummyContract.kt b/finance/isolated/src/main/kotlin/net/corda/contracts/AnotherDummyContract.kt index 113a13ea9e..3044d94e9e 100644 --- a/finance/isolated/src/main/kotlin/net/corda/contracts/AnotherDummyContract.kt +++ b/finance/isolated/src/main/kotlin/net/corda/contracts/AnotherDummyContract.kt @@ -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)) } diff --git a/finance/isolated/src/main/kotlin/net/corda/core/node/DummyContractBackdoor.kt b/finance/isolated/src/main/kotlin/net/corda/core/node/DummyContractBackdoor.kt index f5a33c5d32..e064cfa8e9 100644 --- a/finance/isolated/src/main/kotlin/net/corda/core/node/DummyContractBackdoor.kt +++ b/finance/isolated/src/main/kotlin/net/corda/core/node/DummyContractBackdoor.kt @@ -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 } diff --git a/finance/src/main/java/net/corda/contracts/JavaCommercialPaper.java b/finance/src/main/java/net/corda/contracts/JavaCommercialPaper.java index 286c1a9f12..88f59d07dd 100644 --- a/finance/src/main/java/net/corda/contracts/JavaCommercialPaper.java +++ b/finance/src/main/java/net/corda/contracts/JavaCommercialPaper.java @@ -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> faceValue, @Nullable Instant maturityDate, @NotNull Party notary, Integer encumbrance) { + public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount> 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> faceValue, @Nullable Instant maturityDate, @NotNull Party notary) { + public TransactionBuilder generateIssue(@NotNull PartyAndReference issuance, @NotNull Amount> faceValue, @Nullable Instant maturityDate, @NotNull Party.Full notary) { return generateIssue(issuance, faceValue, maturityDate, notary, null); } diff --git a/finance/src/main/kotlin/net/corda/contracts/CommercialPaper.kt b/finance/src/main/kotlin/net/corda/contracts/CommercialPaper.kt index 2da1f2d22d..04e05d9c4c 100644 --- a/finance/src/main/kotlin/net/corda/contracts/CommercialPaper.kt +++ b/finance/src/main/kotlin/net/corda/contracts/CommercialPaper.kt @@ -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>, maturityDate: Instant, notary: Party): TransactionBuilder { + fun generateIssue(issuance: PartyAndReference, faceValue: Amount>, 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) diff --git a/finance/src/main/kotlin/net/corda/contracts/CommercialPaperLegacy.kt b/finance/src/main/kotlin/net/corda/contracts/CommercialPaperLegacy.kt index 420d6c8657..48af3dcd2a 100644 --- a/finance/src/main/kotlin/net/corda/contracts/CommercialPaperLegacy.kt +++ b/finance/src/main/kotlin/net/corda/contracts/CommercialPaperLegacy.kt @@ -112,7 +112,7 @@ class CommercialPaperLegacy : Contract { } fun generateIssue(issuance: PartyAndReference, faceValue: Amount>, 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)) } diff --git a/finance/src/main/kotlin/net/corda/contracts/asset/Cash.kt b/finance/src/main/kotlin/net/corda/contracts/asset/Cash.kt index 55d195a8fd..a11227b668 100644 --- a/finance/src/main/kotlin/net/corda/contracts/asset/Cash.kt +++ b/finance/src/main/kotlin/net/corda/contracts/asset/Cash.kt @@ -143,13 +143,13 @@ class Cash : OnLedgerAsset() { /** * Puts together an issuance transaction from the given template, that starts out being owned by the given pubkey. */ - fun generateIssue(tx: TransactionBuilder, tokenDef: Issued, pennies: Long, owner: CompositeKey, notary: Party) + fun generateIssue(tx: TransactionBuilder, tokenDef: Issued, 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>, owner: CompositeKey, notary: Party) { + fun generateIssue(tx: TransactionBuilder, amount: Amount>, 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.sumCashOrZero(currency: Issued): Amount.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] */ diff --git a/finance/src/main/kotlin/net/corda/contracts/asset/CommodityContract.kt b/finance/src/main/kotlin/net/corda/contracts/asset/CommodityContract.kt index 7279cf896a..e33ba77bd0 100644 --- a/finance/src/main/kotlin/net/corda/contracts/asset/CommodityContract.kt +++ b/finance/src/main/kotlin/net/corda/contracts/asset/CommodityContract.kt @@ -144,13 +144,13 @@ class CommodityContract : OnLedgerAsset, pennies: Long, owner: CompositeKey, notary: Party) + fun generateIssue(tx: TransactionBuilder, tokenDef: Issued, 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>, owner: CompositeKey, notary: Party) { + fun generateIssue(tx: TransactionBuilder, amount: Amount>, owner: CompositeKey, notary: Party.Full) { check(tx.inputStates().isEmpty()) check(tx.outputStates().map { it.data }.sumCashOrNull() == null) val at = amount.token.issuer diff --git a/finance/src/main/kotlin/net/corda/contracts/asset/Obligation.kt b/finance/src/main/kotlin/net/corda/contracts/asset/Obligation.kt index 8f946c0b9c..f17996fd97 100644 --- a/finance/src/main/kotlin/net/corda/contracts/asset/Obligation.kt +++ b/finance/src/main/kotlin/net/corda/contracts/asset/Obligation.kt @@ -266,7 +266,7 @@ class Obligation

: Contract { data class State

( var lifecycle: Lifecycle = Lifecycle.NORMAL, /** Where the debt originates from (obligor) */ - val obligor: Party, + val obligor: Party.Full, val template: Terms

, val quantity: Long, /** The public key of the entity the contract pays to */ @@ -456,11 +456,11 @@ class Obligation

: 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

, pennies: Long, beneficiary: CompositeKey, - notary: Party) { + notary: Party.Full) { check(tx.inputStates().isEmpty()) check(tx.outputStates().map { it.data }.sumObligationsOrNull

() == null) tx.addOutputState(State(Lifecycle.NORMAL, obligor, issuanceDef, pennies, beneficiary), notary) @@ -469,13 +469,13 @@ class Obligation

: Contract { fun generatePaymentNetting(tx: TransactionBuilder, issued: Issued>, - notary: Party, + notary: Party.Full, vararg states: State

) { 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() + val partyLookup = HashMap() 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

: Contract { fun generateSetLifecycle(tx: TransactionBuilder, statesAndRefs: List>>, 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

: Contract { statesAndRefs: Iterable>>, assetStatesAndRefs: Iterable>>, 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

Iterable.sumObligationsOrZero(issuanceDef: Issued>().filter { it.lifecycle == Obligation.Lifecycle.NORMAL }.map { it.amount }.sumOrZero(issuanceDef) infix fun Obligation.State.at(dueBefore: Instant) = copy(template = template.copy(dueBefore = dueBefore)) -infix fun Obligation.State.between(parties: Pair) = copy(obligor = parties.first, beneficiary = parties.second) +infix fun Obligation.State.between(parties: Pair) = copy(obligor = parties.first, beneficiary = parties.second) infix fun Obligation.State.`owned by`(owner: CompositeKey) = copy(beneficiary = owner) -infix fun Obligation.State.`issued by`(party: Party) = copy(obligor = party) +infix fun Obligation.State.`issued by`(party: Party.Full) = copy(obligor = party) // For Java users: @Suppress("unused") fun Obligation.State.ownedBy(owner: CompositeKey) = copy(beneficiary = owner) -@Suppress("unused") fun Obligation.State.issuedBy(party: Party) = copy(obligor = party) +@Suppress("unused") fun Obligation.State.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.OBLIGATION_DEF: Obligation.Terms get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME) diff --git a/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt b/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt index a4284a41a3..f4d4f186e0 100644 --- a/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt +++ b/finance/src/main/kotlin/net/corda/contracts/testing/VaultFiller.kt @@ -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, - outputNotary: Party = DUMMY_NOTARY, + outputNotary: Party.Full = DUMMY_NOTARY, atLeastThisManyStates: Int = 3, atMostThisManyStates: Int = 10, rng: Random = Random(), diff --git a/finance/src/main/kotlin/net/corda/flows/CashFlow.kt b/finance/src/main/kotlin/net/corda/flows/CashFlow.kt index 5214ff907c..a88b670574 100644 --- a/finance/src/main/kotlin/net/corda/flows/CashFlow.kt +++ b/finance/src/main/kotlin/net/corda/flows/CashFlow.kt @@ -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 = inputStates + val participants: Set = inputStates .filterIsInstance() .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, tx: SignedTransaction, message: String) { + private fun finaliseTx(participants: Set, tx: SignedTransaction, message: String) { try { subFlow(FinalityFlow(tx, participants)) } catch (e: NotaryException) { @@ -145,8 +145,8 @@ sealed class CashCommand { */ class IssueCash(val amount: Amount, 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>, val recipient: Party) : CashCommand() + class PayCash(val amount: Amount>, val recipient: Party.Full) : CashCommand() /** * Exit cash from the ledger. diff --git a/finance/src/main/kotlin/net/corda/flows/IssuerFlow.kt b/finance/src/main/kotlin/net/corda/flows/IssuerFlow.kt index ff946f0fa4..2e2f56992a 100644 --- a/finance/src/main/kotlin/net/corda/flows/IssuerFlow.kt +++ b/finance/src/main/kotlin/net/corda/flows/IssuerFlow.kt @@ -19,14 +19,14 @@ import java.util.* * useful for creation of fake assets. */ object IssuerFlow { - data class IssuanceRequestState(val amount: Amount, val issueToParty: Party, val issuerPartyRef: OpaqueBytes) + data class IssuanceRequestState(val amount: Amount, 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, val issueToParty: Party, val issueToPartyRef: OpaqueBytes, - val issuerBankParty: Party): FlowLogic() { + class IssuanceRequester(val amount: Amount, val issueToParty: Party.Full, val issueToPartyRef: OpaqueBytes, + val issuerBankParty: Party.Full): FlowLogic() { @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() { + class Issuer(val otherParty: Party.Full): FlowLogic() { 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, - issueTo: Party, + issueTo: Party.Full, issuerPartyRef: OpaqueBytes): SignedTransaction { // TODO: pass notary in as request parameter val notaryParty = serviceHub.networkMapCache.notaryNodes[0].notaryIdentity diff --git a/finance/src/main/kotlin/net/corda/flows/TwoPartyTradeFlow.kt b/finance/src/main/kotlin/net/corda/flows/TwoPartyTradeFlow.kt index 50341d8ded..3b325e646a 100644 --- a/finance/src/main/kotlin/net/corda/flows/TwoPartyTradeFlow.kt +++ b/finance/src/main/kotlin/net/corda/flows/TwoPartyTradeFlow.kt @@ -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, val price: Amount, @@ -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, val typeToBuy: Class) : FlowLogic() { diff --git a/finance/src/test/kotlin/net/corda/contracts/CommercialPaperTests.kt b/finance/src/test/kotlin/net/corda/contracts/CommercialPaperTests.kt index 98c4acdaf4..1fc63454b3 100644 --- a/finance/src/test/kotlin/net/corda/contracts/CommercialPaperTests.kt +++ b/finance/src/test/kotlin/net/corda/contracts/CommercialPaperTests.kt @@ -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() } diff --git a/finance/src/test/kotlin/net/corda/contracts/asset/CashTests.kt b/finance/src/test/kotlin/net/corda/contracts/asset/CashTests.kt index 0e2e910968..85a7fd25d7 100644 --- a/finance/src/test/kotlin/net/corda/contracts/asset/CashTests.kt +++ b/finance/src/test/kotlin/net/corda/contracts/asset/CashTests.kt @@ -459,7 +459,7 @@ class CashTests { val THEIR_PUBKEY_1 = DUMMY_PUBKEY_2 - fun makeCash(amount: Amount, corp: Party, depositRef: Byte = 1) = + fun makeCash(amount: Amount, 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, corp: Party, depositRef: Byte = 1): WireTransaction { + fun makeExit(amount: Amount, 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() diff --git a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt index 3004eceb21..e42535abd9 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt @@ -30,7 +30,7 @@ class DistributedServiceTests : DriverBasedTest() { lateinit var alice: NodeHandle lateinit var notaries: List lateinit var aliceProxy: CordaRPCOps - lateinit var raftNotaryIdentity: Party + lateinit var raftNotaryIdentity: Party.Full lateinit var notaryStateMachines: Observable> 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() + val notarisationsPerNotary = HashMap() notaryStateMachines.expectEvents(isStrict = false) { replicate>(50) { expect(match = { it.second is StateMachineUpdate.Added }) { @@ -119,7 +119,7 @@ class DistributedServiceTests : DriverBasedTest() { paySelf(5.POUNDS) } - val notarisationsPerNotary = HashMap() + val notarisationsPerNotary = HashMap() notaryStateMachines.expectEvents(isStrict = false) { replicate>(30) { expect(match = { it.second is StateMachineUpdate.Added }) { diff --git a/node/src/integration-test/kotlin/net/corda/node/services/RaftNotaryServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/RaftNotaryServiceTests.kt index beb04caf0d..939080faad 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/RaftNotaryServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/RaftNotaryServiceTests.kt @@ -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) diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt index 1a1018db51..1e557b01ef 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt @@ -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() { + private class SendFlow(val otherParty: Party.Full, val payload: Any) : FlowLogic() { @Suspendable override fun call() = send(otherParty, payload) } - private class ReceiveFlow(val otherParty: Party) : FlowLogic() { + private class ReceiveFlow(val otherParty: Party.Full) : FlowLogic() { @Suspendable override fun call() = receive(otherParty).unwrap { it } } diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt index 7bc3da78ea..721a7d9fa1 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/P2PSecurityTest.kt @@ -60,7 +60,7 @@ class P2PSecurityTest : NodeBasedTest() { } private fun SimpleNode.registerWithNetworkMap(registrationName: String): ListenableFuture { - 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(REGISTER_FLOW_TOPIC, request, networkMapNode.net.myAddress) diff --git a/node/src/main/kotlin/net/corda/node/driver/Driver.kt b/node/src/main/kotlin/net/corda/node/driver/Driver.kt index 5cf4f0983c..c59f08b255 100644 --- a/node/src/main/kotlin/net/corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/net/corda/node/driver/Driver.kt @@ -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 = emptyList()): Future>> + rpcUsers: List = emptyList()): Future>> /** * Starts a web server for a node @@ -386,7 +386,7 @@ open class DriverDSL( clusterSize: Int, type: ServiceType, rpcUsers: List - ): ListenableFuture>> { + ): ListenableFuture>> { val nodeNames = (1..clusterSize).map { "Notary Node $it" } val paths = nodeNames.map { driverDirectory / it } ServiceIdentityGenerator.generateToDisk(paths, type.id, notaryName) diff --git a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt index 126f53e23f..3f2c8cffc7 100644 --- a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt @@ -104,7 +104,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, // low-performance prototyping period. protected abstract val serverThread: AffinityExecutor - private val flowFactories = ConcurrentHashMap, (Party) -> FlowLogic<*>>() + private val flowFactories = ConcurrentHashMap, (Party.Full) -> FlowLogic<*>>() protected val partyKeys = mutableSetOf() 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 { + private fun obtainKeyPair(dir: Path, privateKeyFileName: String, publicKeyFileName: String, serviceName: String? = null): Pair { // 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() + val myIdentity = pubIdentityFile.readAll().deserialize() if (myIdentity.name != identityName) throw ConfigurationException("The legal name in the config file doesn't match the stored identity file:" + "$identityName vs ${myIdentity.name}") diff --git a/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt b/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt index 0c4ee18a6c..988c8cac5b 100644 --- a/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt +++ b/node/src/main/kotlin/net/corda/node/services/identity/InMemoryIdentityService.kt @@ -13,17 +13,17 @@ import javax.annotation.concurrent.ThreadSafe */ @ThreadSafe class InMemoryIdentityService() : SingletonSerializeAsToken(), IdentityService { - private val keyToParties = ConcurrentHashMap() - private val nameToParties = ConcurrentHashMap() + private val keyToParties = ConcurrentHashMap() + private val nameToParties = ConcurrentHashMap() - 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 = ArrayList(keyToParties.values) + override fun getAllIdentities(): Iterable = 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] } diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt index 431c9f7d0d..4994b3062d 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt @@ -134,7 +134,7 @@ private class RPCKryo(observableSerializer: Serializer>? = 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(0,{}).javaClass) register(Class::class.java, ClassSerializer) diff --git a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt index 0f98f0894b..1bd468d2b0 100644 --- a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt +++ b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt @@ -75,7 +75,7 @@ interface NetworkMapService { data class FetchMapResponse(val nodes: Collection?, 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 = ConcurrentHashMap() + override val registeredNodes: MutableMap = ConcurrentHashMap() override val subscribers = ThreadBox(mutableMapOf()) init { @@ -117,7 +117,7 @@ class InMemoryNetworkMapService(services: ServiceHubInternal) : AbstractNetworkM @ThreadSafe abstract class AbstractNetworkMapService (services: ServiceHubInternal) : NetworkMapService, AbstractNodeService(services) { - protected abstract val registeredNodes: MutableMap + protected abstract val registeredNodes: MutableMap // Map from subscriber address, to most recently acknowledged update map version. protected abstract val subscribers: ThreadBox> @@ -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) { diff --git a/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapService.kt b/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapService.kt index df15a9b06d..e4012a028f 100644 --- a/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapService.kt +++ b/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapService.kt @@ -23,17 +23,17 @@ class PersistentNetworkMapService(services: ServiceHubInternal) : AbstractNetwor val registrationInfo = blob("node_registration_info") } - override val registeredNodes: MutableMap = synchronizedMap(object : AbstractJDBCHashMap(Table, loadOnInit = true) { - override fun keyFromRow(row: ResultRow): Party = Party(row[table.nodeParty.name], row[table.nodeParty.owningKey]) + override val registeredNodes: MutableMap = synchronizedMap(object : AbstractJDBCHashMap(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, finalizables: MutableList<() -> Unit>) { + override fun addKeyToInsert(insert: InsertStatement, entry: Map.Entry, 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, finalizables: MutableList<() -> Unit>) { + override fun addValueToInsert(insert: InsertStatement, entry: Map.Entry, finalizables: MutableList<() -> Unit>) { insert[table.registrationInfo] = serializeToBlob(entry.value, finalizables) } }) diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/DataVendingService.kt b/node/src/main/kotlin/net/corda/node/services/persistence/DataVendingService.kt index 8bbf3cd811..30700ed079 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/DataVendingService.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/DataVendingService.kt @@ -40,20 +40,20 @@ object DataVending { services.registerFlowInitiator(BroadcastTransactionFlow::class, ::NotifyTransactionHandler) } - private class FetchTransactionsHandler(otherParty: Party) : FetchDataHandler(otherParty) { + private class FetchTransactionsHandler(otherParty: Party.Full) : FetchDataHandler(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(otherParty) { + private class FetchAttachmentsHandler(otherParty: Party.Full) : FetchDataHandler(otherParty) { override fun getData(id: SecureHash): ByteArray? { return serviceHub.storageService.attachments.openAttachment(id)?.open()?.readBytes() } } - private abstract class FetchDataHandler(val otherParty: Party) : FlowLogic() { + private abstract class FetchDataHandler(val otherParty: Party.Full) : FlowLogic() { @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() { + class NotifyTransactionHandler(val otherParty: Party.Full) : FlowLogic() { @Suspendable override fun call() { val request = receive(otherParty).unwrap { it } diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt index 343d62288b..334622ea41 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowStateMachineImpl.kt @@ -72,7 +72,7 @@ class FlowStateMachineImpl(override val id: StateMachineRunId, } } - internal val openSessions = HashMap, Party>, FlowSession>() + internal val openSessions = HashMap, Party.Full>, FlowSession>() init { logic.stateMachine = this @@ -133,7 +133,7 @@ class FlowStateMachineImpl(override val id: StateMachineRunId, @Suspendable override fun sendAndReceive(receiveType: Class, - otherParty: Party, + otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>): UntrustworthyData { val session = getConfirmedSession(otherParty, sessionFlow) @@ -147,14 +147,14 @@ class FlowStateMachineImpl(override val id: StateMachineRunId, @Suspendable override fun receive(receiveType: Class, - otherParty: Party, + otherParty: Party.Full, sessionFlow: FlowLogic<*>): UntrustworthyData { val session = getConfirmedSession(otherParty, sessionFlow) ?: startNewSession(otherParty, sessionFlow, null, waitForConfirmation = true) return receiveInternal(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(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(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 diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/SessionMessage.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/SessionMessage.kt index c1811c98b8..98f1f218d6 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/SessionMessage.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/SessionMessage.kt @@ -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(val sender: Party, val message: M) +data class ReceivedSessionMessage(val sender: Party.Full, val message: M) fun ReceivedSessionMessage.checkPayloadIs(type: Class): UntrustworthyData { if (type.isInstance(message.payload)) { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManager.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManager.kt index 98159ddbc3..b1aef66aa8 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManager.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManager.kt @@ -117,7 +117,7 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, private val totalFinishedFlows = metrics.counter("Flows.Finished") private val openSessions = ConcurrentHashMap() - private val recentlyClosedSessions = ConcurrentHashMap() + private val recentlyClosedSessions = ConcurrentHashMap() // 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 } } diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/InMemoryUniquenessProvider.kt b/node/src/main/kotlin/net/corda/node/services/transactions/InMemoryUniquenessProvider.kt index 58509e328d..f6670d96a0 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/InMemoryUniquenessProvider.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/InMemoryUniquenessProvider.kt @@ -15,7 +15,7 @@ class InMemoryUniquenessProvider() : UniquenessProvider { /** For each input state store the consuming transaction information */ private val committedStates = ThreadBox(HashMap()) - override fun commit(states: List, txId: SecureHash, callerIdentity: Party) { + override fun commit(states: List, txId: SecureHash, callerIdentity: Party.Full) { committedStates.locked { val conflictingStates = LinkedHashMap() for (inputState in states) { diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/NotaryService.kt b/node/src/main/kotlin/net/corda/node/services/transactions/NotaryService.kt index 66410033cb..942ab477a6 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/NotaryService.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/NotaryService.kt @@ -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 } diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/PersistentUniquenessProvider.kt b/node/src/main/kotlin/net/corda/node/services/transactions/PersistentUniquenessProvider.kt index e9c533153c..e59f956f5f 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/PersistentUniquenessProvider.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/PersistentUniquenessProvider.kt @@ -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, txId: SecureHash, callerIdentity: Party) { + override fun commit(states: List, txId: SecureHash, callerIdentity: Party.Full) { val conflict = committedStates.locked { val conflictingStates = LinkedHashMap() for (inputState in states) { diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/RaftUniquenessProvider.kt b/node/src/main/kotlin/net/corda/node/services/transactions/RaftUniquenessProvider.kt index 526d62f0c6..ef08d1f6dd 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/RaftUniquenessProvider.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/RaftUniquenessProvider.kt @@ -107,7 +107,7 @@ class RaftUniquenessProvider(storagePath: Path, myAddress: HostAndPort, clusterA .build() } - override fun commit(states: List, txId: SecureHash, callerIdentity: Party) { + override fun commit(states: List, 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()}") diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/RaftValidatingNotaryService.kt b/node/src/main/kotlin/net/corda/node/services/transactions/RaftValidatingNotaryService.kt index 3ef3e1610f..16149b80cb 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/RaftValidatingNotaryService.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/RaftValidatingNotaryService.kt @@ -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) } } diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/SimpleNotaryService.kt b/node/src/main/kotlin/net/corda/node/services/transactions/SimpleNotaryService.kt index 155e2b1594..0d6e3d27ae 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/SimpleNotaryService.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/SimpleNotaryService.kt @@ -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) } } diff --git a/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryService.kt b/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryService.kt index 9bdf100e3f..fa69e3e7a8 100644 --- a/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryService.kt +++ b/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryService.kt @@ -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) } } diff --git a/node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt b/node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt index eeff28cf6d..173fef505e 100644 --- a/node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt +++ b/node/src/main/kotlin/net/corda/node/services/vault/NodeVaultService.kt @@ -205,7 +205,7 @@ class NodeVaultService(private val services: ServiceHub) : SingletonSerializeAsT override fun generateSpend(tx: TransactionBuilder, amount: Amount, to: CompositeKey, - onlyFromParties: Set?): Pair> { + onlyFromParties: Set?): Pair> { // Discussion // // This code is analogous to the Wallet.send() set of methods in bitcoinj, and has the same general outline. diff --git a/node/src/main/kotlin/net/corda/node/utilities/JsonSupport.kt b/node/src/main/kotlin/net/corda/node/utilities/JsonSupport.kt index 20d06f4e67..137ae30cfa 100644 --- a/node/src/main/kotlin/net/corda/node/utilities/JsonSupport.kt +++ b/node/src/main/kotlin/net/corda/node/utilities/JsonSupport.kt @@ -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() { - override fun serialize(obj: Party, generator: JsonGenerator, provider: SerializerProvider) { + object PartySerializer : JsonSerializer() { + override fun serialize(obj: Party.Full, generator: JsonGenerator, provider: SerializerProvider) { generator.writeString(obj.name) } } - object PartyDeserializer : JsonDeserializer() { - override fun deserialize(parser: JsonParser, context: DeserializationContext): Party { + object PartyDeserializer : JsonDeserializer() { + override fun deserialize(parser: JsonParser, context: DeserializationContext): Party.Full { if (parser.currentToken == JsonToken.FIELD_NAME) { parser.nextToken() } diff --git a/node/src/main/kotlin/net/corda/node/utilities/ServiceIdentityGenerator.kt b/node/src/main/kotlin/net/corda/node/utilities/ServiceIdentityGenerator.kt index c4a1981952..f7c00158ff 100644 --- a/node/src/main/kotlin/net/corda/node/utilities/ServiceIdentityGenerator.kt +++ b/node/src/main/kotlin/net/corda/node/utilities/ServiceIdentityGenerator.kt @@ -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) diff --git a/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt b/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt index b469f33c79..387e49b3c7 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt +++ b/node/src/test/kotlin/net/corda/node/messaging/TwoPartyTradeFlowTests.kt @@ -490,8 +490,8 @@ class TwoPartyTradeFlowTests { private fun LedgerDSL.fillUpForBuyer( withError: Boolean, owner: CompositeKey, - issuer: Party, - notary: Party): Pair> { + issuer: Party.Full, + notary: Party.Full): Pair> { 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>, attachmentID: SecureHash?, - notary: Party): Pair> { + notary: Party.Full): Pair> { 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) diff --git a/node/src/test/kotlin/net/corda/node/services/MockServiceHubInternal.kt b/node/src/test/kotlin/net/corda/node/services/MockServiceHubInternal.kt index 0309eaa766..f232a368fc 100644 --- a/node/src/test/kotlin/net/corda/node/services/MockServiceHubInternal.kt +++ b/node/src/test/kotlin/net/corda/node/services/MockServiceHubInternal.kt @@ -65,7 +65,7 @@ open class MockServiceHubInternal( private val txStorageService: TxWritableStorageService get() = storage ?: throw UnsupportedOperationException() - private val flowFactories = ConcurrentHashMap, (Party) -> FlowLogic<*>>() + private val flowFactories = ConcurrentHashMap, (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] } } diff --git a/node/src/test/kotlin/net/corda/node/services/NotaryChangeTests.kt b/node/src/test/kotlin/net/corda/node/services/NotaryChangeTests.kt index 3aef650af2..35dcfcdfda 100644 --- a/node/src/test/kotlin/net/corda/node/services/NotaryChangeTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/NotaryChangeTests.kt @@ -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 diff --git a/node/src/test/kotlin/net/corda/node/services/ScheduledFlowTests.kt b/node/src/test/kotlin/net/corda/node/services/ScheduledFlowTests.kt index b3545fccff..c984e3aba6 100644 --- a/node/src/test/kotlin/net/corda/node/services/ScheduledFlowTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/ScheduledFlowTests.kt @@ -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() { + class InsertInitialStateFlow(val destination: Party.Full) : FlowLogic() { @Suspendable override fun call() { val scheduledState = ScheduledState(serviceHub.clock.instant(), @@ -87,7 +87,7 @@ class ScheduledFlowTests { class ScheduledFlowTestPlugin : CordaPluginRegistry() { override val requiredFlows: Map> = 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) ) } diff --git a/node/src/test/kotlin/net/corda/node/services/persistence/DataVendingServiceTests.kt b/node/src/test/kotlin/net/corda/node/services/persistence/DataVendingServiceTests.kt index c5aeba062f..4b3c5ff45f 100644 --- a/node/src/test/kotlin/net/corda/node/services/persistence/DataVendingServiceTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/persistence/DataVendingServiceTests.kt @@ -94,7 +94,7 @@ class DataVendingServiceTests { } - private class NotifyTxFlow(val otherParty: Party, val stx: SignedTransaction) : FlowLogic() { + private class NotifyTxFlow(val otherParty: Party.Full, val stx: SignedTransaction) : FlowLogic() { @Suspendable override fun call() = send(otherParty, NotifyTxRequest(stx)) } diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/StateMachineManagerTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/StateMachineManagerTests.kt index db91cc92a4..856bdffb53 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/StateMachineManagerTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/StateMachineManagerTests.kt @@ -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() { + private class SendAndReceiveFlow(val otherParty: Party.Full, val payload: Any) : FlowLogic() { @Suspendable override fun call() { sendAndReceive(otherParty, payload) @@ -434,7 +434,7 @@ class StateMachineManagerTests { ) } - private class ConditionalExceptionFlow(val otherParty: Party, val sendPayload: Any) : FlowLogic() { + private class ConditionalExceptionFlow(val otherParty: Party.Full, val sendPayload: Any) : FlowLogic() { @Suspendable override fun call() { val throwException = receive(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() { + class AskForExceptionFlow(val otherParty: Party.Full, val throwException: Boolean) : FlowLogic() { @Suspendable override fun call(): String = sendAndReceive(otherParty, throwException).unwrap { it } } - class RetryOnExceptionFlow(val otherParty: Party) : FlowLogic() { + class RetryOnExceptionFlow(val otherParty: Party.Full) : FlowLogic() { @Suspendable override fun call(): String { return try { @@ -541,7 +541,7 @@ class StateMachineManagerTests { } - private class SendFlow(val payload: Any, vararg val otherParties: Party) : FlowLogic() { + private class SendFlow(val payload: Any, vararg val otherParties: Party.Full) : FlowLogic() { init { require(otherParties.isNotEmpty()) } @@ -551,7 +551,7 @@ class StateMachineManagerTests { } - private class ReceiveFlow(vararg val otherParties: Party) : FlowLogic() { + private class ReceiveFlow(vararg val otherParties: Party.Full) : FlowLogic() { private var nonTerminating: Boolean = false init { @@ -574,7 +574,7 @@ class StateMachineManagerTests { } } - private class PingPongFlow(val otherParty: Party, val payload: Long) : FlowLogic() { + private class PingPongFlow(val otherParty: Party.Full, val payload: Long) : FlowLogic() { @Transient var receivedPayload: Long? = null @Transient var receivedPayload2: Long? = null diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt index 2f84383c2f..40d799bb81 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt @@ -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 diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt index 96abb9d1d9..2ff98df53a 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/plugin/BankOfCordaPlugin.kt @@ -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> = - 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)) } diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt index b172a9768d..6913c41246 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/api/NodeInterestRates.kt @@ -74,7 +74,7 @@ object NodeInterestRates { services.registerFlowInitiator(RatesFixFlow.FixQueryFlow::class) { FixQueryHandler(it, this) } } - private class FixSignHandler(val otherParty: Party, val service: Service) : FlowLogic() { + private class FixSignHandler(val otherParty: Party.Full, val service: Service) : FlowLogic() { @Suspendable override fun call() { val request = receive(otherParty).unwrap { it } @@ -82,7 +82,7 @@ object NodeInterestRates { } } - private class FixQueryHandler(val otherParty: Party, val service: Service) : FlowLogic() { + private class FixQueryHandler(val otherParty: Party.Full, val service: Service) : FlowLogic() { 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") diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt index 60c30dae1f..684cf3859c 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt @@ -304,7 +304,7 @@ class InterestRateSwap() : Contract { } open class FixedLeg( - var fixedRatePayer: Party, + var fixedRatePayer: Party.Full, notional: Amount, 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 = 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, 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 = 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 + override val parties: List 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() var dates = BusinessCalendar.createGenericSchedule(fixedLeg.effectiveDate, fixedLeg.paymentFrequency, fixedLeg.paymentCalendar, fixedLeg.rollConvention, endDate = fixedLeg.terminationDate) diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt index 2d1cf59900..bc3a3c9234 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/AutoOfferFlow.kt @@ -78,8 +78,8 @@ object AutoOfferFlow { return stx } - private fun notUs(parties: List): List { - val notUsParties: MutableList = arrayListOf() + private fun notUs(parties: List): List { + val notUsParties: MutableList = arrayListOf() for (party in parties) { if (serviceHub.myInfo.legalIdentity != party) { notUsParties.add(party) diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt index 044036d19c..81e9e6d16b 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/ExitServerFlow.kt @@ -32,7 +32,7 @@ object ExitServerFlow { } - private class ExitServerHandler(val otherParty: Party) : FlowLogic() { + private class ExitServerHandler(val otherParty: Party.Full) : FlowLogic() { override fun call() { // Just to validate we got the message if (enabled) { diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt index c34dbb0ac7..caeda66fc3 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/FixingFlow.kt @@ -33,7 +33,7 @@ object FixingFlow { * of the flow that is run by the party with the fixed leg of swap deal, which is the basis for deciding * who does what in the flow. */ - class Fixer(override val otherParty: Party, + class Fixer(override val otherParty: Party.Full, override val progressTracker: ProgressTracker = TwoPartyDealFlow.Secondary.tracker()) : TwoPartyDealFlow.Secondary() { private lateinit var txState: TransactionState<*> @@ -96,7 +96,7 @@ object FixingFlow { * is just the "side" of the flow run by the party with the floating leg as a way of deciding who * does what in the flow. */ - class Floater(override val otherParty: Party, + class Floater(override val otherParty: Party.Full, override val payload: FixingSession, override val progressTracker: ProgressTracker = TwoPartyDealFlow.Primary.tracker()) : TwoPartyDealFlow.Primary() { diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/RatesFixFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/RatesFixFlow.kt index 237264cfc8..90add5581e 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/RatesFixFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/RatesFixFlow.kt @@ -30,7 +30,7 @@ import java.util.* open class RatesFixFlow(protected val tx: TransactionBuilder, /** Filtering functions over transaction, used to build partial transaction presented to oracle. */ private val filterFuns: FilterFuns, - private val oracle: Party, + private val oracle: Party.Full, private val fixOf: FixOf, private val expectedRate: BigDecimal, private val rateTolerance: BigDecimal, @@ -81,7 +81,7 @@ open class RatesFixFlow(protected val tx: TransactionBuilder, } // DOCSTART 1 - class FixQueryFlow(val fixOf: FixOf, val oracle: Party) : FlowLogic() { + class FixQueryFlow(val fixOf: FixOf, val oracle: Party.Full) : FlowLogic() { @Suspendable override fun call(): Fix { val deadline = suggestInterestRateAnnouncementTimeWindow(fixOf.name, oracle.name, fixOf.forDay).end @@ -97,7 +97,7 @@ open class RatesFixFlow(protected val tx: TransactionBuilder, } } - class FixSignFlow(val tx: TransactionBuilder, val oracle: Party, val filterFuns: FilterFuns) : FlowLogic() { + class FixSignFlow(val tx: TransactionBuilder, val oracle: Party.Full, val filterFuns: FilterFuns) : FlowLogic() { @Suspendable override fun call(): DigitalSignature.LegallyIdentifiable { val wtx = tx.toWireTransaction() diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt index d6918d9020..349843cfeb 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/flows/UpdateBusinessDayFlow.kt @@ -31,7 +31,7 @@ object UpdateBusinessDayFlow { } } - private class UpdateBusinessDayHandler(val otherParty: Party) : FlowLogic() { + private class UpdateBusinessDayHandler(val otherParty: Party.Full) : FlowLogic() { override fun call() { val message = receive(otherParty).unwrap { it } (serviceHub.clock as TestClock).updateDate(message.date) diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt index 9f3bc79a0c..95f530a864 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/plugin/IRSPlugin.kt @@ -27,7 +27,7 @@ class IRSPlugin : CordaPluginRegistry() { UpdateBusinessDayFlow.Broadcast::class.java.name to setOf(LocalDate::class.java.name), ExitServerFlow.Broadcast::class.java.name to setOf(kotlin.Int::class.java.name), FixingFlow.FixingRoleDecider::class.java.name to setOf(StateRef::class.java.name, Duration::class.java.name), - FixingFlow.Floater::class.java.name to setOf(Party::class.java.name, FixingFlow.FixingSession::class.java.name)) + FixingFlow.Floater::class.java.name to setOf(Party.Full::class.java.name, FixingFlow.FixingSession::class.java.name)) override fun registerRPCKryoTypes(kryo: Kryo): Boolean { kryo.apply { diff --git a/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt b/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt index a837a22fc7..b6b843edda 100644 --- a/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt +++ b/samples/irs-demo/src/test/kotlin/net/corda/irs/testing/NodeInterestRatesTest.kt @@ -46,7 +46,7 @@ class NodeInterestRatesTest { """.trimIndent()) val DUMMY_CASH_ISSUER_KEY = generateKeyPair() - val DUMMY_CASH_ISSUER = Party("Cash issuer", DUMMY_CASH_ISSUER_KEY.public) + val DUMMY_CASH_ISSUER = Party.Full("Cash issuer", DUMMY_CASH_ISSUER_KEY.public) val clock = Clock.systemUTC() lateinit var oracle: NodeInterestRates.Oracle diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt index 6858396298..40ba968f2b 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt @@ -8,7 +8,7 @@ import net.corda.core.node.recordTransactions import net.corda.core.transactions.SignedTransaction import java.util.* -class DummyIssueAndMove(private val notary: Party, private val counterpartyNode: Party) : FlowLogic() { +class DummyIssueAndMove(private val notary: Party.Full, private val counterpartyNode: Party.Full) : FlowLogic() { @Suspendable override fun call(): SignedTransaction { val random = Random() diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt index f6f05665d8..384aaba3d0 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt @@ -11,6 +11,6 @@ class NotaryDemoPlugin : CordaPluginRegistry() { // A list of protocols that are required for this cordapp override val requiredFlows = mapOf( NotaryFlow.Client::class.java.name to setOf(SignedTransaction::class.java.name, setOf(Unit).javaClass.name), - DummyIssueAndMove::class.java.name to setOf(Party::class.java.name) + DummyIssueAndMove::class.java.name to setOf(Party.Full::class.java.name) ) } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt index 1c45d087b9..6986f43f8b 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt @@ -29,10 +29,10 @@ import javax.ws.rs.core.Response @Path("simmvaluationdemo") class PortfolioApi(val rpc: CordaRPCOps) { - private val ownParty: Party get() = rpc.nodeIdentity().legalIdentity + private val ownParty: Party.Full get() = rpc.nodeIdentity().legalIdentity private val portfolioUtils = PortfolioApiUtils(ownParty) - private inline fun dealsWith(party: Party): List> { + private inline fun dealsWith(party: Party.Full): List> { return rpc.vaultAndUpdates().first.filterStatesOfType().filter { it.state.data.parties.any { it == party } } } @@ -40,7 +40,7 @@ class PortfolioApi(val rpc: CordaRPCOps) { * DSL to get a party and then executing the passed function with the party as a parameter. * Used as such: withParty(name) { doSomethingWith(it) } */ - private fun withParty(partyName: String, func: (Party) -> Response): Response { + private fun withParty(partyName: String, func: (Party.Full) -> Response): Response { val otherParty = rpc.partyFromKey(CompositeKey.parseFromBase58(partyName)) return if (otherParty != null) { func(otherParty) @@ -53,7 +53,7 @@ class PortfolioApi(val rpc: CordaRPCOps) { * DSL to get a portfolio and then executing the passed function with the portfolio as a parameter. * Used as such: withPortfolio(party) { doSomethingWith(it) } */ - private fun withPortfolio(party: Party, func: (PortfolioState) -> Response): Response { + private fun withPortfolio(party: Party.Full, func: (PortfolioState) -> Response): Response { val portfolio = getPortfolioWith(party) return if (portfolio != null) { func(portfolio) @@ -65,12 +65,12 @@ class PortfolioApi(val rpc: CordaRPCOps) { /** * Gets all existing IRSStates with the party provided. */ - private fun getTradesWith(party: Party) = dealsWith(party) + private fun getTradesWith(party: Party.Full) = dealsWith(party) /** * Gets the most recent portfolio state, or null if not extant, with the party provided. */ - private fun getPortfolioWith(party: Party): PortfolioState? { + private fun getPortfolioWith(party: Party.Full): PortfolioState? { val portfolios = dealsWith(party) // Can have at most one between any two parties with the current no split portfolio model require(portfolios.size < 2) { "This API currently only supports one portfolio with a counterparty" } @@ -82,7 +82,7 @@ class PortfolioApi(val rpc: CordaRPCOps) { * * @warning Do not call if you have not agreed a portfolio with the other party. */ - private fun getPortfolioStateAndRefWith(party: Party): StateAndRef { + private fun getPortfolioStateAndRefWith(party: Party.Full): StateAndRef { val portfolios = dealsWith(party) // Can have at most one between any two parties with the current no split portfolio model require(portfolios.size < 2) { "This API currently only supports one portfolio with a counterparty" } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApiUtils.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApiUtils.kt index 9105fc2d11..526d1480f2 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApiUtils.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApiUtils.kt @@ -14,7 +14,7 @@ import java.time.LocalDate /** * API JSON generation functions for larger JSON outputs. */ -class PortfolioApiUtils(private val ownParty: Party) { +class PortfolioApiUtils(private val ownParty: Party.Full) { data class InitialMarginView(val baseCurrency: String, val post: Map, val call: Map, val agreed: Boolean) data class ValuationsView( val businessDate: LocalDate, diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataModel.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataModel.kt index f3ebfca2e1..b0365d9cd4 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataModel.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataModel.kt @@ -25,7 +25,7 @@ data class SwapDataModel( /** * Turn this model into the internal representation of SwapData. */ - fun toData(buyer: Party, seller: Party): SwapData { + fun toData(buyer: Party.Full, seller: Party.Full): SwapData { return SwapData( Pair("swap", id), Pair("party", buyer.name), Pair("party", seller.name), description, tradeDate, convention, startDate, endDate, notional, fixedRate ) diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataView.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataView.kt index 1b95df95d2..d1cea89053 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataView.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/SwapDataView.kt @@ -27,7 +27,7 @@ data class SwapDataView( var marginedText: String = "❌️") { } -fun SwapData.toView(viewingParty: Party, portfolio: Portfolio? = null, +fun SwapData.toView(viewingParty: Party.Full, portfolio: Portfolio? = null, presentValue: MultiCurrencyAmount? = null, IM: InitialMarginTriple? = null): SwapDataView { val isBuyer = viewingParty.name == buyer.second diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/IRSState.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/IRSState.kt index 40de703256..ee57a0b921 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/IRSState.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/IRSState.kt @@ -15,18 +15,18 @@ import java.security.PublicKey * TODO: Merge with the existing demo IRS code. */ data class IRSState(val swap: SwapData, - val buyer: Party, - val seller: Party, + val buyer: Party.Full, + val seller: Party.Full, override val contract: OGTrade, override val linearId: UniqueIdentifier = UniqueIdentifier(swap.id.first + swap.id.second)) : DealState { override val ref: String = linearId.externalId!! // Same as the constructor for UniqueIdentified - override val parties: List get() = listOf(buyer, seller) + override val parties: List get() = listOf(buyer, seller) override fun isRelevant(ourKeys: Set): Boolean { return parties.flatMap { it.owningKey.keys }.intersect(ourKeys).isNotEmpty() } - override fun generateAgreement(notary: Party): TransactionBuilder { + override fun generateAgreement(notary: Party.Full): TransactionBuilder { val state = IRSState(swap, buyer, seller, OGTrade()) return TransactionType.General.Builder(notary).withItems(state, Command(OGTrade.Commands.Agree(), parties.map { it.owningKey })) } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/PortfolioState.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/PortfolioState.kt index 35704e5b64..2c92d6e539 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/PortfolioState.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/PortfolioState.kt @@ -17,16 +17,16 @@ import java.time.temporal.ChronoUnit */ data class PortfolioState(val portfolio: List, override val contract: PortfolioSwap, - private val _parties: Pair, + private val _parties: Pair, val valuationDate: LocalDate, val valuation: PortfolioValuation? = null, override val linearId: UniqueIdentifier = UniqueIdentifier()) : RevisionedState, SchedulableState, DealState { data class Update(val portfolio: List? = null, val valuation: PortfolioValuation? = null) - override val parties: List get() = _parties.toList() + override val parties: List get() = _parties.toList() override val ref: String = linearId.toString() - val valuer: Party get() = parties[0] + val valuer: Party.Full get() = parties[0] override val participants: List get() = parties.map { it.owningKey } @@ -40,11 +40,11 @@ data class PortfolioState(val portfolio: List, return parties.flatMap { it.owningKey.keys }.intersect(ourKeys).isNotEmpty() } - override fun generateAgreement(notary: Party): TransactionBuilder { + override fun generateAgreement(notary: Party.Full): TransactionBuilder { return TransactionType.General.Builder(notary).withItems(copy(), Command(PortfolioSwap.Commands.Agree(), parties.map { it.owningKey })) } - override fun generateRevision(notary: Party, oldState: StateAndRef<*>, updatedValue: Update): TransactionBuilder { + override fun generateRevision(notary: Party.Full, oldState: StateAndRef<*>, updatedValue: Update): TransactionBuilder { require(oldState.state.data == this) val portfolio = updatedValue.portfolio ?: portfolio val valuation = updatedValue.valuation ?: valuation diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/RevisionedState.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/RevisionedState.kt index ee606147c7..303530fd58 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/RevisionedState.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/RevisionedState.kt @@ -11,5 +11,5 @@ import net.corda.core.transactions.TransactionBuilder * functional sense) however it can be amended and then re-written as another state into the ledger. */ interface RevisionedState : ContractState { - fun generateRevision(notary: Party, oldState: StateAndRef<*>, updatedValue: T): TransactionBuilder + fun generateRevision(notary: Party.Full, oldState: StateAndRef<*>, updatedValue: T): TransactionBuilder } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/SwapData.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/SwapData.kt index 70c58c3691..6a45c87aa0 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/SwapData.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/contracts/SwapData.kt @@ -46,7 +46,7 @@ data class SwapData( val notional: BigDecimal, val fixedRate: BigDecimal) { - fun getLegForParty(party: Party): Leg { + fun getLegForParty(party: Party.Full): Leg { return if (party.name == buyer.second) FixedLeg(notional) else FloatingLeg(notional) } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/IRSTradeFlow.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/IRSTradeFlow.kt index c9e60d7296..79ed133b2c 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/IRSTradeFlow.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/IRSTradeFlow.kt @@ -11,9 +11,9 @@ import net.corda.vega.contracts.OGTrade import net.corda.vega.contracts.SwapData object IRSTradeFlow { - data class OfferMessage(val notary: Party, val dealBeingOffered: IRSState) + data class OfferMessage(val notary: Party.Full, val dealBeingOffered: IRSState) - class Requester(val swap: SwapData, val otherParty: Party) : FlowLogic() { + class Requester(val swap: SwapData, val otherParty: Party.Full) : FlowLogic() { @Suspendable override fun call(): SignedTransaction { @@ -45,7 +45,7 @@ object IRSTradeFlow { } } - class Receiver(private val replyToParty: Party) : FlowLogic() { + class Receiver(private val replyToParty: Party.Full) : FlowLogic() { @Suspendable override fun call() { diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt index 40ba74a159..d6ac071b15 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/SimmFlow.kt @@ -38,7 +38,7 @@ object SimmFlow { * Represents a new portfolio offer unless the stateRef field is non-null, at which point it represents a * portfolio update offer. */ - data class OfferMessage(val notary: Party, + data class OfferMessage(val notary: Party.Full, val dealBeingOffered: PortfolioState, val stateRef: StateRef?, val valuationDate: LocalDate) @@ -47,14 +47,14 @@ object SimmFlow { * Initiates with the other party by sending a portfolio to agree on and then comes to consensus over initial * margin using SIMM. If there is an existing state it will update and revalue the portfolio agreement. */ - class Requester(val otherParty: Party, + class Requester(val otherParty: Party.Full, val valuationDate: LocalDate, val existing: StateAndRef?) : FlowLogic>() { - constructor(otherParty: Party, valuationDate: LocalDate) : this(otherParty, valuationDate, null) + constructor(otherParty: Party.Full, valuationDate: LocalDate) : this(otherParty, valuationDate, null) - lateinit var myIdentity: Party - lateinit var notary: Party + lateinit var myIdentity: Party.Full + lateinit var notary: Party.Full @Suspendable override fun call(): RevisionedState { @@ -108,7 +108,7 @@ object SimmFlow { } @Suspendable - private fun agreeValuation(portfolio: Portfolio, asOf: LocalDate, valuer: Party): PortfolioValuation { + private fun agreeValuation(portfolio: Portfolio, asOf: LocalDate, valuer: Party.Full): PortfolioValuation { // TODO: The attachments need to be added somewhere // TODO: handle failures val analyticsEngine = OGSIMMAnalyticsEngine() @@ -186,8 +186,8 @@ object SimmFlow { /** * Receives and validates a portfolio and comes to consensus over the portfolio initial margin using SIMM. */ - class Receiver(val replyToParty: Party) : FlowLogic() { - lateinit var ownParty: Party + class Receiver(val replyToParty: Party.Full) : FlowLogic() { + lateinit var ownParty: Party.Full lateinit var offer: OfferMessage @Suspendable @@ -235,7 +235,7 @@ object SimmFlow { * [ reference data is data such as calendars etc, market data is data such as current market price of ] */ @Suspendable - private fun agreeValuation(portfolio: Portfolio, asOf: LocalDate, valuer: Party): PortfolioValuation { + private fun agreeValuation(portfolio: Portfolio, asOf: LocalDate, valuer: Party.Full): PortfolioValuation { // TODO: The attachments need to be added somewhere // TODO: handle failures val analyticsEngine = OGSIMMAnalyticsEngine() diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/StateRevisionFlow.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/StateRevisionFlow.kt index 2da3cce5a3..c023d66967 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/StateRevisionFlow.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/flows/StateRevisionFlow.kt @@ -27,7 +27,7 @@ object StateRevisionFlow { } } - open class Receiver(otherParty: Party) : AbstractStateReplacementFlow.Acceptor(otherParty) { + open class Receiver(otherParty: Party.Full) : AbstractStateReplacementFlow.Acceptor(otherParty) { override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal) { val proposedTx = proposal.stx.tx val state = proposal.stateRef diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/portfolio/Portfolio.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/portfolio/Portfolio.kt index b7b326035f..08b0e5629c 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/portfolio/Portfolio.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/portfolio/Portfolio.kt @@ -21,7 +21,7 @@ data class Portfolio(private val tradeStateAndRefs: List>, val swaps: List by lazy { trades.map { it.swap } } val refs: List by lazy { tradeStateAndRefs.map { it.ref } } - fun getNotionalForParty(party: Party) = trades.map { it.swap.getLegForParty(party).notional }.sum() + fun getNotionalForParty(party: Party.Full) = trades.map { it.swap.getLegForParty(party).notional }.sum() fun update(curTrades: List>): Portfolio { return copy(tradeStateAndRefs = curTrades) diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/services/SimmService.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/services/SimmService.kt index 00376820f3..6974c64b45 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/services/SimmService.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/services/SimmService.kt @@ -36,9 +36,9 @@ object SimmService { class Plugin : CordaPluginRegistry() { override val webApis = listOf(Function(::PortfolioApi)) override val requiredFlows: Map> = mapOf( - SimmFlow.Requester::class.java.name to setOf(Party::class.java.name, LocalDate::class.java.name), + SimmFlow.Requester::class.java.name to setOf(Party.Full::class.java.name, LocalDate::class.java.name), SimmRevaluation.Initiator::class.java.name to setOf(StateRef::class.java.name, LocalDate::class.java.name), - IRSTradeFlow.Requester::class.java.name to setOf(SwapData::class.java.name, Party::class.java.name)) + IRSTradeFlow.Requester::class.java.name to setOf(SwapData::class.java.name, Party.Full::class.java.name)) override val staticServeDirs: Map = mapOf("simmvaluationdemo" to javaClass.classLoader.getResource("simmvaluationweb").toExternalForm()) override val servicePlugins = listOf(Function(SimmFlow::Service), Function(IRSTradeFlow::Service)) override fun registerRPCKryoTypes(kryo: Kryo): Boolean { diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/BuyerFlow.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/BuyerFlow.kt index 1226e178b9..2a48e160b7 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/BuyerFlow.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/BuyerFlow.kt @@ -17,7 +17,7 @@ import net.corda.node.services.persistence.NodeAttachmentService import java.nio.file.Path import java.util.* -class BuyerFlow(val otherParty: Party, +class BuyerFlow(val otherParty: Party.Full, private val attachmentsPath: Path, override val progressTracker: ProgressTracker = ProgressTracker(STARTING_BUY)) : FlowLogic() { diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/SellerFlow.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/SellerFlow.kt index 6ae1c8f5d7..40dbcdddc4 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/SellerFlow.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/flow/SellerFlow.kt @@ -16,10 +16,10 @@ import net.corda.flows.TwoPartyTradeFlow import java.time.Instant import java.util.* -class SellerFlow(val otherParty: Party, +class SellerFlow(val otherParty: Party.Full, val amount: Amount, override val progressTracker: ProgressTracker) : FlowLogic() { - constructor(otherParty: Party, amount: Amount) : this(otherParty, amount, tracker()) + constructor(otherParty: Party.Full, amount: Amount) : this(otherParty, amount, tracker()) companion object { val PROSPECTUS_HASH = SecureHash.parse("decd098666b9657314870e192ced0c3519c2c9d395507a238338f8d003929de9") @@ -65,7 +65,7 @@ class SellerFlow(val otherParty: Party, fun selfIssueSomeCommercialPaper(ownedBy: CompositeKey, notaryNode: NodeInfo): StateAndRef { // Make a fake company that's issued its own paper. val keyPair = generateKeyPair() - val party = Party("Bank of London", keyPair.public) + val party = Party.Full("Bank of London", keyPair.public) val issuance: SignedTransaction = run { val tx = CommercialPaper().generateIssue(party.ref(1, 2, 3), 1100.DOLLARS `issued by` DUMMY_CASH_ISSUER, diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt index 093740050e..ce06f24723 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt @@ -12,7 +12,7 @@ import java.util.function.Function class TraderDemoPlugin : CordaPluginRegistry() { // A list of Flows that are required for this cordapp override val requiredFlows: Map> = mapOf( - SellerFlow::class.java.name to setOf(Party::class.java.name, Amount::class.java.name) + SellerFlow::class.java.name to setOf(Party.Full::class.java.name, Amount::class.java.name) ) override val servicePlugins = listOf(Function(BuyerFlow::Service)) } diff --git a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt index 527a9c77da..4623bb7b50 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/CoreTestUtils.kt @@ -58,22 +58,22 @@ val ORACLE_PUBKEY: CompositeKey get() = ORACLE_KEY.public.composite val ALICE_KEY: KeyPair by lazy { generateKeyPair() } val ALICE_PUBKEY: CompositeKey get() = ALICE_KEY.public.composite -val ALICE: Party get() = Party("Alice", ALICE_PUBKEY) +val ALICE: Party.Full get() = Party.Full("Alice", ALICE_PUBKEY) val BOB_KEY: KeyPair by lazy { generateKeyPair() } val BOB_PUBKEY: CompositeKey get() = BOB_KEY.public.composite -val BOB: Party get() = Party("Bob", BOB_PUBKEY) +val BOB: Party.Full get() = Party.Full("Bob", BOB_PUBKEY) val CHARLIE_KEY: KeyPair by lazy { generateKeyPair() } val CHARLIE_PUBKEY: CompositeKey get() = CHARLIE_KEY.public.composite -val CHARLIE: Party get() = Party("Charlie", CHARLIE_PUBKEY) +val CHARLIE: Party.Full get() = Party.Full("Charlie", CHARLIE_PUBKEY) -val MEGA_CORP: Party get() = Party("MegaCorp", MEGA_CORP_PUBKEY) -val MINI_CORP: Party get() = Party("MiniCorp", MINI_CORP_PUBKEY) +val MEGA_CORP: Party.Full get() = Party.Full("MegaCorp", MEGA_CORP_PUBKEY) +val MINI_CORP: Party.Full get() = Party.Full("MiniCorp", MINI_CORP_PUBKEY) val BOC_KEY: KeyPair by lazy { generateKeyPair() } val BOC_PUBKEY: CompositeKey get() = BOC_KEY.public.composite -val BOC: Party get() = Party("BankOfCorda", BOC_PUBKEY) +val BOC: Party.Full get() = Party.Full("BankOfCorda", BOC_PUBKEY) val BOC_PARTY_REF = BOC.ref(OpaqueBytes.of(1)).reference val ALL_TEST_KEYS: List get() = listOf(MEGA_CORP_KEY, MINI_CORP_KEY, ALICE_KEY, BOB_KEY, DUMMY_NOTARY_KEY) @@ -139,7 +139,7 @@ fun getFreeLocalPorts(hostName: String, numberToAlloc: Int): List { */ inline fun > AbstractNode.initiateSingleShotFlow( markerClass: KClass>, - noinline flowFactory: (Party) -> P): ListenableFuture

{ + noinline flowFactory: (Party.Full) -> P): ListenableFuture

{ val future = smm.changes.filter { it.addOrRemove == ADD && it.logic is P }.map { it.logic as P }.toFuture() services.registerFlowInitiator(markerClass, flowFactory) return future diff --git a/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt b/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt index 95dfcb0e74..89fb48fa48 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/TestDSL.kt @@ -115,7 +115,7 @@ data class TestTransactionDSLInterpreter private constructor( transactionBuilder.addInputState(StateAndRef(state, stateRef)) } - override fun _output(label: String?, notary: Party, encumbrance: Int?, contractState: ContractState) { + override fun _output(label: String?, notary: Party.Full, encumbrance: Int?, contractState: ContractState) { val outputIndex = transactionBuilder.addOutputState(contractState, notary, encumbrance) if (label != null) { if (label in labelToIndexMap) { diff --git a/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt b/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt index 0a047e11e3..17007d9e03 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/TransactionDSLInterpreter.kt @@ -35,7 +35,7 @@ interface TransactionDSLInterpreter : Verifies, OutputStateLookup { * @param encumbrance The position of the encumbrance state. * @param contractState The state itself. */ - fun _output(label: String?, notary: Party, encumbrance: Int?, contractState: ContractState) + fun _output(label: String?, notary: Party.Full, encumbrance: Int?, contractState: ContractState) /** * Adds an [Attachment] reference to the transaction. @@ -90,7 +90,7 @@ class TransactionDSL(val interpreter: T) : Tr * @see TransactionDSLInterpreter._output */ @JvmOverloads - fun output(label: String? = null, notary: Party = DUMMY_NOTARY, encumbrance: Int? = null, contractStateClosure: () -> ContractState) = + fun output(label: String? = null, notary: Party.Full = DUMMY_NOTARY, encumbrance: Int? = null, contractStateClosure: () -> ContractState) = _output(label, notary, encumbrance, contractStateClosure()) /** * @see TransactionDSLInterpreter._output diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt index a961f264a1..7d8aaff770 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockNetworkMapCache.kt @@ -19,8 +19,8 @@ class MockNetworkMapCache() : InMemoryNetworkMapCache() { data class MockAddress(val id: String): SingleMessageRecipient init { - val mockNodeA = NodeInfo(MockAddress("bankC:8080"), Party("Bank C", DummyPublicKey("Bank C"))) - val mockNodeB = NodeInfo(MockAddress("bankD:8080"), Party("Bank D", DummyPublicKey("Bank D"))) + val mockNodeA = NodeInfo(MockAddress("bankC:8080"), Party.Full("Bank C", DummyPublicKey("Bank C"))) + val mockNodeB = NodeInfo(MockAddress("bankD:8080"), Party.Full("Bank D", DummyPublicKey("Bank D"))) registeredNodes[mockNodeA.legalIdentity] = mockNodeA registeredNodes[mockNodeB.legalIdentity] = mockNodeB runWithoutMapService() @@ -40,7 +40,7 @@ class MockNetworkMapCache() : InMemoryNetworkMapCache() { * not a change being received. */ @VisibleForTesting - fun deleteRegistration(legalIdentity: Party) : Boolean { + fun deleteRegistration(legalIdentity: Party.Full) : Boolean { return registeredNodes.remove(legalIdentity) != null } } diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt index 89d05e3626..032ffef3b7 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -63,7 +63,7 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false, // A unique identifier for this network to segregate databases with the same nodeID but different networks. private val networkId = random63BitValue() - val identities = ArrayList() + val identities = ArrayList() private val _nodes = ArrayList() /** A read only view of the current set of executing nodes. */ @@ -174,7 +174,7 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false, val override = overrideServices[it.info] if (override != null) { // TODO: Store the key - ServiceEntry(it.info, Party(it.identity.name, override.public)) + ServiceEntry(it.info, Party.Full(it.identity.name, override.public)) } else { it } diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt b/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt index 97607e55a4..7b4291db52 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/MockServices.kt @@ -61,20 +61,20 @@ open class MockServices(val key: KeyPair = generateKeyPair()) : ServiceHub { override val networkMapCache: NetworkMapCache get() = throw UnsupportedOperationException() override val clock: Clock get() = throw UnsupportedOperationException() override val schedulerService: SchedulerService get() = throw UnsupportedOperationException() - override val myInfo: NodeInfo get() = NodeInfo(object : SingleMessageRecipient {}, Party("MegaCorp", key.public.composite)) + override val myInfo: NodeInfo get() = NodeInfo(object : SingleMessageRecipient {}, Party.Full("MegaCorp", key.public.composite)) } @ThreadSafe -class MockIdentityService(val identities: List) : IdentityService, SingletonSerializeAsToken() { - private val keyToParties: Map +class MockIdentityService(val identities: List) : IdentityService, SingletonSerializeAsToken() { + private val keyToParties: Map get() = synchronized(identities) { identities.associateBy { it.owningKey } } - private val nameToParties: Map + private val nameToParties: Map get() = synchronized(identities) { identities.associateBy { it.name } } - override fun registerIdentity(party: Party) { throw UnsupportedOperationException() } - override fun getAllIdentities(): Iterable = ArrayList(keyToParties.values) - override fun partyFromKey(key: CompositeKey): Party? = keyToParties[key] - override fun partyFromName(name: String): Party? = nameToParties[name] + override fun registerIdentity(party: Party.Full) { throw UnsupportedOperationException() } + override fun getAllIdentities(): Iterable = ArrayList(keyToParties.values) + override fun partyFromKey(key: CompositeKey): Party.Full? = keyToParties[key] + override fun partyFromName(name: String): Party.Full? = nameToParties[name] } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/plugin/ExplorerPlugin.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/plugin/ExplorerPlugin.kt index f49021d384..04f5d28313 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/plugin/ExplorerPlugin.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/plugin/ExplorerPlugin.kt @@ -10,7 +10,7 @@ import java.util.function.Function class ExplorerPlugin : CordaPluginRegistry() { // A list of flow that are required for this cordapp override val requiredFlows: Map> = - 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)) } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/Network.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/Network.kt index 4b6d92ee8c..52d2023494 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/Network.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/Network.kt @@ -169,7 +169,7 @@ class Network : CordaView() { private fun List.getParties() = map { it.participants.map { getModel().lookup(it) } }.flatten() - private fun fireBulletBetweenNodes(senderNode: Party, destNode: Party, startType: String, endType: String) { + private fun fireBulletBetweenNodes(senderNode: Party.Full, destNode: Party.Full, startType: String, endType: String) { allComponentMap[senderNode]?.let { senderNode -> allComponentMap[destNode]?.let { destNode -> val sender = senderNode.label.boundsInParentProperty().map { Point2D(it.width / 2 + it.minX, it.height / 4 - 2.5 + it.minY) } diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt index 477ccfab6d..84d7daebf2 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/CashViewer.kt @@ -84,7 +84,7 @@ class CashViewer : CordaView("Cash") { */ sealed class ViewerNode(val equivAmount: ObservableValue>, val states: ObservableList>) { - class IssuerNode(val issuer: Party, + class IssuerNode(val issuer: Party.Full, sumEquivAmount: ObservableValue>, states: ObservableList>) : ViewerNode(sumEquivAmount, states) diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/NewTransaction.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/NewTransaction.kt index 17661dfa81..3256f7c131 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/NewTransaction.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/views/cordapps/cash/NewTransaction.kt @@ -48,7 +48,7 @@ class NewTransaction : Fragment() { private val partyBLabel by fxid