mirror of
https://github.com/corda/corda.git
synced 2024-12-19 13:08:04 +00:00
Merged in andrius-minor-transaction-cleanup (pull request #329)
Minor TransactionBuilder cleanup
This commit is contained in:
commit
f3b4379e06
@ -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(),
|
||||
@ -30,7 +34,6 @@ open class TransactionBuilder(
|
||||
protected val signers: MutableSet<PublicKey> = mutableSetOf(),
|
||||
protected var timestamp: Timestamp? = null) {
|
||||
|
||||
@Deprecated("use timestamp instead")
|
||||
val time: Timestamp? get() = timestamp
|
||||
|
||||
init {
|
||||
@ -139,13 +142,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) {
|
||||
|
@ -163,7 +163,6 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
|
||||
* Returns the set of missing signatures - a signature must be present for each signer public key.
|
||||
*/
|
||||
private fun getMissingSignatures(): Set<PublicKey> {
|
||||
val notaryKey = tx.notary?.owningKey
|
||||
val requiredKeys = tx.signers.toSet()
|
||||
val sigKeys = sigs.map { it.by }.toSet()
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user