首先,我正在部署没有公证人的Corda网络,因为生成的事务将不使用任何输入状态或时间戳,并且由于我对Kotlin的了解有限,因此我正在用Java编写CorDapps。
在我的IOUFlow类的call()方法中(该方法实现了FlowLogic),创建了TransactionBuilder对象,并且未定义公证人。 项目成功编译,并且在节点启动时,它包含在cordapps文件夹中。 当我尝试创建事务时,问题出现了,应用程序给我一个错误。
请,有人可以看看我的Java代码并给我一些有关此问题的线索吗?
@Suspendable
@Override
public Void call() throws FlowException {
// We retrieve the notary identity from the network map.
//Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
@NotNull
Party notary = null;
// We create the transaction components.
IOUState outputState = new IOUState(iouAmount, iouCurrencyCode, bank, getOurIdentity(), recipient);
List<PublicKey> requiredSigners = Arrays.asList(bank.getOwningKey(), getOurIdentity().getOwningKey(), recipient.getOwningKey());
Command command = new Command<>(new IOUContractCreate.Create(), requiredSigners);
// We create a transaction builder and add the components.
//TransactionBuilder txBuilder = new TransactionBuilder(null).addOutputState(outputState, IOUContractCreate.ID).addCommand(command);
//TransactionBuilder txBuilder = new TransactionBuilder(notary).addOutputState(outputState, IOUContractCreate.ID).addCommand(command);
TransactionBuilder txBuilder = new TransactionBuilder(notary);
//txBuilder.setNotary(notary);
//txBuilder.addInputState(null);
txBuilder.addOutputState(outputState, IOUContractCreate.ID);
txBuilder.addCommand(command);
// Verifying the transaction.
txBuilder.verify(getServiceHub());
// Signing the transaction.
SignedTransaction signedTx = getServiceHub().signInitialTransaction(txBuilder);
// Creating a session with the other parties.
FlowSession bankFlowSession = initiateFlow(bank);
FlowSession recipientFlowSession = initiateFlow(recipient);
// Obtaining the counterparty's signature.
SignedTransaction fullySignedTx = subFlow(new CollectSignaturesFlow(signedTx, Arrays.asList(bankFlowSession, recipientFlowSession), CollectSignaturesFlow.tracker()));
// Finalising the transaction.
subFlow(new FinalityFlow(fullySignedTx, bankFlowSession, recipientFlowSession));
return null;
}
执行此命令时出错:启动IOUFlow iouAmount:99,iouCurrencyCode:“ USD”,bank:“ O = Bank,L = Philadelpia,C = US”,收件人:“ O = User2,L = Madrid,C = ES”
[ERROR] 2019-04-24T22:26:42,112Z [Node thread-1] proxies.ExceptionSerialisingRpcOpsProxy.log - Error during RPC invocation [errorCode=hq8kcg, moreInformationAt=https://errors.corda.net/OS/4.0/hq8kcg] {actor_id=internalShell, actor_owning_identity=O=User1, L=New York, C=US, actor_store_id=NODE_CONFIG, fiber-id=10000001, flow-id=d0b507d1-6497-4408-8afe-bab039e28543, invocation_id=657d59ff-4f41-4ab5-9288-4eeb9033604c, invocation_timestamp=2019-04-24T22:26:41.792Z, origin=internalShell, session_id=c4bd127e-0030-4b49-9cd0-d6a139601e87, session_timestamp=2019-04-24T22:26:41.283Z, thread-id=249}
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method net.corda.core.transactions.TransactionBuilder.<init>, parameter notary
at net.corda.core.transactions.TransactionBuilder.<init>(TransactionBuilder.kt) ~[corda-core-4.0.jar:?]
at com.template.flows.IOUFlow.call(IOUFlow.java:85) ~[?:?]
at com.template.flows.IOUFlow.call(IOUFlow.java:40) ~[?:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:228) ~[corda-node-4.0.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:45) ~[corda-node-4.0.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_202]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_202]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source) ~[?:1.8.0_202]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[?:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:1.8.0_202]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.0.jar:?]
答案 0 :(得分:1)
因此,您将变量声明为@NotNull并同时为其分配null。您应该删除该注释或此分配。
@NotNull
Party notary = null;