在 corda 中使用 accounts 和 oracle 时谓词 returns false

Predicate returns false when accounts along with oracle is used in corda

我正在尝试将 corda 中的帐户功能与 oracle 功能一起使用,问题在于构建用于获取 oracle 签名的过滤函数。我的科特林代码,它使用谓词来检查我的交易中是否有 oracle 密钥总是 returns false,即使我在用于签名初始的 public 密钥列表中添加了 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 [Node thread-1] corda.flow. - Flow raised an error: Collection contains no element matching the predicate.. Sending it to flow hospital to be triaged. {actor_id=internalShell, actor_owning_identity=O=PartyA, L=London, C=GB, actor_store_id=NODE_CONFIG, fiber-id=10000003, flow-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, thread-id=161} [INFO ] 2020-05-26T07:00:59,666Z [Node thread-1] statemachine.StaffedFlowHospital. - Flow [040d69f9-f93a-4a23-bdb4-594c41d38987] admitted to hospital in state

  • 指定命令时应传递requiredSigners列表;目前您正在通过 participantsList
  • 附带说明一下,预言机不应该是参与者;通常是第三方提供经过验证的数据。
    向 oracle 发送过滤后的交易有什么意义,如果您要通过使其成为参与者来在 oracle 中注册该完整交易和相关状态(假设 participantsList 是您将在最终结果中使用的流动)。
  • 您应该使用 WireTransaction 来构建过滤交易(即 localSignedTx.tx.buildFilteredTransaction())(注意 .tx)。
  • 你打错了,你在SignFlow中使用了filteredTransaction;您的变量名称是 filteredTx.