Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions qa/rpc-tests/p2p-autoinstantsend.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def get_autoix_spork_state(self):
return info['SPORK_16_INSTANTSEND_AUTOLOCKS']

def set_autoix_spork_state(self, state):
set_mocktime(get_mocktime() + 1)
set_node_times(self.nodes, get_mocktime())
if state:
value = 0
else:
Expand Down Expand Up @@ -260,6 +262,10 @@ def check_IX_lock(self, txid):
def send_regular_IX(self):
receiver_addr = self.nodes[self.receiver_idx].getnewaddress()
txid = self.nodes[0].instantsendtoaddress(receiver_addr, 1.0)
MIN_FEE = satoshi_round(-0.0001)
fee = self.nodes[0].gettransaction(txid)['fee']
expected_fee = MIN_FEE * len(self.nodes[0].getrawtransaction(txid, True)['vin'])
assert_equal(fee, expected_fee)
return self.check_IX_lock(txid)


Expand Down Expand Up @@ -296,5 +302,12 @@ def run_test(self):
assert(self.send_simple_tx())
assert(not self.send_complex_tx())

self.set_autoix_spork_state(False)
assert(not self.get_autoix_spork_state())

assert(self.send_regular_IX())
assert(not self.send_simple_tx())
assert(not self.send_complex_tx())

if __name__ == '__main__':
AutoInstantSendTest().main()
6 changes: 3 additions & 3 deletions src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,17 +979,17 @@ bool CTxLockRequest::IsValid() const

CAmount nValueOut = tx->GetValueOut();

if (nValueIn - nValueOut < GetMinFee()) {
if (nValueIn - nValueOut < GetMinFee(false)) {
LogPrint("instantsend", "CTxLockRequest::IsValid -- did not include enough fees in transaction: fees=%d, tx=%s", nValueOut - nValueIn, ToString());
return false;
}

return true;
}

CAmount CTxLockRequest::GetMinFee() const
CAmount CTxLockRequest::GetMinFee(bool fForceMinFee) const
{
if (IsSimple()) {
if (!fForceMinFee && CInstantSend::CanAutoLock() && IsSimple()) {
return CAmount();
}
CAmount nMinFee = MIN_FEE;
Expand Down
2 changes: 1 addition & 1 deletion src/instantx.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class CTxLockRequest
}

bool IsValid() const;
CAmount GetMinFee() const;
CAmount GetMinFee(bool fForceMinFee) const;
int GetMaxSignatures() const;

// checks if related transaction is "simple" to lock it automatically
Expand Down
2 changes: 1 addition & 1 deletion src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nPayFee = coinControl->nMinimumTotalFee;

// InstantSend Fee
if (coinControl->fUseInstantSend) nPayFee = std::max(nPayFee, CTxLockRequest(txDummy).GetMinFee());
if (coinControl->fUseInstantSend) nPayFee = std::max(nPayFee, CTxLockRequest(txDummy).GetMinFee(true));

// Allow free? (require at least hard-coded threshold and default to that if no estimate)
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3408,7 +3408,7 @@ 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)
{
CAmount nFeePay = fUseInstantSend ? CTxLockRequest().GetMinFee() : 0;
CAmount nFeePay = fUseInstantSend ? CTxLockRequest().GetMinFee(true) : 0;

CAmount nValue = 0;
int nChangePosRequest = nChangePosInOut;
Expand Down Expand Up @@ -3751,7 +3751,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
nFeeNeeded = coinControl->nMinimumTotalFee;
}
if(fUseInstantSend) {
nFeeNeeded = std::max(nFeeNeeded, CTxLockRequest(txNew).GetMinFee());
nFeeNeeded = std::max(nFeeNeeded, CTxLockRequest(txNew).GetMinFee(true));
}
if (coinControl && coinControl->fOverrideFeeRate)
nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes);
Expand Down