Skip to content

Commit

Permalink
New LLMQ-based IS should have no legacy IS strings in UI and no legac…
Browse files Browse the repository at this point in the history
…y restrictions (#2883)

(max value/too many inputs/additional fees)
  • Loading branch information
UdjinM6 committed Apr 29, 2019
1 parent 7f419ae commit 1951001
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ void SendCoinsDialog::on_sendButton_clicked()
strFunds = tr("using") + " <b>" + tr("any available funds (not anonymous)") + "</b>";
}

if(ui->checkUseInstantSend->isChecked()) {
if(model->IsOldInstantSendEnabled() && ui->checkUseInstantSend->isChecked()) {
strFunds += " ";
strFunds += tr("and InstantSend");
}

for (SendCoinsRecipient& rcp : recipients) {
rcp.inputType = ui->checkUsePrivateSend->isChecked() ? ONLY_DENOMINATED : ALL_COINS;
rcp.fUseInstantSend = ui->checkUseInstantSend->isChecked();
rcp.fUseInstantSend = model->IsOldInstantSendEnabled() && ui->checkUseInstantSend->isChecked();
}

fNewRecipientAllowed = false;
Expand Down Expand Up @@ -611,7 +611,7 @@ void SendCoinsDialog::updateInstantSend()
{
QSettings settings;
settings.setValue("bUseInstantX", ui->checkUseInstantSend->isChecked());
CoinControlDialog::coinControl->fUseInstantSend = ui->checkUseInstantSend->isChecked();
CoinControlDialog::coinControl->fUseInstantSend = model->IsOldInstantSendEnabled() && ui->checkUseInstantSend->isChecked();
coinControlUpdateLabels();
}

Expand Down
11 changes: 8 additions & 3 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ int WalletModel::getNumISLocks() const
return cachedNumISLocks;
}

bool WalletModel::IsOldInstantSendEnabled() const
{
return llmq::IsOldInstantSendEnabled();
}

void WalletModel::updateAddressBook(const QString &address, const QString &label,
bool isMine, const QString &purpose, int status)
{
Expand Down Expand Up @@ -314,7 +319,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
return AmountExceedsBalance;
}

if(recipients[0].fUseInstantSend && total > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
if(recipients[0].fUseInstantSend && IsOldInstantSendEnabled() && total > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
Q_EMIT message(tr("Send Coins"), tr("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 DASH.").arg(sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)),
CClientUIInterface::MSG_ERROR);
return TransactionCreationFailed;
Expand Down Expand Up @@ -344,7 +349,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
nVinSize = newTx->tx->vin.size();
}

if(recipients[0].fUseInstantSend) {
if(recipients[0].fUseInstantSend && IsOldInstantSendEnabled()) {
if(nValueOut > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
Q_EMIT message(tr("Send Coins"), tr("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 DASH.").arg(sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)),
CClientUIInterface::MSG_ERROR);
Expand Down Expand Up @@ -410,7 +415,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
CValidationState state;
// the new IX system does not require explicit IX messages
std::string strCommand = NetMsgType::TX;
if (recipients[0].fUseInstantSend && llmq::IsOldInstantSendEnabled()) {
if (recipients[0].fUseInstantSend && IsOldInstantSendEnabled()) {
strCommand = NetMsgType::TXLOCKREQUEST;
}
if(!wallet->CommitTransaction(*newTx, *keyChange, g_connman.get(), state, strCommand))
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ class WalletModel : public QObject
int getDefaultConfirmTarget() const;
int getNumISLocks() const;

bool IsOldInstantSendEnabled() const;

private:
CWallet *wallet;
bool fHaveWatchOnly;
Expand Down
12 changes: 12 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,12 @@ static void ApproximateBestSubset(std::vector<std::pair<CAmount, std::pair<const
vfBest.assign(vValue.size(), true);
nBest = nTotalLower;

if (!llmq::IsOldInstantSendEnabled()) {
// The new system does not require special handling for InstantSend as this is all done in CInstantSendManager.
// There is also no need for an extra fee anymore.
fUseInstantSend = false;
}

FastRandomContext insecure_rand;

for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++)
Expand Down Expand Up @@ -2662,6 +2668,12 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
setCoinsRet.clear();
nValueRet = 0;

if (!llmq::IsOldInstantSendEnabled()) {
// The new system does not require special handling for InstantSend as this is all done in CInstantSendManager.
// There is also no need for an extra fee anymore.
fUseInstantSend = false;
}

// List of values less than target
std::pair<CAmount, std::pair<const CWalletTx*,unsigned int> > coinLowestLarger;
coinLowestLarger.first = fUseInstantSend
Expand Down

0 comments on commit 1951001

Please sign in to comment.