Replace Party with Party.Full

Replace Party with Party.Full as an interim step to introducing the Party.Anonymised class.

Signed-off-by: Ross Nicoll <ross.nicoll@r3.com>
This commit is contained in:
Ross Nicoll
2017-02-01 11:13:50 +00:00
parent 3572b78372
commit 1b86ddfd6e
137 changed files with 415 additions and 411 deletions

View File

@ -65,7 +65,7 @@ inline fun <R> requireThat(body: Requirements.() -> R) = Requirements.body()
/** Filters the command list by type, party and public key all at once. */
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.select(signer: CompositeKey? = null,
party: Party? = null) =
party: Party.Full? = null) =
filter { it.value is T }.
filter { if (signer == null) true else signer in it.signers }.
filter { if (party == null) true else party in it.signingParties }.
@ -75,7 +75,7 @@ inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>
/** Filters the command list by type, parties and public keys all at once. */
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.select(signers: Collection<CompositeKey>?,
parties: Collection<Party>?) =
parties: Collection<Party.Full>?) =
filter { it.value is T }.
filter { if (signers == null) true else it.signers.containsAll(signers) }.
filter { if (parties == null) true else it.signingParties.containsAll(parties) }.

View File

@ -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))
}

View File

@ -124,7 +124,7 @@ data class TransactionState<out T : ContractState> @JvmOverloads constructor(
/** The custom contract state */
val data: T,
/** Identity of the notary that ensures the state is not used as an input to a transaction more than once */
val notary: Party,
val notary: Party.Full,
/**
* All contract states may be _encumbered_ by up to one other state.
*
@ -148,13 +148,13 @@ data class TransactionState<out T : ContractState> @JvmOverloads constructor(
* Copies the underlying state, replacing the notary field with the new value.
* To replace the notary, we need an approval (signature) from _all_ participants of the [ContractState].
*/
fun withNotary(newNotary: Party) = TransactionState(this.data, newNotary, encumbrance)
fun withNotary(newNotary: Party.Full) = TransactionState(this.data, newNotary, encumbrance)
}
/** Wraps the [ContractState] in a [TransactionState] object */
infix fun <T : ContractState> T.`with notary`(newNotary: Party) = withNotary(newNotary)
infix fun <T : ContractState> T.`with notary`(newNotary: Party.Full) = withNotary(newNotary)
infix fun <T : ContractState> T.withNotary(newNotary: Party) = TransactionState(this, newNotary)
infix fun <T : ContractState> T.withNotary(newNotary: Party.Full) = TransactionState(this, newNotary)
/**
* Marker interface for data classes that represent the issuance state for a contract. These are intended as templates
@ -280,7 +280,7 @@ interface DealState : LinearState {
* Exposes the Parties involved in a generic way.
*
* Appears to duplicate [participants] a property of [ContractState]. However [participants] only holds public keys.
* Currently we need to hard code Party objects into [ContractState]s. [Party] objects are a wrapper for public
* Currently we need to hard code Party objects into [ContractState]s. [Party.Full] objects are a wrapper for public
* keys which also contain some identity information about the public key owner. You can keep track of individual
* parties by adding a property for each one to the state, or you can append parties to the [parties] list if you
* are implementing [DealState]. We need to do this as identity management in Corda is currently incomplete,
@ -289,7 +289,7 @@ interface DealState : LinearState {
* separate process exchange certificates to ascertain identities. Thus decoupling identities from
* [ContractState]s.
* */
val parties: List<Party>
val parties: List<Party.Full>
/**
* Generate a partial transaction representing an agreement (command) to this deal, allowing a general
@ -300,7 +300,7 @@ interface DealState : LinearState {
* TODO: This should more likely be a method on the Contract (on a common interface) and the changes to reference a
* Contract instance from a ContractState are imminent, at which point we can move this out of here.
*/
fun generateAgreement(notary: Party): TransactionBuilder
fun generateAgreement(notary: Party.Full): TransactionBuilder
}
/**
@ -349,7 +349,7 @@ inline fun <reified T : ContractState> Iterable<StateAndRef<ContractState>>.filt
* Reference to something being stored or issued by a party e.g. in a vault or (more likely) on their normal
* ledger. The reference is intended to be encrypted so it's meaningless to anyone other than the party.
*/
data class PartyAndReference(val party: Party, val reference: OpaqueBytes) {
data class PartyAndReference(val party: Party.Full, val reference: OpaqueBytes) {
override fun toString() = "${party.name}$reference"
}
@ -400,7 +400,7 @@ interface NetCommand : CommandData {
data class AuthenticatedObject<out T : Any>(
val signers: List<CompositeKey>,
/** If any public keys were recognised, the looked up institutions are available here */
val signingParties: List<Party>,
val signingParties: List<Party.Full>,
val value: T
)

View File

@ -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)

View File

@ -17,7 +17,7 @@ data class TransactionForContract(val inputs: List<ContractState>,
val attachments: List<Attachment>,
val commands: List<AuthenticatedObject<CommandData>>,
val origHash: SecureHash,
val inputNotary: Party? = null,
val inputNotary: Party.Full? = null,
val timestamp: Timestamp? = null) {
override fun hashCode() = origHash.hashCode()
override fun equals(other: Any?) = other is TransactionForContract && other.origHash == origHash
@ -102,7 +102,7 @@ sealed class TransactionVerificationException(val tx: LedgerTransaction, cause:
}
class InvalidNotaryChange(tx: LedgerTransaction) : TransactionVerificationException(tx, null)
class NotaryChangeInWrongTransactionType(tx: LedgerTransaction, val outputNotary: Party) : TransactionVerificationException(tx, null) {
class NotaryChangeInWrongTransactionType(tx: LedgerTransaction, val outputNotary: Party.Full) : TransactionVerificationException(tx, null) {
override fun toString(): String = "Found unexpected notary change in transaction. Tx notary: ${tx.notary}, found: ${outputNotary}"
}

View File

@ -34,7 +34,7 @@ open class DigitalSignature(bits: ByteArray) : OpaqueBytes(bits) {
}
// TODO: consider removing this as whoever needs to identify the signer should be able to derive it from the public key
class LegallyIdentifiable(val signer: Party, bits: ByteArray) : WithKey(signer.owningKey.singleKey, bits)
class LegallyIdentifiable(val signer: Party.Full, bits: ByteArray) : WithKey(signer.owningKey.singleKey, bits)
}
object NullPublicKey : PublicKey, Comparable<PublicKey> {
@ -81,8 +81,8 @@ fun PublicKey.toBase58String() = Base58.encode((this as EdDSAPublicKey).abyte)
fun KeyPair.signWithECDSA(bytesToSign: ByteArray) = private.signWithECDSA(bytesToSign, public)
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes) = private.signWithECDSA(bytesToSign.bytes, public)
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes, party: Party) = signWithECDSA(bytesToSign.bytes, party)
fun KeyPair.signWithECDSA(bytesToSign: ByteArray, party: Party): DigitalSignature.LegallyIdentifiable {
fun KeyPair.signWithECDSA(bytesToSign: OpaqueBytes, party: Party.Full) = signWithECDSA(bytesToSign.bytes, party)
fun KeyPair.signWithECDSA(bytesToSign: ByteArray, party: Party.Full): DigitalSignature.LegallyIdentifiable {
check(public in party.owningKey.keys)
val sig = signWithECDSA(bytesToSign)
return DigitalSignature.LegallyIdentifiable(party, sig.bytes)

View File

@ -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))
}
}

