Reputation: 23140
In a Corda flow, I am receiving and verifying a transaction as follows:
@InitiatedBy(Initiator::class)
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
val stx = counterpartySession.receive<SignedTransaction>().unwrap { it }
stx.verify(serviceHub, false)
}
}
However, this is throwing the following exception:
net.corda.core.contracts.TransactionResolutionException: Transaction resolution failure for 3D90346DD7F7397479312EF4DD5A4741F4CA31C2070BC4F8A0588974B1CD1523
What is the cause of this TransactionResolutionException
, and how can I fix it?
Upvotes: 2
Views: 366
Reputation: 372
In the node you are verifying you don't have the TransactionState
that the passed input references too.
It is not correct to pass transaction for signing using Send
or SendAndReceive
.
It is better to use flows SendTransactionFlow
and ReceiveTransactionFlow
which will download the states those inputs reference.
If you can't send a SignedTransaction
as above flows require (because for example you are sending a FilteredTransaction
), you can send it with FlowSession.send()
method, but the owner of the input responds with SendStateAndRefFlow
flow, and the requester can receive it ReceiveStateAndRefFlow
to add the inputs on the original transaction.
This will allow to have the referenced states of the inputs in all nodes, allowing you to verify the transaction.
Upvotes: 0
Reputation: 23140
When a node verifies a transaction, it doesn't just verify the transaction itself. It also verifies the entire transaction chain. A TransactionResolutionException
indicates that one or more of the transactions in the transaction chain is missing and cannot be verified.
To avoid this, you should send transactions using SendTransactionFlow
, and receive transactions using ReceiveTransactionFlow
. This flow pair does two things:
Upvotes: 1