Skip to content

Commit

Permalink
Merge fixes from core27 into evmone
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Oct 16, 2024
2 parents fc2908c + e264f63 commit 294e0f2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/rpc/mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static RPCHelpMan sendrawtransaction()
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
{"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
"Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
"/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
"/kvB.\nFee rates larger than 10QTUM/kvB are rejected.\nSet to 0 to accept any fee rate."},
{"maxburnamount", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(0)},
"Reject transactions with provably unspendable outputs (e.g. 'datacarrier' outputs that use the OP_RETURN opcode) greater than the specified value, expressed in " + CURRENCY_UNIT + ".\n"
"If burning funds through unspendable outputs is desired, increase this value.\n"
Expand Down Expand Up @@ -175,7 +175,7 @@ static RPCHelpMan testmempoolaccept()
},
{"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
"Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
"/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
"/kvB.\nFee rates larger than 10QTUM/kvB are rejected.\nSet to 0 to accept any fee rate."},
},
RPCResult{
RPCResult::Type::ARR, "", "The result of the mempool acceptance test for each raw transaction in the input array.\n"
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ CAmount AmountFromValue(const UniValue& value, int decimals)
CFeeRate ParseFeeRate(const UniValue& json)
{
CAmount val{AmountFromValue(json)};
if (val >= COIN) throw JSONRPCError(RPC_INVALID_PARAMETER, "Fee rates larger than or equal to 1BTC/kvB are not accepted");
// MAX(val) / DEFAULT_MAX_RAW_TX_FEE_RATE = 10, preserve the proportion
if (val >= 10 * COIN) throw JSONRPCError(RPC_INVALID_PARAMETER, "Fee rates larger than or equal to 10QTUM/kvB are not accepted");
return CFeeRate{val};
}

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ util::Result<CreatedTransactionResult> FundTransaction(CWallet& wallet, const CM
preset_txin.SetScriptWitness(txin.scriptWitness);
}

CAmount nGasFee = wallet.GetTxGasFee(tx);
CAmount nGasFee = wallet.GetTxGasFee(vecSend);
auto res = CreateTransaction(wallet, vecSend, change_pos, coinControl, false, nGasFee);
if (!res) {
return res;
Expand Down
11 changes: 11 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5666,4 +5666,15 @@ CAmount CWallet::GetTxGasFee(const CMutableTransaction& tx)
}
return 0;
}

CAmount CWallet::GetTxGasFee(const std::vector<CRecipient>& vecSend)
{
CMutableTransaction txNew;
for (const auto& recipient : vecSend)
{
CTxOut txout(recipient.nAmount, GetScriptForDestination(recipient.dest));
txNew.vout.push_back(txout);
}
return GetTxGasFee(txNew);
}
} // namespace wallet
1 change: 1 addition & 0 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

CAmount GetTxGasFee(const CMutableTransaction& tx);
CAmount GetTxGasFee(const std::vector<CRecipient>& vecSend);

bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
Expand Down

0 comments on commit 294e0f2

Please sign in to comment.