Skip to content

Commit fef41ab

Browse files
committed
Fixed locking order for tpos. Fixed nLastPowBlock for testnet and mainnet which were breaking reindex
1 parent 4217067 commit fef41ab

7 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/chainparams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CMainParams : public CChainParams {
7373
public:
7474
CMainParams() {
7575
strNetworkID = "main";
76+
consensus.nLastPoWBlock = 75;
7677
consensus.nFirstBlocksEmpty = 20000;
7778
consensus.nSubsidyHalvingInterval = 43200; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050)
7879
consensus.nMasternodePaymentsStartBlock = 20100; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
@@ -102,7 +103,6 @@ class CMainParams : public CChainParams {
102103
consensus.nStakeMaxAge = 60 * 60 * 24; // one day
103104
consensus.nCoinbaseMaturity = 20;
104105
consensus.nTPoSContractSignatureDeploymentTime = 1523127600;
105-
consensus.nLastPoWBlock = 75;
106106
consensus.nPowKGWHeight = 15200;
107107
consensus.nPowDGWHeight = 24;
108108
consensus.fPowAllowMinDifficultyBlocks = false;
@@ -204,6 +204,7 @@ class CTestNetParams : public CChainParams {
204204
public:
205205
CTestNetParams() {
206206
strNetworkID = "test";
207+
consensus.nLastPoWBlock = 75;
207208
consensus.nSubsidyHalvingInterval = 10000;
208209
consensus.nFirstBlocksEmpty = 20;
209210
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
@@ -233,7 +234,6 @@ class CTestNetParams : public CChainParams {
233234
consensus.fPowNoRetargeting = false;
234235
consensus.nPowKGWHeight = 4001; // nPowKGWHeight >= nPowDGWHeight means "no KGW"
235236
consensus.nPowDGWHeight = 4001;
236-
consensus.nLastPoWBlock = 75;
237237
consensus.nStakeMinAge = 60 * 60;
238238
consensus.nStakeMaxAge = 60 * 60 * 24; // one day
239239
consensus.nCoinbaseMaturity = 20;

src/qt/tposaddressestablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ TPoSAddressesTableModel::Entry TPoSAddressesTableModel::GetAmountForAddress(CBit
197197
for (auto &&walletTx : walletInterface.getWalletTxs())
198198
{
199199
const auto& tx = *walletTx.tx;
200-
if (tx.IsCoinBase() || !CheckFinalTx(tx))
200+
if (tx.IsCoinBase())
201201
continue;
202202

203203
for(size_t i = 0; i < tx.vout.size(); ++i)

src/qt/walletframe.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ void WalletFrame::unlockWallet()
206206
walletView->unlockWallet();
207207
}
208208

209+
void WalletFrame::lockWallet()
210+
{
211+
WalletView *walletView = currentWalletView();
212+
if (walletView)
213+
walletView->lockWallet();
214+
}
215+
209216
void WalletFrame::usedSendingAddresses()
210217
{
211218
WalletView *walletView = currentWalletView();

src/qt/walletframe.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public Q_SLOTS:
8989
void changePassphrase();
9090
/** Ask for passphrase to unlock wallet temporarily */
9191
void unlockWallet();
92+
/** Lock wallet */
93+
void lockWallet();
9294

9395
/** Show used sending addresses */
9496
void usedSendingAddresses();

src/qt/walletview.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ void WalletView::unlockWallet()
326326
}
327327
}
328328

329+
void WalletView::lockWallet()
330+
{
331+
if(!walletModel)
332+
return;
333+
334+
walletModel->setWalletLocked(true);
335+
}
336+
329337
void WalletView::usedSendingAddresses()
330338
{
331339
if(!walletModel)

src/qt/walletview.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public Q_SLOTS:
112112
void changePassphrase();
113113
/** Ask for passphrase to unlock wallet temporarily */
114114
void unlockWallet();
115+
/** Lock wallet */
116+
void lockWallet();
115117

116118
/** Show used sending addresses */
117119
void usedSendingAddresses();

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class CAffectedKeysVisitor : public boost::static_visitor<void> {
152152

153153
void CWallet::LoadContractsFromDB()
154154
{
155+
LOCK(cs_wallet);
155156
for(auto &&contractTx : std::move(tposContractsTxLoadedFromDB))
156157
{
157158
if(!LoadTPoSContract(contractTx))

0 commit comments

Comments
 (0)