mirror of
https://github.com/corda/corda.git
synced 2024-12-24 07:06:44 +00:00
Remove type property from transactions
This commit is contained in:
parent
92a056f869
commit
59edd6f9ae
@ -12,6 +12,6 @@ sealed class TransactionType {
|
|||||||
object General : TransactionType() {
|
object General : TransactionType() {
|
||||||
/** Just uses the default [TransactionBuilder] with no special logic */
|
/** Just uses the default [TransactionBuilder] with no special logic */
|
||||||
@Deprecated("Use TransactionBuilder directly instead", ReplaceWith("TransactionBuilder()"))
|
@Deprecated("Use TransactionBuilder directly instead", ReplaceWith("TransactionBuilder()"))
|
||||||
class Builder(notary: Party?) : TransactionBuilder(General, notary)
|
class Builder(notary: Party?) : TransactionBuilder(notary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import net.corda.core.transactions.CoreTransaction
|
|||||||
import net.corda.core.transactions.NotaryChangeWireTransaction
|
import net.corda.core.transactions.NotaryChangeWireTransaction
|
||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
import net.corda.core.transactions.WireTransaction
|
import net.corda.core.transactions.WireTransaction
|
||||||
import net.corda.core.utilities.OpaqueBytes
|
|
||||||
import net.i2p.crypto.eddsa.EdDSAPrivateKey
|
import net.i2p.crypto.eddsa.EdDSAPrivateKey
|
||||||
import net.i2p.crypto.eddsa.EdDSAPublicKey
|
import net.i2p.crypto.eddsa.EdDSAPublicKey
|
||||||
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec
|
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec
|
||||||
@ -244,7 +243,6 @@ object WireTransactionSerializer : Serializer<WireTransaction>() {
|
|||||||
kryo.writeClassAndObject(output, obj.outputs)
|
kryo.writeClassAndObject(output, obj.outputs)
|
||||||
kryo.writeClassAndObject(output, obj.commands)
|
kryo.writeClassAndObject(output, obj.commands)
|
||||||
kryo.writeClassAndObject(output, obj.notary)
|
kryo.writeClassAndObject(output, obj.notary)
|
||||||
kryo.writeClassAndObject(output, obj.type)
|
|
||||||
kryo.writeClassAndObject(output, obj.timeWindow)
|
kryo.writeClassAndObject(output, obj.timeWindow)
|
||||||
kryo.writeClassAndObject(output, obj.privacySalt)
|
kryo.writeClassAndObject(output, obj.privacySalt)
|
||||||
}
|
}
|
||||||
@ -272,10 +270,9 @@ object WireTransactionSerializer : Serializer<WireTransaction>() {
|
|||||||
val outputs = kryo.readClassAndObject(input) as List<TransactionState<ContractState>>
|
val outputs = kryo.readClassAndObject(input) as List<TransactionState<ContractState>>
|
||||||
val commands = kryo.readClassAndObject(input) as List<Command<*>>
|
val commands = kryo.readClassAndObject(input) as List<Command<*>>
|
||||||
val notary = kryo.readClassAndObject(input) as Party?
|
val notary = kryo.readClassAndObject(input) as Party?
|
||||||
val transactionType = kryo.readClassAndObject(input) as TransactionType
|
|
||||||
val timeWindow = kryo.readClassAndObject(input) as TimeWindow?
|
val timeWindow = kryo.readClassAndObject(input) as TimeWindow?
|
||||||
val privacySalt = kryo.readClassAndObject(input) as PrivacySalt
|
val privacySalt = kryo.readClassAndObject(input) as PrivacySalt
|
||||||
return WireTransaction(inputs, attachmentHashes, outputs, commands, notary, transactionType, timeWindow, privacySalt)
|
return WireTransaction(inputs, attachmentHashes, outputs, commands, notary, timeWindow, privacySalt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ data class LedgerTransaction(
|
|||||||
override val id: SecureHash,
|
override val id: SecureHash,
|
||||||
override val notary: Party?,
|
override val notary: Party?,
|
||||||
val timeWindow: TimeWindow?,
|
val timeWindow: TimeWindow?,
|
||||||
val type: TransactionType,
|
|
||||||
val privacySalt: PrivacySalt
|
val privacySalt: PrivacySalt
|
||||||
) : FullTransaction() {
|
) : FullTransaction() {
|
||||||
//DOCEND 1
|
//DOCEND 1
|
||||||
|
@ -47,7 +47,6 @@ interface TraversableTransaction {
|
|||||||
val outputs: List<TransactionState<ContractState>>
|
val outputs: List<TransactionState<ContractState>>
|
||||||
val commands: List<Command<*>>
|
val commands: List<Command<*>>
|
||||||
val notary: Party?
|
val notary: Party?
|
||||||
val type: TransactionType?
|
|
||||||
val timeWindow: TimeWindow?
|
val timeWindow: TimeWindow?
|
||||||
/**
|
/**
|
||||||
* For privacy purposes, each part of a transaction should be accompanied by a nonce.
|
* For privacy purposes, each part of a transaction should be accompanied by a nonce.
|
||||||
@ -69,7 +68,6 @@ interface TraversableTransaction {
|
|||||||
* - Each output that is present
|
* - Each output that is present
|
||||||
* - Each command that is present
|
* - Each command that is present
|
||||||
* - The notary [Party], if present
|
* - The notary [Party], if present
|
||||||
* - The type of the transaction, if present
|
|
||||||
* - The time-window of the transaction, if present
|
* - The time-window of the transaction, if present
|
||||||
* - The privacy salt required for nonces, always presented in [WireTransaction] and always null in [FilteredLeaves]
|
* - The privacy salt required for nonces, always presented in [WireTransaction] and always null in [FilteredLeaves]
|
||||||
*/
|
*/
|
||||||
@ -82,7 +80,6 @@ interface TraversableTransaction {
|
|||||||
// torn-off transaction and id calculation.
|
// torn-off transaction and id calculation.
|
||||||
val result = mutableListOf(inputs, attachments, outputs, commands).flatten().toMutableList()
|
val result = mutableListOf(inputs, attachments, outputs, commands).flatten().toMutableList()
|
||||||
notary?.let { result += it }
|
notary?.let { result += it }
|
||||||
type?.let { result += it }
|
|
||||||
timeWindow?.let { result += it }
|
timeWindow?.let { result += it }
|
||||||
privacySalt?.let { result += it }
|
privacySalt?.let { result += it }
|
||||||
return result
|
return result
|
||||||
@ -108,7 +105,6 @@ class FilteredLeaves(
|
|||||||
override val outputs: List<TransactionState<ContractState>>,
|
override val outputs: List<TransactionState<ContractState>>,
|
||||||
override val commands: List<Command<*>>,
|
override val commands: List<Command<*>>,
|
||||||
override val notary: Party?,
|
override val notary: Party?,
|
||||||
override val type: TransactionType?,
|
|
||||||
override val timeWindow: TimeWindow?,
|
override val timeWindow: TimeWindow?,
|
||||||
val nonces: List<SecureHash>
|
val nonces: List<SecureHash>
|
||||||
) : TraversableTransaction {
|
) : TraversableTransaction {
|
||||||
|
@ -26,7 +26,6 @@ import java.util.*
|
|||||||
* [TransactionState] with this notary specified will be generated automatically.
|
* [TransactionState] with this notary specified will be generated automatically.
|
||||||
*/
|
*/
|
||||||
open class TransactionBuilder(
|
open class TransactionBuilder(
|
||||||
protected val type: TransactionType = TransactionType.General,
|
|
||||||
var notary: Party? = null,
|
var notary: Party? = null,
|
||||||
var lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
|
var lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
|
||||||
protected val inputs: MutableList<StateRef> = arrayListOf(),
|
protected val inputs: MutableList<StateRef> = arrayListOf(),
|
||||||
@ -36,13 +35,12 @@ open class TransactionBuilder(
|
|||||||
protected var window: TimeWindow? = null,
|
protected var window: TimeWindow? = null,
|
||||||
protected var privacySalt: PrivacySalt = PrivacySalt()
|
protected var privacySalt: PrivacySalt = PrivacySalt()
|
||||||
) {
|
) {
|
||||||
constructor(type: TransactionType, notary: Party) : this(type, notary, (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID())
|
constructor(notary: Party) : this (notary, (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a copy of the builder.
|
* Creates a copy of the builder.
|
||||||
*/
|
*/
|
||||||
fun copy() = TransactionBuilder(
|
fun copy() = TransactionBuilder(
|
||||||
type = type,
|
|
||||||
notary = notary,
|
notary = notary,
|
||||||
inputs = ArrayList(inputs),
|
inputs = ArrayList(inputs),
|
||||||
attachments = ArrayList(attachments),
|
attachments = ArrayList(attachments),
|
||||||
@ -73,7 +71,7 @@ open class TransactionBuilder(
|
|||||||
// DOCEND 1
|
// DOCEND 1
|
||||||
|
|
||||||
fun toWireTransaction() = WireTransaction(ArrayList(inputs), ArrayList(attachments),
|
fun toWireTransaction() = WireTransaction(ArrayList(inputs), ArrayList(attachments),
|
||||||
ArrayList(outputs), ArrayList(commands), notary, type, window, privacySalt)
|
ArrayList(outputs), ArrayList(commands), notary, window, privacySalt)
|
||||||
|
|
||||||
@Throws(AttachmentResolutionException::class, TransactionResolutionException::class)
|
@Throws(AttachmentResolutionException::class, TransactionResolutionException::class)
|
||||||
fun toLedgerTransaction(services: ServiceHub) = toWireTransaction().toLedgerTransaction(services)
|
fun toLedgerTransaction(services: ServiceHub) = toWireTransaction().toLedgerTransaction(services)
|
||||||
|
@ -26,8 +26,6 @@ data class WireTransaction(
|
|||||||
/** Ordered list of ([CommandData], [PublicKey]) pairs that instruct the contracts what to do. */
|
/** Ordered list of ([CommandData], [PublicKey]) pairs that instruct the contracts what to do. */
|
||||||
override val commands: List<Command<*>>,
|
override val commands: List<Command<*>>,
|
||||||
override val notary: Party?,
|
override val notary: Party?,
|
||||||
// TODO: remove type
|
|
||||||
override val type: TransactionType,
|
|
||||||
override val timeWindow: TimeWindow?,
|
override val timeWindow: TimeWindow?,
|
||||||
override val privacySalt: PrivacySalt = PrivacySalt()
|
override val privacySalt: PrivacySalt = PrivacySalt()
|
||||||
) : CoreTransaction(), TraversableTransaction {
|
) : CoreTransaction(), TraversableTransaction {
|
||||||
@ -41,7 +39,7 @@ data class WireTransaction(
|
|||||||
override val id: SecureHash get() = merkleTree.hash
|
override val id: SecureHash get() = merkleTree.hash
|
||||||
|
|
||||||
override val availableComponents: List<Any>
|
override val availableComponents: List<Any>
|
||||||
get() = listOf(inputs, attachments, outputs, commands).flatten() + listOf(notary, type, timeWindow).filterNotNull()
|
get() = listOf(inputs, attachments, outputs, commands).flatten() + listOf(notary, timeWindow).filterNotNull()
|
||||||
|
|
||||||
/** Public keys that need to be fulfilled by signatures in order for the transaction to be valid. */
|
/** Public keys that need to be fulfilled by signatures in order for the transaction to be valid. */
|
||||||
val requiredSigningKeys: Set<PublicKey> get() {
|
val requiredSigningKeys: Set<PublicKey> get() {
|
||||||
@ -93,7 +91,7 @@ data class WireTransaction(
|
|||||||
val resolvedInputs = inputs.map { ref ->
|
val resolvedInputs = inputs.map { ref ->
|
||||||
resolveStateRef(ref)?.let { StateAndRef(it, ref) } ?: throw TransactionResolutionException(ref.txhash)
|
resolveStateRef(ref)?.let { StateAndRef(it, ref) } ?: throw TransactionResolutionException(ref.txhash)
|
||||||
}
|
}
|
||||||
return LedgerTransaction(resolvedInputs, outputs, authenticatedArgs, attachments, id, notary, timeWindow, type, privacySalt)
|
return LedgerTransaction(resolvedInputs, outputs, authenticatedArgs, attachments, id, notary, timeWindow, privacySalt)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,8 +141,7 @@ data class WireTransaction(
|
|||||||
outputs.filterIndexed { index, it -> filterAndNoncesUpdate(filtering, it, index + offsets[1]) },
|
outputs.filterIndexed { index, it -> filterAndNoncesUpdate(filtering, it, index + offsets[1]) },
|
||||||
commands.filterIndexed { index, it -> filterAndNoncesUpdate(filtering, it, index + offsets[2]) },
|
commands.filterIndexed { index, it -> filterAndNoncesUpdate(filtering, it, index + offsets[2]) },
|
||||||
notNullFalseAndNoncesUpdate(notary, offsets[3]) as Party?,
|
notNullFalseAndNoncesUpdate(notary, offsets[3]) as Party?,
|
||||||
notNullFalseAndNoncesUpdate(type, offsets[4]) as TransactionType?,
|
notNullFalseAndNoncesUpdate(timeWindow, offsets[4]) as TimeWindow?,
|
||||||
notNullFalseAndNoncesUpdate(timeWindow, offsets[5]) as TimeWindow?,
|
|
||||||
nonces
|
nonces
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -162,7 +159,6 @@ data class WireTransaction(
|
|||||||
} else {
|
} else {
|
||||||
offsets.add(offsets.last())
|
offsets.add(offsets.last())
|
||||||
}
|
}
|
||||||
offsets.add(offsets.last() + 1) // For tx type.
|
|
||||||
if (timeWindow != null) {
|
if (timeWindow != null) {
|
||||||
offsets.add(offsets.last() + 1)
|
offsets.add(offsets.last() + 1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +39,6 @@ class TransactionTests : TestDependencyInjectionBase() {
|
|||||||
outputs = emptyList(),
|
outputs = emptyList(),
|
||||||
commands = listOf(dummyCommand(compKey, DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
commands = listOf(dummyCommand(compKey, DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
||||||
notary = DUMMY_NOTARY,
|
notary = DUMMY_NOTARY,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = null
|
timeWindow = null
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@ -66,7 +65,6 @@ class TransactionTests : TestDependencyInjectionBase() {
|
|||||||
outputs = emptyList(),
|
outputs = emptyList(),
|
||||||
commands = listOf(dummyCommand(DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
commands = listOf(dummyCommand(DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
||||||
notary = DUMMY_NOTARY,
|
notary = DUMMY_NOTARY,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = null
|
timeWindow = null
|
||||||
)
|
)
|
||||||
assertFailsWith<IllegalArgumentException> { makeSigned(wtx, notarySig = false).verifyRequiredSignatures() }
|
assertFailsWith<IllegalArgumentException> { makeSigned(wtx, notarySig = false).verifyRequiredSignatures() }
|
||||||
@ -108,7 +106,6 @@ class TransactionTests : TestDependencyInjectionBase() {
|
|||||||
id,
|
id,
|
||||||
null,
|
null,
|
||||||
timeWindow,
|
timeWindow,
|
||||||
TransactionType.General,
|
|
||||||
privacySalt
|
privacySalt
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -124,7 +121,6 @@ class TransactionTests : TestDependencyInjectionBase() {
|
|||||||
outputs = emptyList(),
|
outputs = emptyList(),
|
||||||
commands = listOf(dummyCommand(DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
commands = listOf(dummyCommand(DUMMY_KEY_1.public, DUMMY_KEY_2.public)),
|
||||||
notary = DUMMY_NOTARY,
|
notary = DUMMY_NOTARY,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = null
|
timeWindow = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -151,7 +147,6 @@ class TransactionTests : TestDependencyInjectionBase() {
|
|||||||
id,
|
id,
|
||||||
notary,
|
notary,
|
||||||
timeWindow,
|
timeWindow,
|
||||||
TransactionType.General,
|
|
||||||
privacySalt
|
privacySalt
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package net.corda.core.contracts.clauses
|
|||||||
import net.corda.core.contracts.AuthenticatedObject
|
import net.corda.core.contracts.AuthenticatedObject
|
||||||
import net.corda.core.contracts.CommandData
|
import net.corda.core.contracts.CommandData
|
||||||
import net.corda.core.contracts.PrivacySalt
|
import net.corda.core.contracts.PrivacySalt
|
||||||
import net.corda.core.contracts.TransactionType
|
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -17,7 +16,7 @@ class AllOfTests {
|
|||||||
fun minimal() {
|
fun minimal() {
|
||||||
val counter = AtomicInteger(0)
|
val counter = AtomicInteger(0)
|
||||||
val clause = AllOf(matchedClause(counter), matchedClause(counter))
|
val clause = AllOf(matchedClause(counter), matchedClause(counter))
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
||||||
|
|
||||||
// Check that we've run the verify() function of two clauses
|
// Check that we've run the verify() function of two clauses
|
||||||
@ -27,7 +26,7 @@ class AllOfTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `not all match`() {
|
fun `not all match`() {
|
||||||
val clause = AllOf(matchedClause(), unmatchedClause())
|
val clause = AllOf(matchedClause(), unmatchedClause())
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
assertFailsWith<IllegalStateException> { verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>()) }
|
assertFailsWith<IllegalStateException> { verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.corda.core.contracts.clauses
|
|||||||
import net.corda.core.contracts.AuthenticatedObject
|
import net.corda.core.contracts.AuthenticatedObject
|
||||||
import net.corda.core.contracts.CommandData
|
import net.corda.core.contracts.CommandData
|
||||||
import net.corda.core.contracts.PrivacySalt
|
import net.corda.core.contracts.PrivacySalt
|
||||||
import net.corda.core.contracts.TransactionType
|
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -16,7 +15,7 @@ class AnyOfTests {
|
|||||||
fun minimal() {
|
fun minimal() {
|
||||||
val counter = AtomicInteger(0)
|
val counter = AtomicInteger(0)
|
||||||
val clause = AnyOf(matchedClause(counter), matchedClause(counter))
|
val clause = AnyOf(matchedClause(counter), matchedClause(counter))
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
||||||
|
|
||||||
// Check that we've run the verify() function of two clauses
|
// Check that we've run the verify() function of two clauses
|
||||||
@ -27,7 +26,7 @@ class AnyOfTests {
|
|||||||
fun `not all match`() {
|
fun `not all match`() {
|
||||||
val counter = AtomicInteger(0)
|
val counter = AtomicInteger(0)
|
||||||
val clause = AnyOf(matchedClause(counter), unmatchedClause(counter))
|
val clause = AnyOf(matchedClause(counter), unmatchedClause(counter))
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
||||||
|
|
||||||
// Check that we've run the verify() function of one clause
|
// Check that we've run the verify() function of one clause
|
||||||
@ -38,7 +37,7 @@ class AnyOfTests {
|
|||||||
fun `none match`() {
|
fun `none match`() {
|
||||||
val counter = AtomicInteger(0)
|
val counter = AtomicInteger(0)
|
||||||
val clause = AnyOf(unmatchedClause(counter), unmatchedClause(counter))
|
val clause = AnyOf(unmatchedClause(counter), unmatchedClause(counter))
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
assertFailsWith(IllegalArgumentException::class) {
|
assertFailsWith(IllegalArgumentException::class) {
|
||||||
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class VerifyClausesTests {
|
|||||||
outputs: List<ContractState>,
|
outputs: List<ContractState>,
|
||||||
commands: List<AuthenticatedObject<CommandData>>, groupingKey: Unit?): Set<CommandData> = emptySet()
|
commands: List<AuthenticatedObject<CommandData>>, groupingKey: Unit?): Set<CommandData> = emptySet()
|
||||||
}
|
}
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), emptyList(), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
verifyClause(tx, clause, emptyList<AuthenticatedObject<CommandData>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class VerifyClausesTests {
|
|||||||
commands: List<AuthenticatedObject<CommandData>>, groupingKey: Unit?): Set<CommandData> = emptySet()
|
commands: List<AuthenticatedObject<CommandData>>, groupingKey: Unit?): Set<CommandData> = emptySet()
|
||||||
}
|
}
|
||||||
val command = AuthenticatedObject(emptyList(), emptyList(), DummyContract.Commands.Create())
|
val command = AuthenticatedObject(emptyList(), emptyList(), DummyContract.Commands.Create())
|
||||||
val tx = LedgerTransaction(emptyList(), emptyList(), listOf(command), emptyList(), SecureHash.randomSHA256(), null, null, TransactionType.General, PrivacySalt())
|
val tx = LedgerTransaction(emptyList(), emptyList(), listOf(command), emptyList(), SecureHash.randomSHA256(), null, null, PrivacySalt())
|
||||||
// The clause is matched, but doesn't mark the command as consumed, so this should error
|
// The clause is matched, but doesn't mark the command as consumed, so this should error
|
||||||
assertFailsWith<IllegalStateException> { verifyClause(tx, clause, listOf(command)) }
|
assertFailsWith<IllegalStateException> { verifyClause(tx, clause, listOf(command)) }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.corda.core.crypto
|
package net.corda.core.crypto
|
||||||
|
|
||||||
|
|
||||||
import com.esotericsoftware.kryo.KryoException
|
import com.esotericsoftware.kryo.KryoException
|
||||||
import net.corda.contracts.asset.Cash
|
import net.corda.contracts.asset.Cash
|
||||||
import net.corda.core.contracts.*
|
import net.corda.core.contracts.*
|
||||||
@ -120,7 +119,6 @@ class PartialMerkleTreeTest : TestDependencyInjectionBase() {
|
|||||||
assertEquals(1, leaves.outputs.size)
|
assertEquals(1, leaves.outputs.size)
|
||||||
assertEquals(1, leaves.commands.size)
|
assertEquals(1, leaves.commands.size)
|
||||||
assertNull(mt.filteredLeaves.notary)
|
assertNull(mt.filteredLeaves.notary)
|
||||||
assertNull(mt.filteredLeaves.type)
|
|
||||||
assertNotNull(mt.filteredLeaves.timeWindow)
|
assertNotNull(mt.filteredLeaves.timeWindow)
|
||||||
assertNull(mt.filteredLeaves.privacySalt)
|
assertNull(mt.filteredLeaves.privacySalt)
|
||||||
assertEquals(4, leaves.nonces.size)
|
assertEquals(4, leaves.nonces.size)
|
||||||
@ -244,7 +242,6 @@ class PartialMerkleTreeTest : TestDependencyInjectionBase() {
|
|||||||
outputs = testTx.outputs,
|
outputs = testTx.outputs,
|
||||||
commands = testTx.commands,
|
commands = testTx.commands,
|
||||||
notary = notary,
|
notary = notary,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = timeWindow
|
timeWindow = timeWindow
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class FinalityFlowTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `finalise a simple transaction`() {
|
fun `finalise a simple transaction`() {
|
||||||
val amount = Amount(1000, Issued(nodeA.info.legalIdentity.ref(0), GBP))
|
val amount = Amount(1000, Issued(nodeA.info.legalIdentity.ref(0), GBP))
|
||||||
val builder = TransactionBuilder(TransactionType.General, notary)
|
val builder = TransactionBuilder(notary)
|
||||||
Cash().generateIssue(builder, amount, nodeB.info.legalIdentity, notary)
|
Cash().generateIssue(builder, amount, nodeB.info.legalIdentity, notary)
|
||||||
val stx = nodeA.services.signInitialTransaction(builder)
|
val stx = nodeA.services.signInitialTransaction(builder)
|
||||||
val flow = nodeA.services.startFlow(FinalityFlow(stx))
|
val flow = nodeA.services.startFlow(FinalityFlow(stx))
|
||||||
|
@ -4,7 +4,6 @@ import net.corda.contracts.asset.Cash
|
|||||||
import net.corda.core.contracts.Amount
|
import net.corda.core.contracts.Amount
|
||||||
import net.corda.core.contracts.GBP
|
import net.corda.core.contracts.GBP
|
||||||
import net.corda.core.contracts.Issued
|
import net.corda.core.contracts.Issued
|
||||||
import net.corda.core.contracts.TransactionType
|
|
||||||
import net.corda.core.getOrThrow
|
import net.corda.core.getOrThrow
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
@ -43,7 +42,7 @@ class ManualFinalityFlowTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `finalise a simple transaction`() {
|
fun `finalise a simple transaction`() {
|
||||||
val amount = Amount(1000, Issued(nodeA.info.legalIdentity.ref(0), GBP))
|
val amount = Amount(1000, Issued(nodeA.info.legalIdentity.ref(0), GBP))
|
||||||
val builder = TransactionBuilder(TransactionType.General, notary)
|
val builder = TransactionBuilder(notary)
|
||||||
Cash().generateIssue(builder, amount, nodeB.info.legalIdentity, notary)
|
Cash().generateIssue(builder, amount, nodeB.info.legalIdentity, notary)
|
||||||
val stx = nodeA.services.signInitialTransaction(builder)
|
val stx = nodeA.services.signInitialTransaction(builder)
|
||||||
val flow = nodeA.services.startFlow(ManualFinalityFlow(stx, setOf(nodeC.info.legalIdentity)))
|
val flow = nodeA.services.startFlow(ManualFinalityFlow(stx, setOf(nodeC.info.legalIdentity)))
|
||||||
|
@ -311,7 +311,7 @@ public class FlowCookbookJava {
|
|||||||
progressTracker.setCurrentStep(TX_BUILDING);
|
progressTracker.setCurrentStep(TX_BUILDING);
|
||||||
|
|
||||||
// DOCSTART 19
|
// DOCSTART 19
|
||||||
TransactionBuilder txBuilder = new TransactionBuilder(General.INSTANCE, specificNotary);
|
TransactionBuilder txBuilder = new TransactionBuilder(specificNotary);
|
||||||
// DOCEND 19
|
// DOCEND 19
|
||||||
|
|
||||||
// We add items to the transaction builder using ``TransactionBuilder.withItems``:
|
// We add items to the transaction builder using ``TransactionBuilder.withItems``:
|
||||||
|
@ -292,7 +292,7 @@ object FlowCookbook {
|
|||||||
progressTracker.currentStep = TX_BUILDING
|
progressTracker.currentStep = TX_BUILDING
|
||||||
|
|
||||||
// DOCSTART 19
|
// DOCSTART 19
|
||||||
val txBuilder: TransactionBuilder = TransactionBuilder(General, specificNotary)
|
val txBuilder: TransactionBuilder = TransactionBuilder(specificNotary)
|
||||||
// DOCEND 19
|
// DOCEND 19
|
||||||
|
|
||||||
// We add items to the transaction builder using ``TransactionBuilder.withItems``:
|
// We add items to the transaction builder using ``TransactionBuilder.withItems``:
|
||||||
|
@ -73,7 +73,6 @@ class WiredTransactionGenerator : Generator<WireTransaction>(WireTransaction::cl
|
|||||||
outputs = TransactionStateGenerator(ContractStateGenerator()).generateList(random, status),
|
outputs = TransactionStateGenerator(ContractStateGenerator()).generateList(random, status),
|
||||||
commands = commands,
|
commands = commands,
|
||||||
notary = PartyGenerator().generate(random, status),
|
notary = PartyGenerator().generate(random, status),
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = TimeWindowGenerator().generate(random, status)
|
timeWindow = TimeWindowGenerator().generate(random, status)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,6 @@ class VaultSchemaTest : TestDependencyInjectionBase() {
|
|||||||
id,
|
id,
|
||||||
notary,
|
notary,
|
||||||
timeWindow,
|
timeWindow,
|
||||||
TransactionType.General,
|
|
||||||
privacySalt
|
privacySalt
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -161,7 +160,6 @@ class VaultSchemaTest : TestDependencyInjectionBase() {
|
|||||||
id,
|
id,
|
||||||
notary,
|
notary,
|
||||||
timeWindow,
|
timeWindow,
|
||||||
TransactionType.General,
|
|
||||||
privacySalt
|
privacySalt
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,6 @@ class RequeryConfigurationTest : TestDependencyInjectionBase() {
|
|||||||
outputs = emptyList(),
|
outputs = emptyList(),
|
||||||
commands = emptyList(),
|
commands = emptyList(),
|
||||||
notary = DUMMY_NOTARY,
|
notary = DUMMY_NOTARY,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = null
|
timeWindow = null
|
||||||
)
|
)
|
||||||
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
|
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
|
||||||
|
@ -148,7 +148,6 @@ class DBTransactionStorageTests : TestDependencyInjectionBase() {
|
|||||||
outputs = emptyList(),
|
outputs = emptyList(),
|
||||||
commands = emptyList(),
|
commands = emptyList(),
|
||||||
notary = DUMMY_NOTARY,
|
notary = DUMMY_NOTARY,
|
||||||
type = TransactionType.General,
|
|
||||||
timeWindow = null
|
timeWindow = null
|
||||||
)
|
)
|
||||||
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
|
return SignedTransaction(wtx, listOf(DigitalSignature.WithKey(NullPublicKey, ByteArray(1))))
|
||||||
|
@ -458,7 +458,7 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
|||||||
val amount = Amount(1000, Issued(BOC.ref(1), GBP))
|
val amount = Amount(1000, Issued(BOC.ref(1), GBP))
|
||||||
|
|
||||||
// Issue then move some cash
|
// Issue then move some cash
|
||||||
val issueTx = TransactionBuilder(TransactionType.General, services.myInfo.legalIdentity).apply {
|
val issueTx = TransactionBuilder(services.myInfo.legalIdentity).apply {
|
||||||
Cash().generateIssue(this,
|
Cash().generateIssue(this,
|
||||||
amount, anonymousIdentity.party, services.myInfo.legalIdentity)
|
amount, anonymousIdentity.party, services.myInfo.legalIdentity)
|
||||||
}.toWireTransaction()
|
}.toWireTransaction()
|
||||||
@ -468,7 +468,7 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
|||||||
val expectedIssueUpdate = Vault.Update(emptySet(), setOf(cashState), null)
|
val expectedIssueUpdate = Vault.Update(emptySet(), setOf(cashState), null)
|
||||||
|
|
||||||
database.transaction {
|
database.transaction {
|
||||||
val moveTx = TransactionBuilder(TransactionType.General, services.myInfo.legalIdentity).apply {
|
val moveTx = TransactionBuilder(services.myInfo.legalIdentity).apply {
|
||||||
service.generateSpend(this, Amount(1000, GBP), thirdPartyIdentity)
|
service.generateSpend(this, Amount(1000, GBP), thirdPartyIdentity)
|
||||||
}.toWireTransaction()
|
}.toWireTransaction()
|
||||||
service.notify(moveTx)
|
service.notify(moveTx)
|
||||||
|
@ -74,7 +74,6 @@ data class GeneratedLedger(
|
|||||||
outputs,
|
outputs,
|
||||||
commands.map { it.first },
|
commands.map { it.first },
|
||||||
null,
|
null,
|
||||||
TransactionType.General,
|
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
|
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
|
||||||
@ -107,7 +106,6 @@ data class GeneratedLedger(
|
|||||||
outputs,
|
outputs,
|
||||||
commands.map { it.first },
|
commands.map { it.first },
|
||||||
inputNotary,
|
inputNotary,
|
||||||
TransactionType.General,
|
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
|
val newOutputStateAndRefs = outputs.mapIndexed { i, state ->
|
||||||
|
Loading…
Reference in New Issue
Block a user