Implement note locking for z_mergetoaddress
Co-authored-by: Eirik Ogilvie-Wigley <eirik@z.cash>
This commit is contained in:
@@ -3437,6 +3437,42 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note Locking Operations
|
||||
|
||||
void CWallet::LockNote(JSOutPoint& output)
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setLockedNotes
|
||||
setLockedNotes.insert(output);
|
||||
}
|
||||
|
||||
void CWallet::UnlockNote(JSOutPoint& output)
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setLockedNotes
|
||||
setLockedNotes.erase(output);
|
||||
}
|
||||
|
||||
void CWallet::UnlockAllNotes()
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setLockedNotes
|
||||
setLockedNotes.clear();
|
||||
}
|
||||
|
||||
bool CWallet::IsLockedNote(uint256 hash, size_t js, uint8_t n) const
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setLockedNotes
|
||||
JSOutPoint outpt(hash, js, n);
|
||||
|
||||
return (setLockedNotes.count(outpt) > 0);
|
||||
}
|
||||
|
||||
std::vector<JSOutPoint> CWallet::ListLockedNotes()
|
||||
{
|
||||
AssertLockHeld(cs_wallet); // setLockedNotes
|
||||
std::vector<JSOutPoint> vOutpts(setLockedNotes.begin(), setLockedNotes.end());
|
||||
return vOutpts;
|
||||
}
|
||||
|
||||
/** @} */ // end of Actions
|
||||
|
||||
class CAffectedKeysVisitor : public boost::static_visitor<void> {
|
||||
@@ -3725,6 +3761,11 @@ void CWallet::GetFilteredNotes(
|
||||
if (ignoreUnspendable && !HaveSpendingKey(pa)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip locked notes
|
||||
if (IsLockedNote(jsop.hash, jsop.js, jsop.n)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int i = jsop.js; // Index into CTransaction.vjoinsplit
|
||||
int j = jsop.n; // Index into JSDescription.ciphertexts
|
||||
|
||||
Reference in New Issue
Block a user