More stuff

This commit is contained in:
Duke Leto
2019-10-05 13:05:54 -04:00
parent 812078e212
commit cae920cf69
3 changed files with 15 additions and 81 deletions

View File

@@ -2487,45 +2487,6 @@ void CWalletTx::SetSaplingNoteData(mapSaplingNoteData_t &noteData)
}
}
std::pair<SproutNotePlaintext, SproutPaymentAddress> CWalletTx::DecryptSproutNote(
JSOutPoint jsop) const
{
LOCK(pwallet->cs_wallet);
auto nd = this->mapSproutNoteData.at(jsop);
SproutPaymentAddress pa = nd.address;
// Get cached decryptor
ZCNoteDecryption decryptor;
if (!pwallet->GetNoteDecryptor(pa, decryptor)) {
// Note decryptors are created when the wallet is loaded, so it should always exist
throw std::runtime_error(strprintf(
"Could not find note decryptor for payment address %s",
EncodePaymentAddress(pa)));
}
auto hSig = this->vjoinsplit[jsop.js].h_sig(*pzcashParams, this->joinSplitPubKey);
try {
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
decryptor,
this->vjoinsplit[jsop.js].ciphertexts[jsop.n],
this->vjoinsplit[jsop.js].ephemeralKey,
hSig,
(unsigned char) jsop.n);
return std::make_pair(plaintext, pa);
} catch (const note_decryption_failed &err) {
// Couldn't decrypt with this spending key
throw std::runtime_error(strprintf(
"Could not decrypt note for payment address %s",
EncodePaymentAddress(pa)));
} catch (const std::exception &exc) {
// Unexpected failure
throw std::runtime_error(strprintf(
"Error while decrypting note for payment address %s: %s",
EncodePaymentAddress(pa), exc.what()));
}
}
boost::optional<std::pair<
SaplingNotePlaintext,