View File

@ -44,7 +44,7 @@ abstract class FlowLogic<out T> {
* other side. The default implementation returns the class object of this FlowLogic, but any [Class] instance
* will do as long as the other side registers with it.
*/
open fun getCounterpartyMarker(party: Party): Class<*> = javaClass
open fun getCounterpartyMarker(party: Party.Full): Class<*> = javaClass
/**
* Serializes and queues the given [payload] object for sending to the [otherParty]. Suspends until a response
@ -59,7 +59,7 @@ abstract class FlowLogic<out T> {
*
* @returns an [UntrustworthyData] wrapper around the received object.
*/
inline fun <reified R : Any> sendAndReceive(otherParty: Party, payload: Any) = sendAndReceive(R::class.java, otherParty, payload)
inline fun <reified R : Any> sendAndReceive(otherParty: Party.Full, payload: Any) = sendAndReceive(R::class.java, otherParty, payload)
/**
* Serializes and queues the given [payload] object for sending to the [otherParty]. Suspends until a response
@ -73,7 +73,7 @@ abstract class FlowLogic<out T> {
* @returns an [UntrustworthyData] wrapper around the received object.
*/
@Suspendable
open fun <R : Any> sendAndReceive(receiveType: Class<R>, otherParty: Party, payload: Any): UntrustworthyData<R> {
open fun <R : Any> sendAndReceive(receiveType: Class<R>, otherParty: Party.Full, payload: Any): UntrustworthyData<R> {
return stateMachine.sendAndReceive(receiveType, otherParty, payload, sessionFlow)
}
@ -84,7 +84,7 @@ abstract class FlowLogic<out T> {
* verified for consistency and that all expectations are satisfied, as a malicious peer may send you subtly
* corrupted data in order to exploit your code.
*/
inline fun <reified R : Any> receive(otherParty: Party): UntrustworthyData<R> = receive(R::class.java, otherParty)
inline fun <reified R : Any> receive(otherParty: Party.Full): UntrustworthyData<R> = receive(R::class.java, otherParty)
/**
* Suspends until the specified [otherParty] sends us a message of type [receiveType].
@ -96,7 +96,7 @@ abstract class FlowLogic<out T> {
* @returns an [UntrustworthyData] wrapper around the received object.
*/
@Suspendable
open fun <R : Any> receive(receiveType: Class<R>, otherParty: Party): UntrustworthyData<R> {
open fun <R : Any> receive(receiveType: Class<R>, otherParty: Party.Full): UntrustworthyData<R> {
return stateMachine.receive(receiveType, otherParty, sessionFlow)
}
@ -108,7 +108,7 @@ abstract class FlowLogic<out T> {
* network's event horizon time.
*/
@Suspendable
open fun send(otherParty: Party, payload: Any) = stateMachine.send(otherParty, payload, sessionFlow)
open fun send(otherParty: Party.Full, payload: Any) = stateMachine.send(otherParty, payload, sessionFlow)
/**
* Invokes the given subflow. This function returns once the subflow completes successfully with the result

View File

@ -25,15 +25,15 @@ data class StateMachineRunId private constructor(val uuid: UUID) {
interface FlowStateMachine<R> {
@Suspendable
fun <T : Any> sendAndReceive(receiveType: Class<T>,
otherParty: Party,
otherParty: Party.Full,
payload: Any,
sessionFlow: FlowLogic<*>): UntrustworthyData<T>
@Suspendable
fun <T : Any> receive(receiveType: Class<T>, otherParty: Party, sessionFlow: FlowLogic<*>): UntrustworthyData<T>
fun <T : Any> receive(receiveType: Class<T>, otherParty: Party.Full, sessionFlow: FlowLogic<*>): UntrustworthyData<T>
@Suspendable
fun send(otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>)
fun send(otherParty: Party.Full, payload: Any, sessionFlow: FlowLogic<*>)
val serviceHub: ServiceHub
val logger: Logger

View File

@ -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?
}
/**

View File

@ -9,19 +9,19 @@ import net.corda.core.node.services.ServiceType
* Information for an advertised service including the service specific identity information.
* The identity can be used in flows and is distinct from the Node's legalIdentity
*/
data class ServiceEntry(val info: ServiceInfo, val identity: Party)
data class ServiceEntry(val info: ServiceInfo, val identity: Party.Full)
/**
* Info about a network node that acts on behalf of some form of contract party.
*/
data class NodeInfo(val address: SingleMessageRecipient,
val legalIdentity: Party,
val legalIdentity: Party.Full,
var advertisedServices: List<ServiceEntry> = emptyList(),
val physicalLocation: PhysicalLocation? = null) {
init {
require(advertisedServices.none { it.identity == legalIdentity }) { "Service identities must be different from node legal identity" }
}
val notaryIdentity: Party get() = advertisedServices.single { it.info.type.isNotary() }.identity
fun serviceIdentities(type: ServiceType): List<Party> = advertisedServices.filter { it.info.type.isSubTypeOf(type) }.map { it.identity }
val notaryIdentity: Party.Full get() = advertisedServices.single { it.info.type.isNotary() }.identity
fun serviceIdentities(type: ServiceType): List<Party.Full> = advertisedServices.filter { it.info.type.isSubTypeOf(type) }.map { it.identity }
}

View File

@ -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<*>)?
}

View File

@ -4,22 +4,22 @@ import net.corda.core.crypto.CompositeKey
import net.corda.core.crypto.Party
/**
* An identity service maintains an bidirectional map of [Party]s to their associated public keys and thus supports
* An identity service maintains an bidirectional map of [Party.Full]s to their associated public keys and thus supports
* lookup of a party given its key. This is obviously very incomplete and does not reflect everything a real identity
* service would provide.
*/
interface IdentityService {
fun registerIdentity(party: Party)
fun registerIdentity(party: Party.Full)
/**
* Get all identities known to the service. This is expensive, and [partyFromKey] or [partyFromName] should be
* used in preference where possible.
*/
fun getAllIdentities(): Iterable<Party>
fun getAllIdentities(): Iterable<Party.Full>
// There is no method for removing identities, as once we are made aware of a Party we want to keep track of them
// indefinitely. It may be that in the long term we need to drop or archive very old Party information for space,
// but for now this is not supported.
fun partyFromKey(key: CompositeKey): Party?
fun partyFromName(name: String): Party?
fun partyFromKey(key: CompositeKey): Party.Full?
fun partyFromName(name: String): Party.Full?
}

View File

@ -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

View File

@ -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
}

View File

@ -186,11 +186,11 @@ interface VaultService {
fun generateSpend(tx: TransactionBuilder,
amount: Amount<Currency>,
to: CompositeKey,
onlyFromParties: Set<Party>? = null): Pair<TransactionBuilder, List<CompositeKey>>
onlyFromParties: Set<Party.Full>? = null): Pair<TransactionBuilder, List<CompositeKey>>
}
inline fun <reified T : LinearState> VaultService.linearHeadsOfType() = linearHeadsOfType_(T::class.java)
inline fun <reified T : DealState> VaultService.dealsWith(party: Party) = linearHeadsOfType<T>().values.filter {
inline fun <reified T : DealState> VaultService.dealsWith(party: Party.Full) = linearHeadsOfType<T>().values.filter {
// TODO: Replace name comparison with full party comparison (keys are currenty not equal)
it.state.data.parties.any { it.name == party.name }
}

View File

@ -12,7 +12,7 @@ import net.corda.core.crypto.SecureHash
*/
interface UniquenessProvider {
/** Commits all input states of the given transaction */
fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party)
fun commit(states: List<StateRef>, txId: SecureHash, callerIdentity: Party.Full)
/** Specifies the consuming transaction for every conflicting state */
data class Conflict(val stateHistory: Map<StateRef, ConsumingTx>)
@ -26,7 +26,7 @@ interface UniquenessProvider {
* This allows a party to just submit invalid transactions with outputs it was aware of and
* find out where exactly they were spent.
*/
data class ConsumingTx(val id: SecureHash, val inputIndex: Int, val requestingParty: Party)
data class ConsumingTx(val id: SecureHash, val inputIndex: Int, val requestingParty: Party.Full)
}
class UniquenessException(val error: UniquenessProvider.Conflict) : Exception()

View File

@ -302,7 +302,7 @@ object WireTransactionSerializer : Serializer<WireTransaction>() {
kryo.useClassLoader(classLoader) {
val outputs = kryo.readClassAndObject(input) as List<TransactionState<ContractState>>
val commands = kryo.readClassAndObject(input) as List<Command>
val notary = kryo.readClassAndObject(input) as Party?
val notary = kryo.readClassAndObject(input) as Party.Full?
val signers = kryo.readClassAndObject(input) as List<CompositeKey>
val transactionType = kryo.readClassAndObject(input) as TransactionType
val timestamp = kryo.readClassAndObject(input) as Timestamp?
@ -430,7 +430,7 @@ fun createKryo(k: Kryo = Kryo()): Kryo {
addDefaultSerializer(SerializeAsToken::class.java, SerializeAsTokenSerializer<SerializeAsToken>())
// This is required to make all the unit tests pass
register(Party::class.java)
register(Party.Full::class.java)
// This ensures a NonEmptySetSerializer is constructed with an initial value.
register(NonEmptySet::class.java, NonEmptySetSerializer)

View File

@ -45,9 +45,9 @@ class CompositeKeyGenerator : Generator<CompositeKey>(CompositeKey::class.java)
}
}
class PartyGenerator : Generator<Party>(Party::class.java) {
override fun generate(random: SourceOfRandomness, status: GenerationStatus): Party {
return Party(StringGenerator().generate(random, status), CompositeKeyGenerator().generate(random, status))
class PartyGenerator : Generator<Party.Full>(Party.Full::class.java) {
override fun generate(random: SourceOfRandomness, status: GenerationStatus): Party.Full {
return Party.Full(StringGenerator().generate(random, status), CompositeKeyGenerator().generate(random, status))
}
}

View File

@ -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

View File

@ -26,7 +26,7 @@ class LedgerTransaction(
val attachments: List<Attachment>,
/** The hash of the original serialised WireTransaction. */
override val id: SecureHash,
notary: Party?,
notary: Party.Full?,
signers: List<CompositeKey>,
timestamp: Timestamp?,
type: TransactionType

View File

@ -26,7 +26,7 @@ import java.util.*
*/
open class TransactionBuilder(
protected val type: TransactionType = TransactionType.General(),
var notary: Party? = null,
var notary: Party.Full? = null,
protected val inputs: MutableList<StateRef> = arrayListOf(),
protected val attachments: MutableList<SecureHash> = arrayListOf(),
protected val outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
@ -160,7 +160,7 @@ open class TransactionBuilder(
}
@JvmOverloads
fun addOutputState(state: ContractState, notary: Party, encumbrance: Int? = null) = addOutputState(TransactionState(state, notary, encumbrance))
fun addOutputState(state: ContractState, notary: Party.Full, encumbrance: Int? = null) = addOutputState(TransactionState(state, notary, encumbrance))
/** A default notary must be specified during builder construction to use this method */
fun addOutputState(state: ContractState): Int {

View File

@ -29,7 +29,7 @@ class WireTransaction(
outputs: List<TransactionState<ContractState>>,
/** Ordered list of ([CommandData], [PublicKey]) pairs that instruct the contracts what to do. */
val commands: List<Command>,
notary: Party?,
notary: Party.Full?,
signers: List<CompositeKey>,
type: TransactionType,
timestamp: Timestamp?

View File

@ -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))

View File

@ -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)

View File

@ -84,7 +84,7 @@ abstract class AbstractStateReplacementFlow {
}
@Suspendable
private fun getParticipantSignature(party: Party, stx: SignedTransaction): DigitalSignature.WithKey {
private fun getParticipantSignature(party: Party.Full, stx: SignedTransaction): DigitalSignature.WithKey {
val proposal = Proposal(originalState.ref, modification, stx)
val response = sendAndReceive<DigitalSignature.WithKey>(party, proposal)
return response.unwrap {
@ -105,7 +105,7 @@ abstract class AbstractStateReplacementFlow {
}
}
abstract class Acceptor<in T>(val otherSide: Party,
abstract class Acceptor<in T>(val otherSide: Party.Full,
override val progressTracker: ProgressTracker = tracker()) : FlowLogic<Unit>() {
companion object {
object VERIFYING : ProgressTracker.Step("Verifying state replacement proposal")

View File

@ -16,7 +16,7 @@ import net.corda.core.transactions.SignedTransaction
* @return a list of participants who were successfully notified of the transaction.
*/
class BroadcastTransactionFlow(val notarisedTransaction: SignedTransaction,
val participants: Set<Party>) : FlowLogic<Unit>() {
val participants: Set<Party.Full>) : FlowLogic<Unit>() {
data class NotifyTxRequest(val tx: SignedTransaction)

View File

@ -12,7 +12,7 @@ import java.io.InputStream
* attachments are saved to local storage automatically.
*/
class FetchAttachmentsFlow(requests: Set<SecureHash>,
otherSide: Party) : FetchDataFlow<Attachment, ByteArray>(requests, otherSide) {
otherSide: Party.Full) : FetchDataFlow<Attachment, ByteArray>(requests, otherSide) {
override fun load(txid: SecureHash): Attachment? = serviceHub.storageService.attachments.openAttachment(txid)

View File

@ -29,7 +29,7 @@ import java.util.*
*/
abstract class FetchDataFlow<T : NamedByHash, in W : Any>(
protected val requests: Set<SecureHash>,
protected val otherSide: Party) : FlowLogic<FetchDataFlow.Result<T>>() {
protected val otherSide: Party.Full) : FlowLogic<FetchDataFlow.Result<T>>() {
class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : IllegalArgumentException()
class DownloadedVsRequestedSizeMismatch(val requested: Int, val got: Int) : IllegalArgumentException()

View File

@ -12,7 +12,7 @@ import net.corda.core.transactions.SignedTransaction
* results in a [FetchDataFlow.HashNotFound] exception. Note that returned transactions are not inserted into
* the database, because it's up to the caller to actually verify the transactions are valid.
*/
class FetchTransactionsFlow(requests: Set<SecureHash>, otherSide: Party) :
class FetchTransactionsFlow(requests: Set<SecureHash>, otherSide: Party.Full) :
FetchDataFlow<SignedTransaction, SignedTransaction>(requests, otherSide) {
override fun load(txid: SecureHash): SignedTransaction? = serviceHub.storageService.validatedTransactions.getTransaction(txid)

View File

@ -15,9 +15,9 @@ import net.corda.core.utilities.ProgressTracker
* @return a list of participants who were successfully notified of the transaction.
*/
class FinalityFlow(val transaction: SignedTransaction,
val participants: Set<Party>,
val participants: Set<Party.Full>,
override val progressTracker: ProgressTracker) : FlowLogic<Unit>() {
constructor(transaction: SignedTransaction, participants: Set<Party>) : this(transaction, participants, tracker())
constructor(transaction: SignedTransaction, participants: Set<Party.Full>) : this(transaction, participants, tracker())
companion object {
object NOTARISING : ProgressTracker.Step("Requesting signature by notary service")

View File

@ -22,8 +22,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
class Instigator<out T : ContractState>(
originalState: StateAndRef<T>,
newNotary: Party,
progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator<T, Party>(originalState, newNotary, progressTracker) {
newNotary: Party.Full,
progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Instigator<T, Party.Full>(originalState, newNotary, progressTracker) {
override fun assembleTx(): Pair<SignedTransaction, Iterable<CompositeKey>> {
val state = originalState.state
@ -88,8 +88,8 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
}
class Acceptor(otherSide: Party,
override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor<Party>(otherSide) {
class Acceptor(otherSide: Party.Full,
override val progressTracker: ProgressTracker = tracker()) : AbstractStateReplacementFlow.Acceptor<Party.Full>(otherSide) {
/**
* Check the notary change proposal.
@ -98,7 +98,7 @@ object NotaryChangeFlow : AbstractStateReplacementFlow() {
* and is also in a geographically convenient location we can just automatically approve the change.
* TODO: In more difficult cases this should call for human attention to manually verify and approve the proposal
*/
override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal<Party>): Unit {
override fun verifyProposal(proposal: AbstractStateReplacementFlow.Proposal<Party.Full>): Unit {
val state = proposal.stateRef
val proposedTx = proposal.stx.tx

View File

@ -35,7 +35,7 @@ object NotaryFlow {
fun tracker() = ProgressTracker(REQUESTING, VALIDATING)
}
lateinit var notaryParty: Party
lateinit var notaryParty: Party.Full
@Suspendable
@Throws(NotaryException::class)
@ -82,7 +82,7 @@ object NotaryFlow {
*
* TODO: the notary service should only be able to see timestamp commands and inputs
*/
open class Service(val otherSide: Party,
open class Service(val otherSide: Party.Full,
val timestampChecker: TimestampChecker,
val uniquenessProvider: UniquenessProvider) : FlowLogic<Unit>() {

View File

@ -29,7 +29,7 @@ import java.util.*
* The flow returns a list of verified [LedgerTransaction] objects, in a depth-first order.
*/
class ResolveTransactionsFlow(private val txHashes: Set<SecureHash>,
private val otherSide: Party) : FlowLogic<List<LedgerTransaction>>() {
private val otherSide: Party.Full) : FlowLogic<List<LedgerTransaction>>() {
companion object {
private fun dependencyIDs(wtx: WireTransaction) = wtx.inputs.map { it.txhash }.toSet()
@ -77,14 +77,14 @@ class ResolveTransactionsFlow(private val txHashes: Set<SecureHash>,
/**
* Resolve the full history of a transaction and verify it with its dependencies.
*/
constructor(stx: SignedTransaction, otherSide: Party) : this(stx.tx, otherSide) {
constructor(stx: SignedTransaction, otherSide: Party.Full) : this(stx.tx, otherSide) {
this.stx = stx
}
/**
* Resolve the full history of a transaction and verify it with its dependencies.
*/
constructor(wtx: WireTransaction, otherSide: Party) : this(dependencyIDs(wtx), otherSide) {
constructor(wtx: WireTransaction, otherSide: Party.Full) : this(dependencyIDs(wtx), otherSide) {
this.wtx = wtx
}

View File

@ -71,10 +71,10 @@ object TwoPartyDealFlow {
abstract val payload: Any
abstract val notaryNode: NodeInfo
abstract val otherParty: Party
abstract val otherParty: Party.Full
abstract val myKeyPair: KeyPair
override fun getCounterpartyMarker(party: Party): Class<*> {
override fun getCounterpartyMarker(party: Party.Full): Class<*> {
return if (serviceHub.networkMapCache.regulatorNodes.any { it.legalIdentity == party }) {
MarkerForBogusRegulatorFlow::class.java
} else {
@ -202,7 +202,7 @@ object TwoPartyDealFlow {
fun tracker() = ProgressTracker(RECEIVING, VERIFYING, SIGNING, SWAPPING_SIGNATURES, RECORDING)
}
abstract val otherParty: Party
abstract val otherParty: Party.Full
@Suspendable
override fun call(): SignedTransaction {
@ -263,13 +263,13 @@ object TwoPartyDealFlow {
}
data class AutoOffer(val notary: Party, val dealBeingOffered: DealState)
data class AutoOffer(val notary: Party.Full, val dealBeingOffered: DealState)
/**
* One side of the flow for inserting a pre-agreed deal.
*/
open class Instigator(override val otherParty: Party,
open class Instigator(override val otherParty: Party.Full,
override val payload: AutoOffer,
override val myKeyPair: KeyPair,
override val progressTracker: ProgressTracker = Primary.tracker()) : Primary() {
@ -281,7 +281,7 @@ object TwoPartyDealFlow {
/**
* One side of the flow for inserting a pre-agreed deal.
*/
open class Acceptor(override val otherParty: Party,
open class Acceptor(override val otherParty: Party.Full,
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<AutoOffer>() {
override fun validateHandshake(handshake: Handshake<AutoOffer>): Handshake<AutoOffer> {

View File

@ -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) {

View File

@ -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)))

View File

@ -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() {

View File

@ -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))
}