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

This commit is contained in:
Andrius Dagys 2016-09-05 18:47:51 +01:00
parent aa166518a0
commit 84247128b4
2 changed files with 5 additions and 6 deletions

View File

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

View File

@ -106,8 +106,8 @@ data class TestTransactionDSLInterpreter private constructor(
internal fun toWireTransaction() = transactionBuilder.toWireTransaction()
override fun input(stateRef: StateRef) {
val notary = ledgerInterpreter.resolveStateRef<ContractState>(stateRef).notary
transactionBuilder.addInputState(stateRef, notary)
val state = ledgerInterpreter.resolveStateRef<ContractState>(stateRef)
transactionBuilder.addInputState(StateAndRef(state, stateRef))
}
override fun _output(label: String?, notary: Party, contractState: ContractState) {