Skip to content

Commit 28556f1

Browse files
committed
GUI: Add SPORK_20 check in sendCoins
1 parent ac6a6c8 commit 28556f1

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/qt/pivx/guitransactionsutils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ namespace GuiTransactionsUtils {
4646
retStr = QString::fromStdString(sendCoinsReturn.commitRes.ToString());
4747
informType = CClientUIInterface::MSG_ERROR;
4848
break;
49+
case WalletModel::SaplingInMaintenance:
50+
retStr = parent->translate("Sapling Protocol temporarily in maintenance. Shielded txes not allowed");
51+
informType = CClientUIInterface::MSG_ERROR;
52+
break;
4953
case WalletModel::StakingOnlyUnlocked:
5054
// Unlock is only need when the coins are send
5155
if (!fPrepare) {

src/qt/walletmodel.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ bool WalletModel::isColdStakingNetworkelyEnabled() const
7171
return !sporkManager.IsSporkActive(SPORK_19_COLDSTAKING_MAINTENANCE);
7272
}
7373

74+
bool WalletModel::isSaplingInMaintenance() const
75+
{
76+
return sporkManager.IsSporkActive(SPORK_20_SAPLING_MAINTENANCE);
77+
}
78+
7479
bool WalletModel::isStakingStatusActive() const
7580
{
7681
return wallet && wallet->pStakerStatus && wallet->pStakerStatus->IsActive();
@@ -458,14 +463,17 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction& tran
458463
bool fSaplingActive = Params().GetConsensus().NetworkUpgradeActive(cachedNumBlocks, Consensus::UPGRADE_V5_DUMMY);
459464

460465
// Double check tx before do anything
466+
CWalletTx* newTx = transaction.getTransaction();
467+
if (newTx->IsShieldedTx() && isSaplingInMaintenance()) {
468+
return SaplingInMaintenance;
469+
}
461470
CValidationState state;
462-
if (!CheckTransaction(*transaction.getTransaction(), true, true, state, true, fColdStakingActive, fSaplingActive)) {
471+
if (!CheckTransaction(*newTx, true, true, state, true, fColdStakingActive, fSaplingActive)) {
463472
return TransactionCheckFailed;
464473
}
465474

466475
{
467476
LOCK2(cs_main, wallet->cs_wallet);
468-
CWalletTx* newTx = transaction.getTransaction();
469477
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
470478

471479
// Store PaymentRequests in wtx.vOrderForm in wallet.

src/qt/walletmodel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class WalletModel : public QObject
129129
TransactionCreationFailed,
130130
TransactionCheckFailed,
131131
TransactionCommitFailed,
132+
SaplingInMaintenance,
132133
StakingOnlyUnlocked,
133134
InsaneFee,
134135
CannotCreateInternalAddress
@@ -150,6 +151,7 @@ class WalletModel : public QObject
150151
bool isRegTestNetwork() const;
151152
/** Whether cold staking is enabled or disabled in the network **/
152153
bool isColdStakingNetworkelyEnabled() const;
154+
bool isSaplingInMaintenance() const;
153155
CAmount getMinColdStakingAmount() const;
154156
/* current staking status from the miner thread **/
155157
bool isStakingStatusActive() const;

0 commit comments

Comments
 (0)