mirror of
https://github.com/corda/corda.git
synced 2025-06-15 21:58:17 +00:00
Minor: auto-format of module: core
This commit is contained in:
@ -360,6 +360,7 @@ inline fun <reified T : ContractState> Iterable<StateAndRef<ContractState>>.filt
|
|||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
data class PartyAndReference(val party: AnonymousParty, val reference: OpaqueBytes) {
|
data class PartyAndReference(val party: AnonymousParty, val reference: OpaqueBytes) {
|
||||||
constructor(party: Party, reference: OpaqueBytes) : this(party.toAnonymous(), reference)
|
constructor(party: Party, reference: OpaqueBytes) : this(party.toAnonymous(), reference)
|
||||||
|
|
||||||
override fun toString() = "${party}$reference"
|
override fun toString() = "${party}$reference"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ sealed class TransactionVerificationException(val tx: LedgerTransaction, cause:
|
|||||||
class SignersMissing(tx: LedgerTransaction, val missing: List<CompositeKey>) : TransactionVerificationException(tx, null) {
|
class SignersMissing(tx: LedgerTransaction, val missing: List<CompositeKey>) : TransactionVerificationException(tx, null) {
|
||||||
override fun toString(): String = "Signers missing: ${missing.joinToString()}"
|
override fun toString(): String = "Signers missing: ${missing.joinToString()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
class DuplicateInputStates(tx: LedgerTransaction, val duplicates: Set<StateRef>) : TransactionVerificationException(tx, null) {
|
class DuplicateInputStates(tx: LedgerTransaction, val duplicates: Set<StateRef>) : TransactionVerificationException(tx, null) {
|
||||||
override fun toString(): String = "Duplicate inputs: ${duplicates.joinToString()}"
|
override fun toString(): String = "Duplicate inputs: ${duplicates.joinToString()}"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ abstract class AbstractParty(val owningKey: CompositeKey) {
|
|||||||
|
|
||||||
/** Anonymised parties do not include any detail apart from owning key, so equality is dependent solely on the key */
|
/** 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 AbstractParty && this.owningKey == other.owningKey
|
override fun equals(other: Any?): Boolean = other is AbstractParty && this.owningKey == other.owningKey
|
||||||
|
|
||||||
override fun hashCode(): Int = owningKey.hashCode()
|
override fun hashCode(): Int = owningKey.hashCode()
|
||||||
abstract fun toAnonymous(): AnonymousParty
|
abstract fun toAnonymous(): AnonymousParty
|
||||||
abstract fun nameOrNull(): String?
|
abstract fun nameOrNull(): String?
|
||||||
|
@ -12,7 +12,10 @@ import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable
|
|||||||
import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec
|
import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec
|
||||||
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec
|
import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.security.*
|
import java.security.KeyPair
|
||||||
|
import java.security.PrivateKey
|
||||||
|
import java.security.PublicKey
|
||||||
|
import java.security.SignatureException
|
||||||
|
|
||||||
/** A wrapper around a digital signature. */
|
/** A wrapper around a digital signature. */
|
||||||
@CordaSerializable
|
@CordaSerializable
|
||||||
|
@ -25,6 +25,7 @@ import java.security.PublicKey
|
|||||||
class Party(val name: String, owningKey: CompositeKey) : AbstractParty(owningKey) {
|
class Party(val name: String, owningKey: CompositeKey) : AbstractParty(owningKey) {
|
||||||
/** A helper constructor that converts the given [PublicKey] in to a [CompositeKey] with a single node */
|
/** 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)
|
constructor(name: String, owningKey: PublicKey) : this(name, owningKey.composite)
|
||||||
|
|
||||||
override fun toAnonymous(): AnonymousParty = AnonymousParty(owningKey)
|
override fun toAnonymous(): AnonymousParty = AnonymousParty(owningKey)
|
||||||
override fun toString() = "${owningKey.toBase58String()} (${name})"
|
override fun toString() = "${owningKey.toBase58String()} (${name})"
|
||||||
override fun nameOrNull(): String? = name
|
override fun nameOrNull(): String? = name
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.corda.core.crypto
|
package net.corda.core.crypto
|
||||||
|
|
||||||
import java.security.*
|
import java.security.KeyFactory
|
||||||
|
import java.security.KeyPairGeneratorSpi
|
||||||
|
import java.security.Signature
|
||||||
import java.security.spec.AlgorithmParameterSpec
|
import java.security.spec.AlgorithmParameterSpec
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package net.corda.core.crypto
|
package net.corda.core.crypto
|
||||||
|
|
||||||
import net.corda.core.serialization.opaque
|
|
||||||
import java.security.InvalidKeyException
|
import java.security.InvalidKeyException
|
||||||
import java.security.PublicKey
|
|
||||||
import java.security.SignatureException
|
import java.security.SignatureException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,11 +23,10 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequest
|
|||||||
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder
|
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder
|
||||||
import org.bouncycastle.util.IPAddress
|
import org.bouncycastle.util.IPAddress
|
||||||
import org.bouncycastle.util.io.pem.PemReader
|
import org.bouncycastle.util.io.pem.PemReader
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.io.InputStream
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.io.InputStream
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
@ -196,7 +196,9 @@ abstract class FlowLogic<out T> {
|
|||||||
*/
|
*/
|
||||||
var stateMachine: FlowStateMachine<*>
|
var stateMachine: FlowStateMachine<*>
|
||||||
get() = _stateMachine ?: throw IllegalStateException("This can only be done after the flow has been started.")
|
get() = _stateMachine ?: throw IllegalStateException("This can only be done after the flow has been started.")
|
||||||
set(value) { _stateMachine = value }
|
set(value) {
|
||||||
|
_stateMachine = value
|
||||||
|
}
|
||||||
|
|
||||||
// This points to the outermost flow and is changed when a subflow is invoked.
|
// This points to the outermost flow and is changed when a subflow is invoked.
|
||||||
private var sessionFlow: FlowLogic<*> = this
|
private var sessionFlow: FlowLogic<*> = this
|
||||||
|
@ -13,6 +13,7 @@ sealed class PartyInfo {
|
|||||||
data class Node(val node: NodeInfo) : PartyInfo() {
|
data class Node(val node: NodeInfo) : PartyInfo() {
|
||||||
override val party get() = node.legalIdentity
|
override val party get() = node.legalIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Service(val service: ServiceEntry) : PartyInfo() {
|
data class Service(val service: ServiceEntry) : PartyInfo() {
|
||||||
override val party get() = service.identity
|
override val party get() = service.identity
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package net.corda.core.schemas.requery.converters
|
package net.corda.core.schemas.requery.converters
|
||||||
|
|
||||||
import io.requery.Converter
|
import io.requery.Converter
|
||||||
|
import java.sql.Timestamp
|
||||||
import java.sql.*
|
import java.time.Instant
|
||||||
import java.time.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from a [Instant] to a [java.sql.Timestamp] for Java 8. Note that
|
* Converts from a [Instant] to a [java.sql.Timestamp] for Java 8. Note that
|
||||||
@ -12,19 +11,29 @@ import java.time.*
|
|||||||
*/
|
*/
|
||||||
class InstantConverter : Converter<Instant, Timestamp> {
|
class InstantConverter : Converter<Instant, Timestamp> {
|
||||||
|
|
||||||
override fun getMappedType(): Class<Instant> { return Instant::class.java }
|
override fun getMappedType(): Class<Instant> {
|
||||||
|
return Instant::class.java
|
||||||
|
}
|
||||||
|
|
||||||
override fun getPersistedType(): Class<Timestamp> { return Timestamp::class.java }
|
override fun getPersistedType(): Class<Timestamp> {
|
||||||
|
return Timestamp::class.java
|
||||||
|
}
|
||||||
|
|
||||||
override fun getPersistedSize(): Int? { return null }
|
override fun getPersistedSize(): Int? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
override fun convertToPersisted(value: Instant?): Timestamp? {
|
override fun convertToPersisted(value: Instant?): Timestamp? {
|
||||||
if (value == null) { return null }
|
if (value == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return Timestamp.from(value)
|
return Timestamp.from(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?): Instant? {
|
override fun convertToMapped(type: Class<out Instant>, value: Timestamp?): Instant? {
|
||||||
if (value == null) { return null }
|
if (value == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return value.toInstant()
|
return value.toInstant()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,20 +9,30 @@ import net.corda.core.crypto.SecureHash
|
|||||||
*/
|
*/
|
||||||
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
|
class StateRefConverter : Converter<StateRef, Pair<String, Int>> {
|
||||||
|
|
||||||
override fun getMappedType(): Class<StateRef> { return StateRef::class.java }
|
override fun getMappedType(): Class<StateRef> {
|
||||||
|
return StateRef::class.java
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun getPersistedType(): Class<Pair<String,Int>> { return Pair::class.java as Class<Pair<String,Int>> }
|
override fun getPersistedType(): Class<Pair<String, Int>> {
|
||||||
|
return Pair::class.java as Class<Pair<String, Int>>
|
||||||
|
}
|
||||||
|
|
||||||
override fun getPersistedSize(): Int? { return null }
|
override fun getPersistedSize(): Int? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
override fun convertToPersisted(value: StateRef?): Pair<String, Int>? {
|
override fun convertToPersisted(value: StateRef?): Pair<String, Int>? {
|
||||||
if (value == null) { return null }
|
if (value == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return Pair(value.txhash.toString(), value.index)
|
return Pair(value.txhash.toString(), value.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?): StateRef? {
|
override fun convertToMapped(type: Class<out StateRef>, value: Pair<String, Int>?): StateRef? {
|
||||||
if (value == null) { return null }
|
if (value == null) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return StateRef(SecureHash.parse(value.first), value.second)
|
return StateRef(SecureHash.parse(value.first), value.second)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,8 @@
|
|||||||
package net.corda.core.schemas.requery.converters
|
package net.corda.core.schemas.requery.converters
|
||||||
|
|
||||||
import io.requery.Converter
|
|
||||||
import io.requery.converter.EnumOrdinalConverter
|
import io.requery.converter.EnumOrdinalConverter
|
||||||
import io.requery.sql.Mapping
|
|
||||||
import net.corda.core.contracts.ContractState
|
|
||||||
import net.corda.core.node.services.Vault
|
import net.corda.core.node.services.Vault
|
||||||
|
|
||||||
import java.sql.*
|
|
||||||
import java.time.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converter which persists a [Vault.StateStatus] enum using its enum ordinal representation
|
* Converter which persists a [Vault.StateStatus] enum using its enum ordinal representation
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,6 @@ import net.corda.core.serialization.p2PKryo
|
|||||||
import net.corda.core.serialization.serialize
|
import net.corda.core.serialization.serialize
|
||||||
import net.corda.core.utilities.Emoji
|
import net.corda.core.utilities.Emoji
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A transaction ready for serialisation, without any signatures attached. A WireTransaction is usually wrapped
|
* A transaction ready for serialisation, without any signatures attached. A WireTransaction is usually wrapped
|
||||||
|
@ -41,6 +41,7 @@ class FinalityFlow(val transactions: Iterable<SignedTransaction>,
|
|||||||
object NOTARISING : ProgressTracker.Step("Requesting signature by notary service") {
|
object NOTARISING : ProgressTracker.Step("Requesting signature by notary service") {
|
||||||
override fun childProgressTracker() = NotaryFlow.Client.tracker()
|
override fun childProgressTracker() = NotaryFlow.Client.tracker()
|
||||||
}
|
}
|
||||||
|
|
||||||
object BROADCASTING : ProgressTracker.Step("Broadcasting transaction to participants")
|
object BROADCASTING : ProgressTracker.Step("Broadcasting transaction to participants")
|
||||||
|
|
||||||
// TODO: Make all tracker() methods @JvmStatic
|
// TODO: Make all tracker() methods @JvmStatic
|
||||||
@ -90,6 +91,7 @@ class FinalityFlow(val transactions: Iterable<SignedTransaction>,
|
|||||||
return needsNotarisation && hasNoNotarySignature(stx)
|
return needsNotarisation && hasNoNotarySignature(stx)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasNoNotarySignature(stx: SignedTransaction): Boolean {
|
private fun hasNoNotarySignature(stx: SignedTransaction): Boolean {
|
||||||
val notaryKey = stx.tx.notary?.owningKey
|
val notaryKey = stx.tx.notary?.owningKey
|
||||||
val signers = stx.sigs.map { it.by }.toSet()
|
val signers = stx.sigs.map { it.by }.toSet()
|
||||||
|
@ -5,7 +5,6 @@ import net.corda.core.crypto.CompositeKey
|
|||||||
import net.corda.core.crypto.Party
|
import net.corda.core.crypto.Party
|
||||||
import net.corda.core.crypto.composite
|
import net.corda.core.crypto.composite
|
||||||
import net.corda.core.flows.FlowLogic
|
import net.corda.core.flows.FlowLogic
|
||||||
import net.corda.core.node.ServiceHub
|
|
||||||
import net.corda.core.serialization.CordaSerializable
|
import net.corda.core.serialization.CordaSerializable
|
||||||
import net.corda.core.utilities.unwrap
|
import net.corda.core.utilities.unwrap
|
||||||
import java.security.cert.Certificate
|
import java.security.cert.Certificate
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package net.corda.core.flows;
|
package net.corda.core.flows;
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.Suspendable;
|
import co.paralleluniverse.fibers.*;
|
||||||
import net.corda.core.crypto.Party;
|
import net.corda.core.crypto.*;
|
||||||
import net.corda.testing.node.MockNetwork;
|
import net.corda.testing.node.*;
|
||||||
import org.junit.After;
|
import org.junit.*;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
import static org.assertj.core.api.AssertionsForClassTypes.*;
|
||||||
|
|
||||||
public class FlowsInJavaTest {
|
public class FlowsInJavaTest {
|
||||||
|
|
||||||
|
@ -17,9 +17,13 @@ import org.junit.Assert.assertNotEquals
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.security.KeyFactory
|
import java.security.KeyFactory
|
||||||
import java.security.Security
|
import java.security.Security
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec
|
||||||
|
import java.security.spec.X509EncodedKeySpec
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.security.spec.*
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.*
|
import kotlin.test.assertNotNull
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
import kotlin.test.fail
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run tests for cryptographic algorithms
|
* Run tests for cryptographic algorithms
|
||||||
|
@ -27,6 +27,7 @@ class EncodingUtilsTest {
|
|||||||
assertEquals("", emptyByteArray.toBase64())
|
assertEquals("", emptyByteArray.toBase64())
|
||||||
assertEquals("", emptyByteArray.toHex())
|
assertEquals("", emptyByteArray.toHex())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `encoding 7 zero bytes`() {
|
fun `encoding 7 zero bytes`() {
|
||||||
val sevenZeroByteArray = ByteArray(7)
|
val sevenZeroByteArray = ByteArray(7)
|
||||||
|
@ -103,6 +103,7 @@ class PartialMerkleTreeTest {
|
|||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val mt = testTx.buildFilteredTransaction(::filtering)
|
val mt = testTx.buildFilteredTransaction(::filtering)
|
||||||
val leaves = mt.filteredLeaves
|
val leaves = mt.filteredLeaves
|
||||||
val d = WireTransaction.deserialize(testTx.serialized)
|
val d = WireTransaction.deserialize(testTx.serialized)
|
||||||
|
@ -7,7 +7,6 @@ import java.security.Security
|
|||||||
import java.security.SignatureException
|
import java.security.SignatureException
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import kotlin.test.fail
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Digital signature MetaData tests
|
* Digital signature MetaData tests
|
||||||
|
@ -12,7 +12,6 @@ import net.corda.core.utilities.DUMMY_NOTARY
|
|||||||
import net.corda.testing.MEGA_CORP
|
import net.corda.testing.MEGA_CORP
|
||||||
import net.corda.testing.node.MockAttachmentStorage
|
import net.corda.testing.node.MockAttachmentStorage
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.junit.After
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.Kryo
|
|||||||
import com.google.common.primitives.Ints
|
import com.google.common.primitives.Ints
|
||||||
import net.corda.core.crypto.*
|
import net.corda.core.crypto.*
|
||||||
import net.corda.core.messaging.Ack
|
import net.corda.core.messaging.Ack
|
||||||
|
import net.corda.node.services.persistence.NodeAttachmentService
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||||
@ -11,14 +12,13 @@ import org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.security.Security
|
import java.security.Security
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import net.corda.node.services.persistence.NodeAttachmentService
|
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
|
|
||||||
class KryoTests {
|
class KryoTests {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user