我正在使用Corda版本4。
我的CorDapp有四个节点-公证节点(正在验证),“节点A”,“节点B”和“节点C”。以下是应用程序中定义的流程-
流程1:“节点A”签名并向“节点B”发送交易请求。还通知“节点C”。
以下是我对流程1的代码:
val tx = TransactionBuilder(notary).withItems(
StateAndContract(tradeProposal, IOU_CONTRACT_ID),
Command(IOUContract.Commands.Issue(), listOf(tradeProposal.sender.owningKey)))
.addAttachment(secHash)
tx.setTimeWindow(serviceHub.clock.instant(), 180.seconds)
val signedTx = serviceHub.signInitialTransaction(tx)
signedTx.verify(serviceHub)
val NodeBFlow = initiateFlow(NodeB)
val NodeCFlow = initiateFlow(NodeC)
subFlow(FinalityFlow(signedTx, listOf(NodeBFlow ,NodeCFlow )))
return signedTx.tx.outRef<State>(0)
流程2:“节点B”批准交易请求,对其自签名,从A获得签名并结束交易。还通知“节点C”。
val tx = TransactionBuilder(notary).
withItems(
latestRecord,
StateAndContract(newState, IOU_CONTRACT_ID),
Command(IOUContract.Commands.Completed(),
newState.participants.map { it.owningKey }))
tx.setTimeWindow(serviceHub.clock.instant(), 600.seconds)
tx.verify(serviceHub)
val partSignedTx = serviceHub.signInitialTransaction(tx)
val NodeAFlow = initiateFlow(newState.sender)
val NodeCFlow = initiateFlow(newState.recipient2)
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(NodeAFlow ,NodeCFlow)))
return subFlow(FinalityFlow(fullySignedTx, listOf(NodeAFlow ,NodeCFlow)))
执行流1时出现以下错误-
Missing signatures on transaction 58C11D for keys: aL9YufujsPipKTb8fjj897654322ogVS1s67PBWD3vn2fGzjUbEnN, by signers: notary
net.corda.core.transactions.SignedTransaction$SignaturesMissingException: Missing signatures on transaction 58C11D for keys: aL9YufujsPipKTb8fjj897654322ogVS1s67PBWD3vn2fGzjUbEnN, by signers: notary
答案 0 :(得分:2)
公证人会抛出该错误,因为NodeC包含在FinalityFlow中(它将交易发送到公证人),但是它不是事务签名者的一部分
如果要通知节点C而不使其成为事务的必需参与者和签字者,则要使用“观察者”类型的设置,可以在此处找到代码示例:
https://docs.corda.net/tutorial-observer-nodes.html