diff options
author | Samuel Dobson <dobsonsa68@gmail.com> | 2021-09-23 14:54:02 +1200 |
---|---|---|
committer | Samuel Dobson <dobsonsa68@gmail.com> | 2021-09-25 23:50:06 +1200 |
commit | d96b000e94d72d041689c5c47e374df2ebc0e011 (patch) | |
tree | 893d38948a7073c2902bf4520bcb49ae9013b2cf | |
parent | 077154fe698f5556ad6e26ef49c9024c2f07ff68 (diff) |
Make GUI UTXO lock/unlock persistent
-rw-r--r-- | src/interfaces/wallet.h | 2 | ||||
-rw-r--r-- | src/qt/coincontroldialog.cpp | 2 | ||||
-rw-r--r-- | src/wallet/interfaces.cpp | 8 |
3 files changed, 7 insertions, 5 deletions
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index f92d100ef5..6766e0510f 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -122,7 +122,7 @@ public: virtual bool displayAddress(const CTxDestination& dest) = 0; //! Lock coin. - virtual bool lockCoin(const COutPoint& output) = 0; + virtual bool lockCoin(const COutPoint& output, const bool write_to_db) = 0; //! Unlock coin. virtual bool unlockCoin(const COutPoint& output) = 0; diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index d2a9365890..86dbd05b1a 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -241,7 +241,7 @@ void CoinControlDialog::lockCoin() contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt()); - model->wallet().lockCoin(outpt); + model->wallet().lockCoin(outpt, /* write_to_db = */ true); contextMenuItem->setDisabled(true); contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); updateLabelLocked(); diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 809569cfaa..d9fc6de79b 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -214,15 +214,17 @@ public: LOCK(m_wallet->cs_wallet); return m_wallet->DisplayAddress(dest); } - bool lockCoin(const COutPoint& output) override + bool lockCoin(const COutPoint& output, const bool write_to_db) override { LOCK(m_wallet->cs_wallet); - return m_wallet->LockCoin(output); + std::unique_ptr<WalletBatch> batch = write_to_db ? std::make_unique<WalletBatch>(m_wallet->GetDatabase()) : nullptr; + return m_wallet->LockCoin(output, batch.get()); } bool unlockCoin(const COutPoint& output) override { LOCK(m_wallet->cs_wallet); - return m_wallet->UnlockCoin(output); + std::unique_ptr<WalletBatch> batch = std::make_unique<WalletBatch>(m_wallet->GetDatabase()); + return m_wallet->UnlockCoin(output, batch.get()); } bool isLockedCoin(const COutPoint& output) override { |