如何将安全哈希传递给交易生成器

How to pass secure hash to transaction builder

我将一个文件上传到 Corda 节点并得到以下十六进制值作为字符串返回:

854AAE9BE6607CE0B15A70EEBEF19C553557103FB051413F2AA35E70F5B44313

现在我需要将其作为 secureHash 参数传递给交易生成器: txBuilder.addAttachment(??).

如何从文件上传获得的十六进制字符串结果作为输入参数构建安全散列到addAttachment..?

SecureHash 具有 toString() 函数,可将 returns 散列为上述十六进制字符串。我需要使用上面的十六进制字符串创建安全哈希。

谢谢。

尝试对代码进行以下更新: 在 Hello World 教程中为 IOUFlow 添加了 attachId 参数。添加附件为 txBuilder.addAttachment(attachId)。请参阅下面的代码:

class IOUFlow(val iouValue: Int,
          val otherParty: Party, val attachId: SecureHash.SHA256) : 
 FlowLogic<Unit>() {

/** The progress tracker provides checkpoints indicating the progress of 
the flow to observers. */
override val progressTracker = ProgressTracker()

/** The flow logic is encapsulated within the call() method. */
@Suspendable
override fun call() {
    // We retrieve the notary identity from the network map.
    val notary = serviceHub.networkMapCache.notaryIdentities[0]
    val txBuilder = TransactionBuilder(notary = notary)
    txBuilder.addAttachment(attachId)
    ....
    }

已将附件上传到服务器并获得以下哈希值:

C5C84DADD15B2359EBDF0DFC6CCCAA48A0DBA3A04EFD8F03EB117186CC0B2D08

使用以下 shell 命令开始流程:

start IOUFlow iouValue: 99, otherParty: "O=PartyB,L=New York,C=US", attachId: C5C84DADD15B2359EBDF0DFC6CCCAA48A0DBA3A04EFD8F03EB117186CC0B2D08

Shell 只是用“>”响应,没有任何反应。必须使用 CTRL-C 才能返回 shell 提示符。

使用SecureHash.parse()将字符串转换为SecureHash