0
votes

I'm deploying a corda network using two different machines: in the first I'm deploying a notary and an oracle service using the following configuration:

Notary

myLegalName="O=Notary,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip1:10004"
notary : {
    validating : false
}
devMode : true

Oracle

myLegalName="O=Oracle,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip1:10001"
rpcSettings {
    address="0.0.0.0:10002"
    adminAddress="0.0.0.0:10003"
}
rpcUsers=[
    {
        password=test
        permissions=[
            ALL
        ]
        user=user1
    }
]
devMode : true

In the second I'm deploying the following party node:

Party

myLegalName="O=Party,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip2:10001"
rpcSettings {
    address="0.0.0.0:10002"
    adminAddress="0.0.0.0:10003"
}
rpcUsers=[
    {
        password=test
        permissions=[
            ALL
        ]
        user=user1
    }
]
devMode : true

Once Party starts a flow building a transaction it fails raising this exception:

java.lang.IllegalStateException: Need to specify a notary for the state, or set a default one on TransactionBuilder 
        at net.corda.core.transactions.TransactionBuilder.addOutputState(TransactionBuilder.kt:172) 
        at net.corda.core.transactions.TransactionBuilder.addOutputState$default(TransactionBuilder.kt:171) 

The call function is :

override fun call(): SignedTransaction {

    val notary = serviceHub.networkMapCache.getNotary(CordaX500Name("Notary", "London", "GB"))!!

    val issueState = CashOwningState(amount, ourIdentity)
    val issueCommand = Command(
        CashIssueContract.Commands.Issue(),
        issueState.participants.map { it.owningKey })

    val txBuilder = TransactionBuilder(notary).withItems(
        StateAndContract(issueState, CashIssueContract.TEST_CONTRACT_ID),
        issueCommand)

    txBuilder.verify(serviceHub)

    val fullySignedTx = serviceHub.signInitialTransaction(txBuilder)

    return subFlow(FinalityFlow(fullySignedTx, FINALIZING_TX.childProgressTracker()))
}

It seems that the Notary is found in the network, but the CordApp doesn't recognize it as a notary.

1

1 Answers

0
votes

This is not an issue of the CorDapp not recognising the notary. The only place this exception is thrown is here:

@JvmOverloads
fun addOutputState(state: ContractState, contract: ContractClassName, constraint: AttachmentConstraint = AutomaticHashConstraint): 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
}

When instantiating a TransactionBuilder by passing in a notary, no check is performed for whether the party being passed is in fact a notary.

You must be trying to add an output state to a TransactionBuilder without a notary somewhere else in your code.