Corda合约中是否有一种方法可以检查发行人是否仅是特定方。说我有一个由3个节点组成的网络-NodeA,NodeB,Notary。我可以签入合同,确定问题是否仅由甲方完成 即发行人的发行密钥始终等于甲方的发行密钥?
答案 0 :(得分:0)
是的,您可以执行此检查。例如:
class IssuedContract : Contract {
companion object {
// Used to identify our contract when building a transaction.
const val ID = "com.issuing.IssuedContract"
}
private val expectedIssuer = CordaX500Name("Expected Issuer", "London", "GB")
override fun verify(tx: LedgerTransaction) {
val issuedStates = tx.outputsOfType<IssuedState>()
issuedStates.forEach { issuedState ->
if (issuedState.issuer.name != expectedIssuer)
throw IllegalArgumentException("The state is not issued by the correct party.")
}
}
}
但是,这种方法很脆弱。该合同仅适用于指定的发行人。
通常,最好在签名流中的交易之前检查每个节点是否对所选发行者满意。