【发布时间】:2020-05-27 23:46:59
【问题描述】:
我正在尝试在 corda 中使用帐户功能和 oracle 功能,问题在于构建过滤函数以获取 oracle 签名。我的 kotlin 代码,它使用谓词检查我的交易中是否有 oracle 密钥总是返回 false,即使我在用于签署初始交易的公钥列表中添加了 oracle publickey。
var requiredSigners = Arrays.asList(oracle.owningKey, urIdentity.owningKey, lenderAccountNewKey)
val output = IOUState(exchangeRate * value, lenderAccountNewKey, borrowerAccountNewKey)
val transactionBuilder = TransactionBuilder(notary)
var participantsList = ArrayList<AbstractParty>(output.participants)
participantsList.add(oracle)
transactionBuilder.addOutputState(output, IOUContract.ID)
.addCommand(IOUContract.Commands.Create(), participantsList.map { it.owningKey })
transactionBuilder.verify(serviceHub)
var localSignedTx = serviceHub.signInitialTransaction(transactionBuilder)
var filteredTx = localSignedTx.buildFilteredTransaction(Predicate {
when (it) {
is Command<*> -> oracle.owningKey in it.signers
else -> false
}
}
val oracleSignature = subFlow(SignFlow(oracle, filteredTransaction))
val stx = locallySignedTransaction.withAdditionalSignature(oracleSignature)
当尝试使用以下代码运行时,日志如下所示。
[INFO] 2020-05-26T07:00:59,660Z [节点线程 1]corda.flow。 - Flow 引发错误:集合不包含与谓词匹配的元素。将其发送到流医院进行分类。 {actor_id=internalShell,actor_owning_identity=O=PartyA,L=伦敦, C=GB,actor_store_id=NODE_CONFIG,fiber-id=10000003, 流量 ID=040d69f9-f93a-4a23-bdb4-594c41d38987, invocation_id=3da3d8a0-64ec-4a41-8f18-b0ca05557490, invocation_timestamp=2020-05-26T07:00:58.102Z, origin=internalShell, session_id=dec88c8e-1441-425b-bfe0-f00ad6b12126, session_timestamp=2020-05-26T06:58:59.126Z,线程 ID=161} [信息] 2020-05-26T07:00:59,666Z [节点线程 1] statemachine.StaffedFlow 医院。 - 流动 [040d69f9-f93a-4a23-bdb4-594c41d38987] 州内入院
【问题讨论】:
标签: corda