【问题标题】:Predicate returns false when accounts along with oracle is used in corda当在 corda 中使用帐户和 oracle 时,谓词返回 false
【发布时间】: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


    【解决方案1】:
    • 指定命令时应传递requiredSigners列表;目前您正在通过participantsList。
    • 顺便说一句,预言机不应该是参与者;通常是第三方提供经过验证的数据。
      如果您要通过使其成为参与者来在 oracle 中注册该完整交易和相关状态,那么向 oracle 发送过滤交易有什么意义(假设 participantsList 是您将在最终流程中使用的内容) .
    • 您应该使用WireTransaction 来构建过滤的事务(即localSignedTx.tx.buildFilteredTransaction())(注意.tx)。
    • 你有一个错字,你在SignFlow中使用了filteredTransaction;你的变量名是filteredTx。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多