Changes after review
This commit is contained in:
parent
0736fa14fc
commit
32a103aab7
|
@ -89,6 +89,6 @@ bool CBasicKeyStore::AddSpendingKey(const libzcash::SpendingKey &sk)
|
|||
LOCK(cs_SpendingKeyStore);
|
||||
auto address = sk.address();
|
||||
mapSpendingKeys[address] = sk;
|
||||
mapNoteDecryptors[address] = ZCNoteDecryption(sk.viewing_key());
|
||||
mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(sk.viewing_key())));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ TEST(wallet_tests, set_invalid_note_addrs_in_cwallettx) {
|
|||
CNoteData nd {sk.address(), uint256()};
|
||||
noteData[jsoutpt] = nd;
|
||||
|
||||
EXPECT_THROW(wtx.SetNoteData(noteData), std::runtime_error);
|
||||
EXPECT_THROW(wtx.SetNoteData(noteData), std::logic_error);
|
||||
}
|
||||
|
||||
TEST(wallet_tests, find_note_in_tx) {
|
||||
|
|
|
@ -601,6 +601,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
|||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
|
||||
CNoteData* nd = &(item.second);
|
||||
// Check the validity of the cache
|
||||
assert(nWitnessCacheSize >= nd->witnesses.size());
|
||||
// Copy the witness for the previous block if we have one
|
||||
if (nd->witnesses.size() > 0) {
|
||||
nd->witnesses.push_front(nd->witnesses.front());
|
||||
|
@ -1060,8 +1062,12 @@ mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const
|
|||
CNoteData nd {address, note.nullifier(key)};
|
||||
noteData.insert(std::make_pair(jsoutpt, nd));
|
||||
break;
|
||||
} catch (const std::exception &) {
|
||||
} catch (const std::runtime_error &) {
|
||||
// Couldn't decrypt with this spending key
|
||||
} catch (const std::exception &exc) {
|
||||
// Unexpected failure
|
||||
LogPrintf("FindMyNotes(): Unexpected error while testing decrypt:\n");
|
||||
LogPrintf("%s\n", exc.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1252,7 +1258,7 @@ void CWalletTx::SetNoteData(mapNoteData_t ¬eData)
|
|||
} else {
|
||||
// If FindMyNotes() was used to obtain noteData,
|
||||
// this should never happen
|
||||
throw std::runtime_error("CWalletTc::SetNoteData(): Invalid note");
|
||||
throw std::logic_error("CWalletTx::SetNoteData(): Invalid note");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ static const CAmount nHighTransactionMaxFeeWarning = 100 * nHighTransactionFeeWa
|
|||
//! Largest (in bytes) free transaction we're willing to create
|
||||
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
|
||||
//! Size of witness cache
|
||||
// Should be large enough that we can expect to never reorg beyond our cache.
|
||||
// Should be large enough that we can expect not to reorg beyond our cache
|
||||
// unless there is some exceptional network disruption.
|
||||
static const unsigned int WITNESS_CACHE_SIZE = COINBASE_MATURITY;
|
||||
|
||||
class CAccountingEntry;
|
||||
|
|
|
@ -23,8 +23,13 @@ public:
|
|||
READWRITE(pk_enc);
|
||||
}
|
||||
|
||||
friend inline bool operator==(const PaymentAddress& a, const PaymentAddress& b) { return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc; }
|
||||
friend inline bool operator<(const PaymentAddress& a, const PaymentAddress& b) { return a.a_pk < b.a_pk; }
|
||||
friend inline bool operator==(const PaymentAddress& a, const PaymentAddress& b) {
|
||||
return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc;
|
||||
}
|
||||
friend inline bool operator<(const PaymentAddress& a, const PaymentAddress& b) {
|
||||
return (a.a_pk < b.a_pk ||
|
||||
(a.a_pk == b.a_pk && a.pk_enc < b.pk_enc));
|
||||
}
|
||||
};
|
||||
|
||||
class ViewingKey : public uint256 {
|
||||
|
|
|
@ -61,7 +61,6 @@ public:
|
|||
typedef boost::array<unsigned char, CLEN> Ciphertext;
|
||||
typedef boost::array<unsigned char, MLEN> Plaintext;
|
||||
|
||||
// Unused default constructor to make allocators happy
|
||||
NoteDecryption() { }
|
||||
NoteDecryption(uint256 sk_enc);
|
||||
|
||||
|
@ -71,8 +70,13 @@ public:
|
|||
unsigned char nonce
|
||||
) const;
|
||||
|
||||
friend inline bool operator==(const NoteDecryption& a, const NoteDecryption& b) { return a.sk_enc == b.sk_enc && a.pk_enc == b.pk_enc; }
|
||||
friend inline bool operator<(const NoteDecryption& a, const NoteDecryption& b) { return a.pk_enc < b.pk_enc; }
|
||||
friend inline bool operator==(const NoteDecryption& a, const NoteDecryption& b) {
|
||||
return a.sk_enc == b.sk_enc && a.pk_enc == b.pk_enc;
|
||||
}
|
||||
friend inline bool operator<(const NoteDecryption& a, const NoteDecryption& b) {
|
||||
return (a.sk_enc < b.sk_enc ||
|
||||
(a.sk_enc == b.sk_enc && a.pk_enc < b.pk_enc));
|
||||
}
|
||||
};
|
||||
|
||||
uint256 random_uint256();
|
||||
|
|
Loading…
Reference in New Issue