Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin Corda:在单个事务中添加多个输出状态_Kotlin_Corda - Fatal编程技术网

Kotlin Corda:在单个事务中添加多个输出状态

Kotlin Corda:在单个事务中添加多个输出状态,kotlin,corda,Kotlin,Corda,在我们的用例中,我们必须向一个事务添加两个具有不同契约的输出状态。我试图在with items中将多个状态添加到事务中。我从RPC调用此流,但它在签名事务时引发异常,如java.lang.IllegalArgumentException:List有多个元素。 这就是我添加多个输出状态的方式:- val outputstate1 = IouState1(dataModel1, me, otherParty) val outputstate2 = IouState2(dataModel2, me,

在我们的用例中,我们必须向一个事务添加两个具有不同契约的输出状态。我试图在
with items
中将多个状态添加到事务中。我从RPC调用此流,但它在签名事务时引发异常,如
java.lang.IllegalArgumentException:List有多个元素。

这就是我添加多个输出状态的方式:-

val outputstate1 = IouState1(dataModel1, me, otherParty)
val outputstate2 = IouState2(dataModel2, me, otherParty)
val cmd1 = Command(IouContract1.Commands.Create(), state1.participants.map { it.owningKey })
val cmd2 = Command(IouContract2.Commands.Initiated(), state2.participants.map { it.owningKey })
val txBuilder = TransactionBuilder(TransactionType.General, notary).withItems(state1, state2, cmd1, cmd2)
progressTracker.currentStep = VERIFYING_TRANSACTION

// Verifying the transaction.
txBuilder.toWireTransaction().toLedgerTransaction(serviceHub).verify()

progressTracker.currentStep = SIGNING_TRANSACTION
// Signing the transaction.
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)

progressTracker.currentStep = GATHERING_SIGS
// Send the state to the counterparty, and receive it back with their signature.
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, GATHERING_SIGS.childProgressTracker()))

// Finalising the transaction.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(fullySignedTx, FINALISING_TRANSACTION.childProgressTracker())).single()
堆栈跟踪:-

net.corda.core.flows.FlowException: java.lang.IllegalArgumentException: List has more than one element.
    at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:202) ~[corda-core-0.14.0.jar:?]
    at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:175) ~[corda-core-0.14.0.jar:?]
    at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:166) ~[corda-core-0.14.0.jar:?]
    at com.dwlabcorda.salescontract.LOCReceiverFlow.call(LOCContractFlow.kt:107) ~[tradefinancecorda-0.1.jar:?]
    at com.dwlabcorda.salescontract.LOCReceiverFlow.call(LOCContractFlow.kt:95) ~[tradefinancecorda-0.1.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:101) [corda-node-0.14.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:33) [corda-node-0.14.0.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1067) [quasar-core-0.7.6-jdk8.jar:0.7.6]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:767) [quasar-core-0.7.6-jdk8.jar:0.7.6]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.6-jdk8.jar:0.7.6]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.6-jdk8.jar:0.7.6]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_144]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_144]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) [?:1.8.0_144]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_144]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:69) [corda-node-0.14.0.jar:?]
Caused by: java.lang.IllegalArgumentException: List has more than one element.
    at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:471) ~[kotlin-stdlib-1.1.1.jar:1.1.1]
    at com.dwlabcorda.salescontract.LOCReceiverFlow$call$signTransactionFlow$1.checkTransaction(LOCContractFlow.kt:100) ~[tradefinancecorda-0.1.jar:?]
    at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:199) ~[corda-core-0.14.0.jar:?]
    ... 17 more

可能您在某个契约中使用了.single()强制转换,该契约现在引发异常

这应该没问题。我怀疑你的问题在别处。你能发布流的其余部分吗?更新了整个流的代码..谢谢-你能添加完整的堆栈跟踪吗?因为我没有看到上面有什么不好的地方,我猜问题可能在合同代码中(CollectSignaturesFlow将调用该代码)。正如Stefano所说,检查您是否正在对合同中的输出调用
single
。是的,我使用了val out=tx.outputsOfType().single()“发送方和接收方不能是同一个实体。”使用(out.party1!=out.party2)…如何更改它..get(0)和get(1)抛出异常..您不能使用.single()然后创建两个IoState类型的输出,首先您必须选择是否可以输出多个IoState或仅输出一个IoState
get(0)
不应引发异常。您看到的bakriOnFire出现了什么异常?@bakriOnFire您必须对单个输入执行检查,然后转换为单个输入。如果你不明白,你可以pm我