neobytes/src/privatesend-util.h
UdjinM6 33e460f306 Fix losing keys on PrivateSend (#1616)
* 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
2017-09-11 17:14:55 +03:00

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