Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,6 @@ WalletModel::UnlockContext::~UnlockContext()
}
}

void WalletModel::UnlockContext::CopyFrom(UnlockContext&& rhs)
{
// Transfer context; old object no longer relocks wallet
*this = rhs;
rhs.relock = false;
}

bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
{
CCoinControl coin_control;
Expand Down
18 changes: 8 additions & 10 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class WalletModel : public QObject
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString());
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass);

// RAI object for unlocking wallet, returned by requestUnlock()
// RAII object for unlocking wallet, returned by requestUnlock()
class UnlockContext
{
public:
Expand All @@ -120,18 +120,16 @@ class WalletModel : public QObject

bool isValid() const { return valid; }

// Copy constructor is disabled.
// Disable unused copy/move constructors/assignments explicitly.
UnlockContext(const UnlockContext&) = delete;
// Move operator and constructor transfer the context
UnlockContext(UnlockContext&& obj) { CopyFrom(std::move(obj)); }
UnlockContext& operator=(UnlockContext&& rhs) { CopyFrom(std::move(rhs)); return *this; }
UnlockContext(UnlockContext&&) = delete;
UnlockContext& operator=(const UnlockContext&) = delete;
UnlockContext& operator=(UnlockContext&&) = delete;

private:
WalletModel *wallet;
bool valid;
mutable bool relock; // mutable, as it can be set to false by copying

UnlockContext& operator=(const UnlockContext&) = default;
void CopyFrom(UnlockContext&& rhs);
const bool valid;
const bool relock;
};

UnlockContext requestUnlock();
Expand Down