我是Corda的新手,我想详细了解公证人的角色。根据文件中的说明,例如,甲方与乙方之间发生交易,公证人将签署交易,公证人的作用是防止双重支出。我们可以进行没有公证签名的交易吗?在TransactionBuilder类中,它的说法是var notary:Party?用于交易的公证人。如果为null,则表明交易记录没有公证人。根据语法,我们可以将其设置为null,如果将其设置为null,则交易是否有效以及corda如何防止双重支出。如果我误解了这个概念,请纠正我。
我同意阿德尔对他提到的案件的公证签名要求的回答。除此之外,交易需要与公证人相关联,它不应为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
}
仅在以下情况下需要公证签名:
您可以在here中看到needsNotarySignature()
函数FinalityFlow
,证明了上述几点。