Corda观察员节点无法重新发行现金?

时间:2018-12-03 07:29:29

标签: corda

我正在尝试仅将特定状态保持为观察者节点的保管库状态。

在我的用例中,观察者是现金发行者,观察者在其中发行现金并转移到Corda网络中的其他节点。当Corda节点执行交易时,作为观察者的节点的所有现金状态也将保留在观察者节点上。

当尝试从Observer重新发行现金时,出现以下错误:

java.util.NoSuchElementException: Collection contains no element matching the predicate.
        at net.corda.node.services.keys.PersistentKeyManagementService.getSigningKeyPair(PersistentKeyManagementService.kt:110) ~[corda-node-3.3-corda.jar:?]
        at net.corda.node.services.keys.PersistentKeyManagementService.sign(PersistentKeyManagementService.kt:101) ~[corda-node-3.3-corda.jar:?]
        at net.corda.core.transactions.TransactionBuilder.toSignedTransaction(TransactionBuilder.kt:224) ~[corda-core-3.3-corda.jar:?]
        at net.corda.core.node.ServiceHub$DefaultImpls.signInitialTransaction(ServiceHub.kt:219) ~[corda-core-3.3-corda.jar:?]
        at net.corda.core.node.ServiceHub$DefaultImpls.signInitialTransaction(ServiceHub.kt:233) ~[corda-core-3.3-corda.jar:?]
        at net.corda.node.services.api.ServiceHubInternal$DefaultImpls.signInitialTransaction(ServiceHubInternal.kt) ~[corda-node-3.3-corda.jar:?]
        at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl.signInitialTransaction(AbstractNode.kt:836) ~[corda-node-3.3-corda.jar:?]
        at net.corda.core.node.ServiceHub$DefaultImpls.signInitialTransaction(ServiceHub.kt:255) ~[corda-core-3.3-corda.jar:?]
        at net.corda.node.services.api.ServiceHubInternal$DefaultImpls.signInitialTransaction(ServiceHubInternal.kt) ~[corda-node-3.3-corda.jar:?]
        at net.corda.node.internal.AbstractNode$ServiceHubInternalImpl.signInitialTransaction(AbstractNode.kt:836) ~[corda-node-3.3-corda.jar:?]
        at net.corda.finance.flows.CashPaymentFlow.call(CashPaymentFlow.kt:66) ~[corda-finance-3.3-corda.jar:?]
        at net.corda.finance.flows.CashPaymentFlow.call(CashPaymentFlow.kt:26) ~[corda-finance-3.3-corda.jar:?]
        at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:290) ~[corda-core-3.3-corda.jar:?]
        at net.corda.finance.flows.CashIssueAndPaymentFlow.call(CashIssueAndPaymentFlow.kt:41) ~[corda-finance-3.3-corda.jar:?]
        at net.corda.finance.flows.CashIssueAndPaymentFlow.call(CashIssueAndPaymentFlow.kt:24) ~[corda-finance-3.3-corda.jar:?]
        at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.3-corda.jar:?]
        at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.3-corda.jar:?]
        at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
        at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]

我想从观察者节点重新发行新现金,但是它尝试使用未消耗现金状态在观察交易期间保持不变。我认为观察员不能发行或转移现金。

编辑:

在调节器节点上,通过API如下调用CashIssueAndPaymentFlow:

rpcOps.startFlow(::CashIssueAndPaymentFlow, issueAmount, OpaqueBytes.of(0), toTransferNode, false, notaryIdentity).returnValue.get()

在其他节点流上将事务发送给观察者:

val observer = serviceHub.networkMapCache.getPeerByLegalName(CordaX500Name.parse(FundTransferConstants.OBSERVER_NAME)) ?: throw IllegalArgumentException("Unknown observer name.")
        subFlow(BroadcastTransactionTransfer.BroadcastTransactionToObserversTransfer(finalTx, listOf(observer)))

场景如下:

  1. 使用调节器节点上的CashIssueAndPaymentFlow进行现金发行和转移到节点。

  2. 进行涉及现金的交易,并将交易发送给观察者(监管者)。现金是使用Cash.generateSpend()

  3. 支付给另一方的
  4. 再次尝试重新发行现金,出现上述问题。

我认为git的类似问题发布在https://github.com/corda/corda/issues/4368

在这方面需要帮助。

1 个答案:

答案 0 :(得分:0)

当您致电ServiceHub.signInitialTransaction而不传递特定密钥时,平台会尝试使用您节点的默认密钥对交易进行签名:

fun signInitialTransaction(builder: TransactionBuilder): SignedTransaction = 
    signInitialTransaction(builder, legalIdentityKey)

private val legalIdentityKey: PublicKey get() = 
    this.myInfo.legalIdentitiesAndCerts.first().owningKey

由于观察者节点不是签名者之一(例如,因为他们不是现金的所有者),因此抛出此异常。