33e460f306
* reserve colateral keey only if needed reserve colateral keey only if needed -> fix losing one key on every subsequent CreateDonominate * Adding KeyHolder and KeyHolderStorage Adding KeyHolder and KeyHolderStorage to store keys used in PrivateSend until status of mixing is known. * Removing ClearOn... methods. Instead of calling directly KeepAll/ReplaceAll. * remove usage of shared_ptr * use unique_ptr * follow naming convention * use CKeyHolderStorage in CreateDenominated too * adjust log messages * return keys on POOL_STATE_ERROR, keep keys on POOL_STATE_SUCCESS * Disable copy/assign and allow move * Use keyHolderStorageDenom for collateral output in CreateDenominated
38 lines
803 B
C++
38 lines
803 B
C++
// Copyright (c) 2014-2017 The Dash Core developers
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef PRIVATESENDUTIL_H
|
|
#define PRIVATESENDUTIL_H
|
|
|
|
#include "wallet/wallet.h"
|
|
|
|
class CKeyHolder
|
|
{
|
|
private:
|
|
CReserveKey reserveKey;
|
|
CPubKey pubKey;
|
|
public:
|
|
CKeyHolder(CWallet* pwalletIn);
|
|
CKeyHolder(CKeyHolder&&) = default;
|
|
CKeyHolder& operator=(CKeyHolder&&) = default;
|
|
void KeepKey();
|
|
void ReturnKey();
|
|
|
|
CScript GetScriptForDestination() const;
|
|
|
|
};
|
|
|
|
class CKeyHolderStorage
|
|
{
|
|
private:
|
|
std::vector<std::unique_ptr<CKeyHolder> > storage;
|
|
|
|
public:
|
|
const CKeyHolder& AddKey(CWallet* pwalletIn);
|
|
void KeepAll();
|
|
void ReturnAll();
|
|
|
|
};
|
|
#endif //PRIVATESENDUTIL_H
|