Throw error in plaintext deserialization
This commit is contained in:
parent
f24e706079
commit
2f4d7e35c9
|
@ -196,15 +196,18 @@ boost::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
|||
}
|
||||
|
||||
// Deserialize from the plaintext
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << pt.get();
|
||||
|
||||
SaplingOutgoingPlaintext ret;
|
||||
ss >> ret;
|
||||
|
||||
assert(ss.size() == 0);
|
||||
|
||||
return ret;
|
||||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
|
@ -290,13 +293,18 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
|
|||
};
|
||||
|
||||
// Deserialize from the plaintext
|
||||
SaplingNotePlaintext plaintext;
|
||||
SaplingNotePlaintext ret;
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << encPlaintext.get();
|
||||
ss >> plaintext;
|
||||
ss >> ret;
|
||||
assert(ss.size() == 0);
|
||||
|
||||
return plaintext;
|
||||
return ret;
|
||||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
|
@ -384,13 +392,18 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
|
|||
};
|
||||
|
||||
// Deserialize from the plaintext
|
||||
SaplingNotePlaintext plaintext;
|
||||
SaplingNotePlaintext ret;
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << encPlaintext.get();
|
||||
ss >> plaintext;
|
||||
ss >> ret;
|
||||
assert(ss.size() == 0);
|
||||
|
||||
return plaintext;
|
||||
return ret;
|
||||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintextEncryptionResult> SaplingNotePlaintext::encrypt(const uint256& pk_d) const
|
||||
|
|
|
@ -213,7 +213,12 @@ public:
|
|||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
READWRITE(leadbyte); // 1 byte
|
||||
READWRITE(leadbyte);
|
||||
|
||||
if (leadbyte != 0x01 && leadbyte != 0x02) {
|
||||
throw std::ios_base::failure("lead byte of SaplingNotePlaintext is not recognized");
|
||||
}
|
||||
|
||||
READWRITE(d); // 11 bytes
|
||||
READWRITE(value_); // 8 bytes
|
||||
READWRITE(rseed); // 32 bytes
|
||||
|
|
Loading…
Reference in New Issue