mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge 23c926d859 into merged_master (Bitcoin PR #18699)
This commit is contained in:
commit
d4711bdf91
26 changed files with 278 additions and 239 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include <util/moneystr.h>
|
||||
#include <util/string.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
#include <util/url.h>
|
||||
#include <util/vector.h>
|
||||
#include <validation.h>
|
||||
|
|
@ -380,7 +381,7 @@ static CTransactionRef SendMoney(CWallet * const pwallet, const CTxDestination &
|
|||
|
||||
// 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, asset, GetDestinationBlindingKey(address), fSubtractFeeFromAmount};
|
||||
|
|
@ -388,10 +389,10 @@ static CTransactionRef SendMoney(CWallet * const pwallet, const CTxDestination &
|
|||
CTransactionRef tx;
|
||||
BlindDetails* blind_details = g_con_elementsmode ? new BlindDetails() : NULL;
|
||||
if (blind_details) blind_details->ignore_blind_failure = ignore_blind_fail;
|
||||
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, strError, coin_control, true, blind_details)) {
|
||||
if (!pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, error, coin_control, true, blind_details)) {
|
||||
if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance[policyAsset])
|
||||
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 */, blind_details);
|
||||
return tx;
|
||||
|
|
@ -1022,15 +1023,15 @@ static UniValue sendmany(const JSONRPCRequest& request)
|
|||
// Send
|
||||
CAmount nFeeRequired = 0;
|
||||
int nChangePosRet = -1;
|
||||
std::string strFailReason;
|
||||
bilingual_str error;
|
||||
CTransactionRef tx;
|
||||
BlindDetails* blind_details = g_con_elementsmode ? new BlindDetails() : NULL;
|
||||
if (g_con_elementsmode) {
|
||||
blind_details->ignore_blind_failure = ignore_blind_fail;
|
||||
}
|
||||
bool fCreated = pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, strFailReason, coin_control, true, blind_details);
|
||||
bool fCreated = pwallet->CreateTransaction(vecSend, tx, nFeeRequired, nChangePosRet, error, coin_control, true, blind_details);
|
||||
if (!fCreated) {
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
|
||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, error.original);
|
||||
}
|
||||
|
||||
pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, blind_details);
|
||||
|
|
@ -2818,14 +2819,14 @@ static UniValue loadwallet(const JSONRPCRequest& request)
|
|||
}
|
||||
}
|
||||
|
||||
std::string error;
|
||||
std::vector<std::string> warning;
|
||||
std::shared_ptr<CWallet> const wallet = LoadWallet(*g_rpc_chain, location, error, warning);
|
||||
if (!wallet) throw JSONRPCError(RPC_WALLET_ERROR, error);
|
||||
bilingual_str error;
|
||||
std::vector<bilingual_str> warnings;
|
||||
std::shared_ptr<CWallet> const wallet = LoadWallet(*g_rpc_chain, location, error, warnings);
|
||||
if (!wallet) throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("name", wallet->GetName());
|
||||
obj.pushKV("warning", Join(warning, "\n"));
|
||||
obj.pushKV("warning", Join(warnings, "\n", OpOriginal));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -2934,12 +2935,12 @@ static UniValue createwallet(const JSONRPCRequest& request)
|
|||
}
|
||||
SecureString passphrase;
|
||||
passphrase.reserve(100);
|
||||
std::vector<std::string> warnings;
|
||||
std::vector<bilingual_str> warnings;
|
||||
if (!request.params[3].isNull()) {
|
||||
passphrase = request.params[3].get_str().c_str();
|
||||
if (passphrase.empty()) {
|
||||
// Empty string means unencrypted
|
||||
warnings.emplace_back("Empty string given as passphrase, wallet will not be encrypted.");
|
||||
warnings.emplace_back(Untranslated("Empty string given as passphrase, wallet will not be encrypted."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2950,14 +2951,14 @@ static UniValue createwallet(const JSONRPCRequest& request)
|
|||
flags |= WALLET_FLAG_DESCRIPTORS;
|
||||
}
|
||||
|
||||
std::string error;
|
||||
bilingual_str error;
|
||||
std::shared_ptr<CWallet> wallet;
|
||||
WalletCreationStatus status = CreateWallet(*g_rpc_chain, passphrase, flags, request.params[0].get_str(), error, warnings, wallet);
|
||||
switch (status) {
|
||||
case WalletCreationStatus::CREATION_FAILED:
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error);
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
case WalletCreationStatus::ENCRYPTION_FAILED:
|
||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error);
|
||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, error.original);
|
||||
case WalletCreationStatus::SUCCESS:
|
||||
break;
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
|
|
@ -2965,7 +2966,7 @@ static UniValue createwallet(const JSONRPCRequest& request)
|
|||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("name", wallet->GetName());
|
||||
obj.pushKV("warning", Join(warnings, "\n"));
|
||||
obj.pushKV("warning", Join(warnings, "\n", OpOriginal));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -3474,10 +3475,10 @@ void FundTransaction(CWallet* const pwallet, CMutableTransaction& tx, CAmount& f
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3806,7 +3807,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;
|
||||
|
|
@ -3816,19 +3817,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -3844,7 +3845,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());
|
||||
|
|
@ -3862,8 +3863,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);
|
||||
|
||||
|
|
@ -4922,12 +4923,12 @@ static UniValue upgradewallet(const JSONRPCRequest& request)
|
|||
version = request.params[0].get_int();
|
||||
}
|
||||
|
||||
std::string error;
|
||||
std::vector<std::string> warnings;
|
||||
bilingual_str error;
|
||||
std::vector<bilingual_str> warnings;
|
||||
if (!pwallet->UpgradeWallet(version, error, warnings)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error);
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
return error;
|
||||
return error.original;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -5872,8 +5873,8 @@ UniValue claimpegin(const JSONRPCRequest& request)
|
|||
bool accepted = ::AcceptToMemoryPool(mempool, acceptState, MakeTransactionRef(mtx),
|
||||
nullptr /* plTxnReplaced */, false /* bypass_limits */, pwallet->m_default_max_tx_fee, true /* test_accept */);
|
||||
if (!accepted) {
|
||||
std::string strError = strprintf("Error: The transaction was rejected! Reason given: %s", acceptState.ToString());
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
bilingual_str error = Untranslated(strprintf("Error: The transaction was rejected! Reason given: %s", acceptState.ToString()));
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
|
||||
// Send it
|
||||
|
|
@ -6250,12 +6251,12 @@ static CTransactionRef SendGenerationTransaction(const CScript& asset_script, co
|
|||
|
||||
CAmount nFeeRequired;
|
||||
int nChangePosRet = -1;
|
||||
std::string strError;
|
||||
bilingual_str error;
|
||||
CCoinControl dummy_control;
|
||||
BlindDetails blind_details;
|
||||
CTransactionRef tx_ref(MakeTransactionRef());
|
||||
if (!pwallet->CreateTransaction(vecSend, tx_ref, nFeeRequired, nChangePosRet, strError, dummy_control, true, &blind_details, issuance_details)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, strError);
|
||||
if (!pwallet->CreateTransaction(vecSend, tx_ref, nFeeRequired, nChangePosRet, error, dummy_control, true, &blind_details, issuance_details)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
|
||||
mapValue_t map_value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue