mirror of
https://github.com/corda/corda.git
synced 2024-12-20 21:43:14 +00:00
Add debugging information in case of missing signatures
This commit is contained in:
parent
17ae349f4d
commit
a2dff5488f
@ -12,6 +12,7 @@ import com.r3corda.core.serialization.serialize
|
|||||||
import com.r3corda.core.utilities.Emoji
|
import com.r3corda.core.utilities.Emoji
|
||||||
import java.security.PublicKey
|
import java.security.PublicKey
|
||||||
import java.security.SignatureException
|
import java.security.SignatureException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Views of a transaction as it progresses through the pipeline, from bytes loaded from disk/network to the object
|
* Views of a transaction as it progresses through the pipeline, from bytes loaded from disk/network to the object
|
||||||
@ -115,8 +116,20 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
|
|||||||
|
|
||||||
// Now examine the contents and ensure the sigs we have line up with the advertised list of signers.
|
// Now examine the contents and ensure the sigs we have line up with the advertised list of signers.
|
||||||
val missing = getMissingSignatures()
|
val missing = getMissingSignatures()
|
||||||
if (missing.isNotEmpty() && throwIfSignaturesAreMissing)
|
if (missing.isNotEmpty() && throwIfSignaturesAreMissing) {
|
||||||
throw SignatureException("Missing signatures on transaction ${id.prefixChars()} for: ${missing.map { it.toStringShort() }}")
|
// Take a best guess at where the signatures are required from, for debugging
|
||||||
|
// TODO: We need a much better way of structuring this data
|
||||||
|
val missingElements = ArrayList<String>()
|
||||||
|
this.tx.commands.forEach { command ->
|
||||||
|
if (command.signers.any { signer -> missing.contains(signer) })
|
||||||
|
missingElements.add(command.toString())
|
||||||
|
}
|
||||||
|
this.tx.notary?.owningKey.apply {
|
||||||
|
if (missing.contains(this))
|
||||||
|
missingElements.add("notary")
|
||||||
|
}
|
||||||
|
throw SignatureException("Missing signatures for ${missingElements} on transaction ${id.prefixChars()} for ${missing.map { it.toStringShort() }}")
|
||||||
|
}
|
||||||
|
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user