Skip to content

Commit

Permalink
Disable explicit lock requests when the new IX system is active
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Mar 7, 2019
1 parent 68cfdc9 commit dc97835
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "instantx.h"
#include "spork.h"
#include "privatesend-client.h"
#include "llmq/quorums_instantsend.h"

#include <stdint.h>

Expand Down Expand Up @@ -389,7 +390,12 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran

CReserveKey *keyChange = transaction.getPossibleKeyChange();
CValidationState state;
if(!wallet->CommitTransaction(*newTx, *keyChange, g_connman.get(), state, recipients[0].fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX))
// the new IX system does not require explicit IX messages
std::string strCommand = NetMsgType::TX;
if (recipients[0].fUseInstantSend && llmq::IsOldInstantSendEnabled()) {
strCommand = NetMsgType::TXLOCKREQUEST;
}
if(!wallet->CommitTransaction(*newTx, *keyChange, g_connman.get(), state, strCommand))
return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(state.GetRejectReason()));

CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
Expand Down
14 changes: 12 additions & 2 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,12 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}
CValidationState state;
if (!pwallet->CommitTransaction(wtxNew, reservekey, g_connman.get(), state, fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX)) {
// the new IX system does not require explicit IX messages
std::string strCommand = NetMsgType::TX;
if (fUseInstantSend && llmq::IsOldInstantSendEnabled()) {
strCommand = NetMsgType::TXLOCKREQUEST;
}
if (!pwallet->CommitTransaction(wtxNew, reservekey, g_connman.get(), state, strCommand)) {
strError = strprintf("Error: The transaction was rejected! Reason given: %s", state.GetRejectReason());
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}
Expand Down Expand Up @@ -1136,7 +1141,12 @@ UniValue sendmany(const JSONRPCRequest& request)
if (!fCreated)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
CValidationState state;
if (!pwallet->CommitTransaction(wtx, keyChange, g_connman.get(), state, fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX)) {
// the new IX system does not require explicit IX messages
std::string strCommand = NetMsgType::TX;
if (fUseInstantSend && llmq::IsOldInstantSendEnabled()) {
strCommand = NetMsgType::TXLOCKREQUEST;
}
if (!pwallet->CommitTransaction(wtx, keyChange, g_connman.get(), state, strCommand)) {
strFailReason = strprintf("Transaction commit failed:: %s", state.GetRejectReason());
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
}
Expand Down
6 changes: 6 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,12 @@ bool CWallet::ConvertList(std::vector<CTxIn> vecTxIn, std::vector<CAmount>& vecA
bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
int& nChangePosInOut, std::string& strFailReason, const CCoinControl* coinControl, bool sign, AvailableCoinsType nCoinType, bool fUseInstantSend, int nExtraPayloadSize)
{
if (!llmq::IsOldInstantSendEnabled()) {
// The new system does not require special handling for InstantSend as this is all done in CInstantXManager.
// There is also no need for an extra fee anymore.
fUseInstantSend = false;
}

CAmount nFeePay = fUseInstantSend ? CTxLockRequest().GetMinFee(true) : 0;

CAmount nValue = 0;
Expand Down

0 comments on commit dc97835

Please sign in to comment.