Add sanity check on SignedTransaction.id

Add sanity check on SignedTransaction.id when deserializing the wrapped transaction. This
check is already done when verifying signatures, this moves it up to an earlier step and
adds a more specific error message to aid diagnosis.
This commit is contained in:
Ross Nicoll 2016-11-11 15:46:10 +00:00
parent d855b10817
commit cf6a3050c3

View File

@ -31,7 +31,11 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
// TODO: This needs to be reworked to ensure that the inner WireTransaction is only ever deserialised sandboxed.
/** Lazily calculated access to the deserialised/hashed transaction data. */
val tx: WireTransaction by lazy { WireTransaction.deserialize(txBits) }
val tx: WireTransaction by lazy {
val temp = WireTransaction.deserialize(txBits)
check(temp.id == id) { "Supplied transaction ID does not match deserialized transaction's ID - this is probably a problem in serialization/deserialization" }
temp
}
class SignaturesMissingException(val missing: Set<PublicKeyTree>, val descriptions: List<String>, override val id: SecureHash) : NamedByHash, SignatureException() {
override fun toString(): String {