mirror of
https://github.com/corda/corda.git
synced 2025-01-29 23:54:07 +00:00
Simply TransactionForLedger.verify
This commit is contained in:
parent
ac9a371179
commit
3041ca73f2
@ -12,6 +12,8 @@ class WireTransaction(
|
|||||||
val tx: ByteArray,
|
val tx: ByteArray,
|
||||||
|
|
||||||
// We assume Ed25519 signatures for all. Num signatures == array.length / 64 (each sig is 64 bytes in size)
|
// We assume Ed25519 signatures for all. Num signatures == array.length / 64 (each sig is 64 bytes in size)
|
||||||
|
// This array is in the same order as the public keys in the commands array, so signatures can be matched to
|
||||||
|
// public keys in that manner.
|
||||||
val signatures: ByteArray
|
val signatures: ByteArray
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -41,14 +43,10 @@ class TransactionForVerification(
|
|||||||
fun verify(programMap: Map<SecureHash, Contract>) {
|
fun verify(programMap: Map<SecureHash, Contract>) {
|
||||||
// For each input and output state, locate the program to run. Then execute the verification function. If any
|
// For each input and output state, locate the program to run. Then execute the verification function. If any
|
||||||
// throws an exception, the entire transaction is invalid.
|
// throws an exception, the entire transaction is invalid.
|
||||||
fun runContracts(desc: String, l: List<ContractState>) {
|
val programHashes = (inStates.map { it.programRef } + outStates.map { it.programRef }).toSet()
|
||||||
for ((index, state) in l.withIndex()) {
|
for (hash in programHashes) {
|
||||||
val contract = programMap[state.programRef] ?: throw IllegalStateException("$desc state $index refers to unknown contract ${state.programRef}")
|
val program = programMap[hash] ?: throw IllegalStateException("Unknown program hash $hash")
|
||||||
contract.verify(this)
|
program.verify(this)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runContracts("input", inStates)
|
|
||||||
runContracts("output", outStates)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user