From aa166518a0575ccaf4bd058a106ec327b17a5ef5 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Mon, 5 Sep 2016 18:41:35 +0100 Subject: [PATCH 1/4] Remove unused val --- core/src/main/kotlin/com/r3corda/core/contracts/Transactions.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/Transactions.kt b/core/src/main/kotlin/com/r3corda/core/contracts/Transactions.kt index da836c8476..03397d7542 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/Transactions.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/Transactions.kt @@ -163,7 +163,6 @@ data class SignedTransaction(val txBits: SerializedBytes, * Returns the set of missing signatures - a signature must be present for each signer public key. */ private fun getMissingSignatures(): Set { - val notaryKey = tx.notary?.owningKey val requiredKeys = tx.signers.toSet() val sigKeys = sigs.map { it.by }.toSet() From 84247128b4d32da7322d64d49f22b40fbcfee5b8 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Mon, 5 Sep 2016 18:47:51 +0100 Subject: [PATCH 2/4] Remove addInputState(stateRef, notary) from TransactionBuilder API, as it might lead to issues where someone accidentally provides a different notary than the one in the state --- .../com/r3corda/core/contracts/TransactionBuilder.kt | 7 +++---- test-utils/src/main/kotlin/com/r3corda/testing/TestDSL.kt | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt index 4dc36557cd..9b40c65424 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt @@ -139,13 +139,12 @@ open class TransactionBuilder( return SignedTransaction(toWireTransaction().serialize(), ArrayList(currentSigs)) } - open fun addInputState(stateAndRef: StateAndRef<*>) = addInputState(stateAndRef.ref, stateAndRef.state.notary) - - fun addInputState(stateRef: StateRef, notary: Party) { + open fun addInputState(stateAndRef: StateAndRef<*>) { check(currentSigs.isEmpty()) + val notary = stateAndRef.state.notary require(notary == this.notary) { "Input state requires notary \"${notary}\" which does not match the transaction notary \"${this.notary}\"." } signers.add(notary.owningKey) - inputs.add(stateRef) + inputs.add(stateAndRef.ref) } fun addAttachment(attachmentId: SecureHash) { diff --git a/test-utils/src/main/kotlin/com/r3corda/testing/TestDSL.kt b/test-utils/src/main/kotlin/com/r3corda/testing/TestDSL.kt index 96b3ee6dbf..40fd227416 100644 --- a/test-utils/src/main/kotlin/com/r3corda/testing/TestDSL.kt +++ b/test-utils/src/main/kotlin/com/r3corda/testing/TestDSL.kt @@ -106,8 +106,8 @@ data class TestTransactionDSLInterpreter private constructor( internal fun toWireTransaction() = transactionBuilder.toWireTransaction() override fun input(stateRef: StateRef) { - val notary = ledgerInterpreter.resolveStateRef(stateRef).notary - transactionBuilder.addInputState(stateRef, notary) + val state = ledgerInterpreter.resolveStateRef(stateRef) + transactionBuilder.addInputState(StateAndRef(state, stateRef)) } override fun _output(label: String?, notary: Party, contractState: ContractState) { From 2676e8878d6f75dd9edde2557c290da7eb817c49 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Mon, 5 Sep 2016 18:50:53 +0100 Subject: [PATCH 3/4] Remove a @Deprecated as the code has been changed since its introduction anyway --- .../main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt index 9b40c65424..c548b4f398 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt @@ -30,7 +30,6 @@ open class TransactionBuilder( protected val signers: MutableSet = mutableSetOf(), protected var timestamp: Timestamp? = null) { - @Deprecated("use timestamp instead") val time: Timestamp? get() = timestamp init { From 9cccb1196751ec38fd5c478d377b7dafbd7260e5 Mon Sep 17 00:00:00 2001 From: Andrius Dagys Date: Tue, 6 Sep 2016 10:07:08 +0100 Subject: [PATCH 4/4] Add comment explaining signers --- .../kotlin/com/r3corda/core/contracts/TransactionBuilder.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt index c548b4f398..40533864cd 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionBuilder.kt @@ -19,6 +19,10 @@ import java.util.* * @param notary Notary used for the transaction. If null, this indicates the transaction DOES NOT have a notary. * When this is set to a non-null value, an output state can be added by just passing in a [ContractState] – a * [TransactionState] with this notary specified will be generated automatically. + * + * @param signers The set of public keys the transaction needs signatures for. The logic for building the signers set + * can be customised for every [TransactionType]. E.g. in the general case it contains the command and notary public keys, + * but for the [TransactionType.NotaryChange] transactions it is the set of all input [ContractState.participants]. */ open class TransactionBuilder( protected val type: TransactionType = TransactionType.General(),