R3-无公证签名的Corda交易

问题描述 投票:0回答:2

我是Corda的新手,我想详细了解公证人的角色。根据文件中的说明,例如,甲方与乙方之间发生交易,公证人将签署交易,公证人的作用是防止双重支出。我们可以进行没有公证签名的交易吗?在TransactionBuilder类中,它的说法是var notary:Party?用于交易的公证人。如果为null,则表明交易记录没有公证人。根据语法,我们可以将其设置为null,如果将其设置为null,则交易是否有效以及corda如何防止双重支出。如果我误解了这个概念,请纠正我。

corda
2个回答
0
投票

我同意阿德尔对他提到的案件的公证签名要求的回答。除此之外,交易需要与公证人相关联,它不应为null。

[一个人可能认为不需要公证人的情况是签发国家。实际上,不需要公证人签名,但是,交易仍需要公证人,因为需要将状态标记为公证人,以防止在消耗状态时发生任何双花。

如果未附加任何公证人,则可以将状态发送给其他公证人,这可能导致双花。

您可以在TransactionBuilder的addOutput方法中对此进行验证:

fun addOutputState(
    state: ContractState,
    contract: ContractClassName = requireNotNullContractClassName(state),
    constraint: AttachmentConstraint = AutomaticPlaceholderConstraint
): TransactionBuilder {
    checkNotNull(notary) { "Need to specify a notary for the state, or set a default one on TransactionBuilder initialisation" }
    addOutputState(state, contract, notary!!, constraint = constraint)
    return this
}

0
投票

仅在以下情况下需要公证签名:

  1. 如果您的交易中有投入,请证明未消耗这些投入,以防止重复支出。
  2. 如果您的交易具有参考状态:证明未使用那些参考状态,从而防止使用“过时”参考数据。
  3. 如果您的交易有时间窗口:证明交易已在指定的时间窗口内完成。

您可以在here中看到needsNotarySignature()函数FinalityFlow,证明了上述几点。

© www.soinside.com 2019 - 2024. All rights reserved.