Skip to content

Commit d96b000

Browse files
committed
Make GUI UTXO lock/unlock persistent
1 parent 077154f commit d96b000

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/interfaces/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Wallet
122122
virtual bool displayAddress(const CTxDestination& dest) = 0;
123123

124124
//! Lock coin.
125-
virtual bool lockCoin(const COutPoint& output) = 0;
125+
virtual bool lockCoin(const COutPoint& output, const bool write_to_db) = 0;
126126

127127
//! Unlock coin.
128128
virtual bool unlockCoin(const COutPoint& output) = 0;

src/qt/coincontroldialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void CoinControlDialog::lockCoin()
241241
contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
242242

243243
COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt());
244-
model->wallet().lockCoin(outpt);
244+
model->wallet().lockCoin(outpt, /* write_to_db = */ true);
245245
contextMenuItem->setDisabled(true);
246246
contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
247247
updateLabelLocked();

src/wallet/interfaces.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,17 @@ class WalletImpl : public Wallet
214214
LOCK(m_wallet->cs_wallet);
215215
return m_wallet->DisplayAddress(dest);
216216
}
217-
bool lockCoin(const COutPoint& output) override
217+
bool lockCoin(const COutPoint& output, const bool write_to_db) override
218218
{
219219
LOCK(m_wallet->cs_wallet);
220-
return m_wallet->LockCoin(output);
220+
std::unique_ptr<WalletBatch> batch = write_to_db ? std::make_unique<WalletBatch>(m_wallet->GetDatabase()) : nullptr;
221+
return m_wallet->LockCoin(output, batch.get());
221222
}
222223
bool unlockCoin(const COutPoint& output) override
223224
{
224225
LOCK(m_wallet->cs_wallet);
225-
return m_wallet->UnlockCoin(output);
226+
std::unique_ptr<WalletBatch> batch = std::make_unique<WalletBatch>(m_wallet->GetDatabase());
227+
return m_wallet->UnlockCoin(output, batch.get());
226228
}
227229
bool isLockedCoin(const COutPoint& output) override
228230
{

0 commit comments

Comments
 (0)