mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-26 00:41:23 +02:00
wallet: Avoid translating RPC errors when creating txs
Also, mark feebumper bilingual_str as Untranslated They are technical and have previously not been translated either. It is questionable whether they can even appear in the GUI.
This commit is contained in:
parent
fae51a5c6f
commit
fae7776690
@ -219,7 +219,7 @@ public:
|
||||
bool sign,
|
||||
int& change_pos,
|
||||
CAmount& fee,
|
||||
std::string& fail_reason) override
|
||||
bilingual_str& fail_reason) override
|
||||
{
|
||||
LOCK(m_wallet->cs_wallet);
|
||||
CTransactionRef tx;
|
||||
@ -248,7 +248,7 @@ public:
|
||||
}
|
||||
bool createBumpTransaction(const uint256& txid,
|
||||
const CCoinControl& coin_control,
|
||||
std::vector<std::string>& errors,
|
||||
std::vector<bilingual_str>& errors,
|
||||
CAmount& old_fee,
|
||||
CAmount& new_fee,
|
||||
CMutableTransaction& mtx) override
|
||||
@ -258,7 +258,7 @@ public:
|
||||
bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(*m_wallet.get(), mtx); }
|
||||
bool commitBumpTransaction(const uint256& txid,
|
||||
CMutableTransaction&& mtx,
|
||||
std::vector<std::string>& errors,
|
||||
std::vector<bilingual_str>& errors,
|
||||
uint256& bumped_txid) override
|
||||
{
|
||||
return feebumper::CommitTransaction(*m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
|
||||
|
@ -31,6 +31,7 @@ enum class TransactionError;
|
||||
enum isminetype : unsigned int;
|
||||
struct CRecipient;
|
||||
struct PartiallySignedTransaction;
|
||||
struct bilingual_str;
|
||||
typedef uint8_t isminefilter;
|
||||
|
||||
namespace interfaces {
|
||||
@ -136,7 +137,7 @@ public:
|
||||
bool sign,
|
||||
int& change_pos,
|
||||
CAmount& fee,
|
||||
std::string& fail_reason) = 0;
|
||||
bilingual_str& fail_reason) = 0;
|
||||
|
||||
//! Commit transaction.
|
||||
virtual void commitTransaction(CTransactionRef tx,
|
||||
@ -155,7 +156,7 @@ public:
|
||||
//! Create bump transaction.
|
||||
virtual bool createBumpTransaction(const uint256& txid,
|
||||
const CCoinControl& coin_control,
|
||||
std::vector<std::string>& errors,
|
||||
std::vector<bilingual_str>& errors,
|
||||
CAmount& old_fee,
|
||||
CAmount& new_fee,
|
||||
CMutableTransaction& mtx) = 0;
|
||||
@ -166,7 +167,7 @@ public:
|
||||
//! Commit bump transaction.
|
||||
virtual bool commitBumpTransaction(const uint256& txid,
|
||||
CMutableTransaction&& mtx,
|
||||
std::vector<std::string>& errors,
|
||||
std::vector<bilingual_str>& errors,
|
||||
uint256& bumped_txid) = 0;
|
||||
|
||||
//! Get a transaction.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <psbt.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/system.h> // for GetBoolArg
|
||||
#include <util/translation.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <wallet/wallet.h> // for CRecipient
|
||||
|
||||
@ -185,10 +186,10 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||
{
|
||||
CAmount nFeeRequired = 0;
|
||||
int nChangePosRet = -1;
|
||||
std::string strFailReason;
|
||||
bilingual_str error;
|
||||
|
||||
auto& newTx = transaction.getWtx();
|
||||
newTx = m_wallet->createTransaction(vecSend, coinControl, !wallet().privateKeysDisabled() /* sign */, nChangePosRet, nFeeRequired, strFailReason);
|
||||
newTx = m_wallet->createTransaction(vecSend, coinControl, !wallet().privateKeysDisabled() /* sign */, nChangePosRet, nFeeRequired, error);
|
||||
transaction.setTransactionFee(nFeeRequired);
|
||||
if (fSubtractFeeFromAmount && newTx)
|
||||
transaction.reassignAmounts(nChangePosRet);
|
||||
@ -199,8 +200,8 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||
{
|
||||
return SendCoinsReturn(AmountWithFeeExceedsBalance);
|
||||
}
|
||||
Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
|
||||
CClientUIInterface::MSG_ERROR);
|
||||
Q_EMIT message(tr("Send Coins"), QString::fromStdString(error.translated),
|
||||
CClientUIInterface::MSG_ERROR);
|
||||
return TransactionCreationFailed;
|
||||
}
|
||||
|
||||
@ -482,14 +483,14 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
||||
{
|
||||
CCoinControl coin_control;
|
||||
coin_control.m_signal_bip125_rbf = true;
|
||||
std::vector<std::string> errors;
|
||||
std::vector<bilingual_str> errors;
|
||||
CAmount old_fee;
|
||||
CAmount new_fee;
|
||||
CMutableTransaction mtx;
|
||||
if (!m_wallet->createBumpTransaction(hash, coin_control, errors, old_fee, new_fee, mtx)) {
|
||||
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Increasing transaction fee failed") + "<br />(" +
|
||||
(errors.size() ? QString::fromStdString(errors[0]) : "") +")");
|
||||
return false;
|
||||
(errors.size() ? QString::fromStdString(errors[0].translated) : "") +")");
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool create_psbt = m_wallet->privateKeysDisabled();
|
||||
@ -551,8 +552,8 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
||||
// commit the bumped transaction
|
||||
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
|
||||
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
|
||||
QString::fromStdString(errors[0])+")");
|
||||
return false;
|
||||
QString::fromStdString(errors[0].translated)+")");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,44 +3,45 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <interfaces/chain.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <wallet/feebumper.h>
|
||||
#include <wallet/fees.h>
|
||||
#include <wallet/wallet.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <wallet/feebumper.h>
|
||||
#include <wallet/fees.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
//! Check whether transaction has descendant in wallet or mempool, or has been
|
||||
//! mined, or conflicts with a mined transaction. Return a feebumper::Result.
|
||||
static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
|
||||
static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
|
||||
{
|
||||
if (wallet.HasWalletSpend(wtx.GetHash())) {
|
||||
errors.push_back("Transaction has descendants in the wallet");
|
||||
errors.push_back(Untranslated("Transaction has descendants in the wallet"));
|
||||
return feebumper::Result::INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
{
|
||||
if (wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
|
||||
errors.push_back("Transaction has descendants in the mempool");
|
||||
errors.push_back(Untranslated("Transaction has descendants in the mempool"));
|
||||
return feebumper::Result::INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
if (wtx.GetDepthInMainChain() != 0) {
|
||||
errors.push_back("Transaction has been mined, or is conflicted with a mined transaction");
|
||||
errors.push_back(Untranslated("Transaction has been mined, or is conflicted with a mined transaction"));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
if (!SignalsOptInRBF(*wtx.tx)) {
|
||||
errors.push_back("Transaction is not BIP 125 replaceable");
|
||||
errors.push_back(Untranslated("Transaction is not BIP 125 replaceable"));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
if (wtx.mapValue.count("replaced_by_txid")) {
|
||||
errors.push_back(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid")));
|
||||
errors.push_back(strprintf(Untranslated("Cannot bump transaction %s which was already bumped by transaction %s"), wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid")));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
|
||||
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
|
||||
isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
|
||||
if (!wallet.IsAllFromMe(*wtx.tx, filter)) {
|
||||
errors.push_back("Transaction contains inputs that don't belong to this wallet");
|
||||
errors.push_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
@ -57,7 +58,8 @@ static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWallet
|
||||
}
|
||||
|
||||
//! Check if the user provided a valid feeRate
|
||||
static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CFeeRate& newFeerate, const int64_t maxTxSize, std::vector<std::string>& errors) {
|
||||
static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CFeeRate& newFeerate, const int64_t maxTxSize, std::vector<bilingual_str>& errors)
|
||||
{
|
||||
// check that fee rate is higher than mempool's minimum fee
|
||||
// (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
|
||||
// This may occur if the user set fee_rate or paytxfee too low, if fallbackfee is too low, or, perhaps,
|
||||
@ -67,7 +69,7 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
|
||||
|
||||
if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
|
||||
errors.push_back(strprintf(
|
||||
"New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ",
|
||||
Untranslated("New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- "),
|
||||
FormatMoney(newFeerate.GetFeePerK()),
|
||||
FormatMoney(minMempoolFeeRate.GetFeePerK())));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
@ -86,14 +88,14 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
|
||||
CAmount minTotalFee = nOldFeeRate.GetFee(maxTxSize) + incrementalRelayFee.GetFee(maxTxSize);
|
||||
|
||||
if (new_total_fee < minTotalFee) {
|
||||
errors.push_back(strprintf("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)",
|
||||
errors.push_back(strprintf(Untranslated("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)"),
|
||||
FormatMoney(new_total_fee), FormatMoney(minTotalFee), FormatMoney(nOldFeeRate.GetFee(maxTxSize)), FormatMoney(incrementalRelayFee.GetFee(maxTxSize))));
|
||||
return feebumper::Result::INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CAmount requiredFee = GetRequiredFee(wallet, maxTxSize);
|
||||
if (new_total_fee < requiredFee) {
|
||||
errors.push_back(strprintf("Insufficient total fee (cannot be less than required fee %s)",
|
||||
errors.push_back(strprintf(Untranslated("Insufficient total fee (cannot be less than required fee %s)"),
|
||||
FormatMoney(requiredFee)));
|
||||
return feebumper::Result::INVALID_PARAMETER;
|
||||
}
|
||||
@ -101,8 +103,8 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
|
||||
// Check that in all cases the new fee doesn't violate maxTxFee
|
||||
const CAmount max_tx_fee = wallet.m_default_max_tx_fee;
|
||||
if (new_total_fee > max_tx_fee) {
|
||||
errors.push_back(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
|
||||
FormatMoney(new_total_fee), FormatMoney(max_tx_fee)));
|
||||
errors.push_back(strprintf(Untranslated("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)"),
|
||||
FormatMoney(new_total_fee), FormatMoney(max_tx_fee)));
|
||||
return feebumper::Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
@ -144,12 +146,12 @@ bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
|
||||
const CWalletTx* wtx = wallet.GetWalletTx(txid);
|
||||
if (wtx == nullptr) return false;
|
||||
|
||||
std::vector<std::string> errors_dummy;
|
||||
std::vector<bilingual_str> errors_dummy;
|
||||
feebumper::Result res = PreconditionChecks(wallet, *wtx, errors_dummy);
|
||||
return res == feebumper::Result::OK;
|
||||
}
|
||||
|
||||
Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<std::string>& errors,
|
||||
Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<bilingual_str>& errors,
|
||||
CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx)
|
||||
{
|
||||
// We are going to modify coin control later, copy to re-use
|
||||
@ -159,7 +161,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
||||
errors.clear();
|
||||
auto it = wallet.mapWallet.find(txid);
|
||||
if (it == wallet.mapWallet.end()) {
|
||||
errors.push_back("Invalid or non-wallet transaction id");
|
||||
errors.push_back(Untranslated("Invalid or non-wallet transaction id"));
|
||||
return Result::INVALID_ADDRESS_OR_KEY;
|
||||
}
|
||||
const CWalletTx& wtx = it->second;
|
||||
@ -216,9 +218,9 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
||||
CTransactionRef tx_new = MakeTransactionRef();
|
||||
CAmount fee_ret;
|
||||
int change_pos_in_out = -1; // No requested location for change
|
||||
std::string fail_reason;
|
||||
bilingual_str fail_reason;
|
||||
if (!wallet.CreateTransaction(recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, false)) {
|
||||
errors.push_back("Unable to create transaction: " + fail_reason);
|
||||
errors.push_back(Untranslated("Unable to create transaction: ") + Untranslated(" ") + fail_reason);
|
||||
return Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
@ -242,7 +244,7 @@ bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx) {
|
||||
return wallet.SignTransaction(mtx);
|
||||
}
|
||||
|
||||
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<std::string>& errors, uint256& bumped_txid)
|
||||
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, uint256& bumped_txid)
|
||||
{
|
||||
LOCK(wallet.cs_wallet);
|
||||
if (!errors.empty()) {
|
||||
@ -250,7 +252,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti
|
||||
}
|
||||
auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
|
||||
if (it == wallet.mapWallet.end()) {
|
||||
errors.push_back("Invalid or non-wallet transaction id");
|
||||
errors.push_back(Untranslated("Invalid or non-wallet transaction id"));
|
||||
return Result::MISC_ERROR;
|
||||
}
|
||||
CWalletTx& oldWtx = it->second;
|
||||
@ -275,7 +277,7 @@ Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransacti
|
||||
// along with an exception. It would be good to return information about
|
||||
// wtxBumped to the caller even if marking the original transaction
|
||||
// replaced does not succeed for some reason.
|
||||
errors.push_back("Created new bumpfee transaction but could not mark the original transaction as replaced");
|
||||
errors.push_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced"));
|
||||
}
|
||||
return Result::OK;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ class CWalletTx;
|
||||
class uint256;
|
||||
class CCoinControl;
|
||||
enum class FeeEstimateMode;
|
||||
struct bilingual_str;
|
||||
|
||||
namespace feebumper {
|
||||
|
||||
@ -30,12 +31,12 @@ bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid);
|
||||
|
||||
//! Create bumpfee transaction based on feerate estimates.
|
||||
Result CreateRateBumpTransaction(CWallet& wallet,
|
||||
const uint256& txid,
|
||||
const CCoinControl& coin_control,
|
||||
std::vector<std::string>& errors,
|
||||
CAmount& old_fee,
|
||||
CAmount& new_fee,
|
||||
CMutableTransaction& mtx);
|
||||
const uint256& txid,
|
||||
const CCoinControl& coin_control,
|
||||
std::vector<bilingual_str>& errors,
|
||||
CAmount& old_fee,
|
||||
CAmount& new_fee,
|
||||
CMutableTransaction& mtx);
|
||||
|
||||
//! Sign the new transaction,
|
||||
//! @return false if the tx couldn't be found or if it was
|
||||
@ -47,10 +48,10 @@ bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx);
|
||||
//! but sets errors if the tx could not be added to the mempool (will try later)
|
||||
//! or if the old transaction could not be marked as replaced.
|
||||
Result CommitTransaction(CWallet& wallet,
|
||||
const uint256& txid,
|
||||
CMutableTransaction&& mtx,
|
||||
std::vector<std::string>& errors,
|
||||
uint256& bumped_txid);
|
||||
const uint256& txid,
|
||||
CMutableTransaction&& mtx,
|
||||
std::vector<bilingual_str>& errors,
|
||||
uint256& bumped_txid);
|
||||
|
||||
} // namespace feebumper
|
||||
|
||||
|
@ -339,16 +339,16 @@ static CTransactionRef SendMoney(CWallet* const pwallet, const CTxDestination& a
|
||||
|
||||
// Create and send the transaction
|
||||
CAmount nFeeRequired = 0;
|
||||
std::string strError;
|
||||
bilingual_str error;
|
||||
std::vector<CRecipient> vecSend;
|
||||
int nChangePosRet = -1;
|
||||
CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount};
|
||||
vecSend.push_back(recipient);
|
||||
CTransactionRef tx;
|
||||
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, strError, coin_control)) {
|
||||
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, error, coin_control)) {
|
||||
if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance)
|
||||
strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
error = strprintf(Untranslated("Error: This transaction requires a transaction fee of at least %s"), FormatMoney(nFeeRequired));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */);
|
||||
return tx;
|
||||
@ -904,11 +904,11 @@ static UniValue sendmany(const JSONRPCRequest& request)
|
||||
// Send
|
||||
CAmount nFeeRequired = 0;
|
||||
int nChangePosRet = -1;
|
||||
std::string strFailReason;
|
||||
bilingual_str error;
|
||||
CTransactionRef tx;
|
||||
bool fCreated = pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, strFailReason, coin_control);
|
||||
bool fCreated = pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, error, coin_control);
|
||||
if (!fCreated)
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, error.original);
|
||||
pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */);
|
||||
return tx->GetHash().GetHex();
|
||||
}
|
||||
@ -3109,10 +3109,10 @@ void FundTransaction(CWallet* const pwallet, CMutableTransaction& tx, CAmount& f
|
||||
setSubtractFeeFromOutputs.insert(pos);
|
||||
}
|
||||
|
||||
std::string strFailReason;
|
||||
bilingual_str error;
|
||||
|
||||
if (!pwallet->FundTransaction(tx, fee_out, change_position, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
|
||||
if (!pwallet->FundTransaction(tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3418,7 +3418,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
|
||||
|
||||
std::vector<std::string> errors;
|
||||
std::vector<bilingual_str> errors;
|
||||
CAmount old_fee;
|
||||
CAmount new_fee;
|
||||
CMutableTransaction mtx;
|
||||
@ -3428,19 +3428,19 @@ static UniValue bumpfee(const JSONRPCRequest& request)
|
||||
if (res != feebumper::Result::OK) {
|
||||
switch(res) {
|
||||
case feebumper::Result::INVALID_ADDRESS_OR_KEY:
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, errors[0]);
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, errors[0].original);
|
||||
break;
|
||||
case feebumper::Result::INVALID_REQUEST:
|
||||
throw JSONRPCError(RPC_INVALID_REQUEST, errors[0]);
|
||||
throw JSONRPCError(RPC_INVALID_REQUEST, errors[0].original);
|
||||
break;
|
||||
case feebumper::Result::INVALID_PARAMETER:
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, errors[0]);
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, errors[0].original);
|
||||
break;
|
||||
case feebumper::Result::WALLET_ERROR:
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, errors[0]);
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
|
||||
break;
|
||||
default:
|
||||
throw JSONRPCError(RPC_MISC_ERROR, errors[0]);
|
||||
throw JSONRPCError(RPC_MISC_ERROR, errors[0].original);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3456,7 +3456,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
|
||||
|
||||
uint256 txid;
|
||||
if (feebumper::CommitTransaction(*pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, errors[0]);
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
|
||||
}
|
||||
|
||||
result.pushKV("txid", txid.GetHex());
|
||||
@ -3474,8 +3474,8 @@ static UniValue bumpfee(const JSONRPCRequest& request)
|
||||
result.pushKV("origfee", ValueFromAmount(old_fee));
|
||||
result.pushKV("fee", ValueFromAmount(new_fee));
|
||||
UniValue result_errors(UniValue::VARR);
|
||||
for (const std::string& error : errors) {
|
||||
result_errors.push_back(error);
|
||||
for (const bilingual_str& error : errors) {
|
||||
result_errors.push_back(error.original);
|
||||
}
|
||||
result.pushKV("errors", result_errors);
|
||||
|
||||
|
@ -516,7 +516,7 @@ public:
|
||||
CTransactionRef tx;
|
||||
CAmount fee;
|
||||
int changePos = -1;
|
||||
std::string error;
|
||||
bilingual_str error;
|
||||
CCoinControl dummy;
|
||||
{
|
||||
BOOST_CHECK(wallet->CreateTransaction({recipient}, tx, fee, changePos, error, dummy));
|
||||
|
@ -2521,7 +2521,7 @@ SigningResult CWallet::SignMessage(const std::string& message, const PKHash& pkh
|
||||
return SigningResult::PRIVATE_KEY_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl coinControl)
|
||||
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl coinControl)
|
||||
{
|
||||
std::vector<CRecipient> vecSend;
|
||||
|
||||
@ -2543,7 +2543,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
|
||||
LOCK(cs_wallet);
|
||||
|
||||
CTransactionRef tx_new;
|
||||
if (!CreateTransaction(vecSend, tx_new, nFeeRet, nChangePosInOut, strFailReason, coinControl, false)) {
|
||||
if (!CreateTransaction(vecSend, tx_new, nFeeRet, nChangePosInOut, error, coinControl, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2659,7 +2659,7 @@ OutputType CWallet::TransactionChangeType(OutputType change_type, const std::vec
|
||||
return m_default_address_type;
|
||||
}
|
||||
|
||||
bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, const CCoinControl& coin_control, bool sign)
|
||||
bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, bool sign)
|
||||
{
|
||||
CAmount nValue = 0;
|
||||
const OutputType change_type = TransactionChangeType(coin_control.m_change_type ? *coin_control.m_change_type : m_default_change_type, vecSend);
|
||||
@ -2670,7 +2670,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
{
|
||||
if (nValue < 0 || recipient.nAmount < 0)
|
||||
{
|
||||
strFailReason = _("Transaction amounts must not be negative").translated;
|
||||
error = _("Transaction amounts must not be negative");
|
||||
return false;
|
||||
}
|
||||
nValue += recipient.nAmount;
|
||||
@ -2680,7 +2680,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
}
|
||||
if (vecSend.empty())
|
||||
{
|
||||
strFailReason = _("Transaction must have at least one recipient").translated;
|
||||
error = _("Transaction must have at least one recipient");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2717,7 +2717,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
// destination in case we don't need change.
|
||||
CTxDestination dest;
|
||||
if (!reservedest.GetReservedDestination(dest, true)) {
|
||||
strFailReason = _("Transaction needs a change address, but we can't generate it. Please call keypoolrefill first.").translated;
|
||||
error = _("Transaction needs a change address, but we can't generate it. Please call keypoolrefill first.");
|
||||
}
|
||||
scriptChange = GetScriptForDestination(dest);
|
||||
assert(!dest.empty() || scriptChange.empty());
|
||||
@ -2779,12 +2779,12 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
if (recipient.fSubtractFeeFromAmount && nFeeRet > 0)
|
||||
{
|
||||
if (txout.nValue < 0)
|
||||
strFailReason = _("The transaction amount is too small to pay the fee").translated;
|
||||
error = _("The transaction amount is too small to pay the fee");
|
||||
else
|
||||
strFailReason = _("The transaction amount is too small to send after the fee has been deducted").translated;
|
||||
error = _("The transaction amount is too small to send after the fee has been deducted");
|
||||
}
|
||||
else
|
||||
strFailReason = _("Transaction amount too small").translated;
|
||||
error = _("Transaction amount too small");
|
||||
return false;
|
||||
}
|
||||
txNew.vout.push_back(txout);
|
||||
@ -2812,7 +2812,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
strFailReason = _("Insufficient funds").translated;
|
||||
error = _("Insufficient funds");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2843,7 +2843,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
}
|
||||
else if ((unsigned int)nChangePosInOut > txNew.vout.size())
|
||||
{
|
||||
strFailReason = _("Change index out of range").translated;
|
||||
error = _("Change index out of range");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2862,14 +2862,14 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
|
||||
nBytes = CalculateMaximumSignedTxSize(CTransaction(txNew), this, coin_control.fAllowWatchOnly);
|
||||
if (nBytes < 0) {
|
||||
strFailReason = _("Signing transaction failed").translated;
|
||||
error = _("Signing transaction failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
nFeeNeeded = GetMinimumFee(*this, nBytes, coin_control, &feeCalc);
|
||||
if (feeCalc.reason == FeeReason::FALLBACK && !m_allow_fallback_fee) {
|
||||
// eventually allow a fallback fee
|
||||
strFailReason = _("Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.").translated;
|
||||
error = _("Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2909,7 +2909,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
// fee to pay for the new output and still meet nFeeNeeded
|
||||
// Or we should have just subtracted fee from recipients and
|
||||
// nFeeNeeded should not have changed
|
||||
strFailReason = _("Transaction fee and change calculation failed").translated;
|
||||
error = _("Transaction fee and change calculation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2962,7 +2962,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
}
|
||||
|
||||
if (sign && !SignTransaction(txNew)) {
|
||||
strFailReason = _("Signing transaction failed").translated;
|
||||
error = _("Signing transaction failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2972,20 +2972,20 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||
// Limit size
|
||||
if (GetTransactionWeight(*tx) > MAX_STANDARD_TX_WEIGHT)
|
||||
{
|
||||
strFailReason = _("Transaction too large").translated;
|
||||
error = _("Transaction too large");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (nFeeRet > m_default_max_tx_fee) {
|
||||
strFailReason = TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED);
|
||||
error = Untranslated(TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
|
||||
// Lastly, ensure this tx will pass the mempool's chain limits
|
||||
if (!chain().checkChainLimits(tx)) {
|
||||
strFailReason = _("Transaction has too long of a mempool chain").translated;
|
||||
error = _("Transaction has too long of a mempool chain");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ public:
|
||||
* Insert additional inputs into the transaction by
|
||||
* calling CreateTransaction();
|
||||
*/
|
||||
bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
|
||||
bool FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl);
|
||||
// Fetch the inputs and sign with SIGHASH_ALL.
|
||||
bool SignTransaction(CMutableTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
// Sign the tx given the input coins and sighash.
|
||||
@ -963,7 +963,7 @@ public:
|
||||
* selected by SelectCoins(); Also create the change output, when needed
|
||||
* @note passing nChangePosInOut as -1 will result in setting a random position
|
||||
*/
|
||||
bool CreateTransaction(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, const CCoinControl& coin_control, bool sign = true);
|
||||
bool CreateTransaction(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, bool sign = true);
|
||||
/**
|
||||
* Submit the transaction to the node's mempool and then relay to peers.
|
||||
* Should be called after CreateTransaction unless you want to abort
|
||||
|
Loading…
x
Reference in New Issue
Block a user