corda - 无法使用 Corda 4.0 创建带有自身节点的 Corda 事务
问题描述
我想使用 corda 4.0 创建与 self 节点的事务。
我为此使用了示例 IOU 示例,并在 ExampleFlow 中添加了我的更改,如下面的代码所示。 https://github.com/corda/cordapp-example/tree/release-V4/java-source。
但它不允许使用自身节点创建交易。
我也遵循/实施了这个Corda 4 - Single Party Transaction Failed to Commit to Ledger的答案
但它没有成功。
我只在 ExampleFlow 中进行了更改,如下所示/iOU 示例中的其余代码相同。
请帮忙。
@Suspendable
override fun call(): SignedTransaction {
// Obtain a reference to the notary we want to use.
val notary = serviceHub.networkMapCache.notaryIdentities[0]
// Stage 1.
progressTracker.currentStep = GENERATING_TRANSACTION
// Generate an unsigned transaction.
val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)
val txCommand = Command(IOUContract.Commands.Create(), listOf(ourIdentity.owningKey))
val txBuilder = TransactionBuilder(notary)
.addOutputState(iouState, IOU_CONTRACT_ID)
.addCommand(txCommand)
// Stage 2.
progressTracker.currentStep = VERIFYING_TRANSACTION
// Verify that the transaction is valid.
txBuilder.verify(serviceHub)
// Stage 3.
progressTracker.currentStep = SIGNING_TRANSACTION
// Sign the transaction.
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)
// Stage 5.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(partSignedTx,emptyList()))
}
解决方案
我认为问题是因为您在该州使用对方:
val iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty)
Corda 4 要求所有参与者 flowsession 必须在 中提供FinalityFlow
,以便状态信息可以正确分发。
请参阅此处了解 我们未为以下交易参与者提供的更多流会话 - Corda 4
推荐阅读
- java - 如何使用 gradle 任务运行 shadow jar?
- java - 在文件 Java 中查找一定数量的子字符串
- twitter - tweepy 第一个程序:不识别 API 调用
- r - 如何在 R Studio 中将两个数据集合并为一个并用两个数据集绘制一张图
- algorithm - 二分图中边的均匀分布
- java - Java - 从 JPanel 扩展,在其中添加新面板
- linux - 将脚本加载到 /bin,然后删除,但仍然有效
- javascript - 即使在等待网页加载时也未捕获类型错误
- mysql - 将多个值插入一列,仅在其他列中插入一个 MySql Mamp
- laravel-5 - Laravel - 在 Web 根目录中仅放置公共文件夹只会出现空白屏幕