Skip to content

Commit

Permalink
Merge pull request #1387 from psgreco/elem-23.2.6-rc1
Browse files Browse the repository at this point in the history
Prepare 23.2.6 rc1
  • Loading branch information
delta1 authored Jan 24, 2025
2 parents 81ea480 + c315124 commit e0a68d9
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 46 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 23)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_BUILD, 5)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_BUILD, 6)
define(_CLIENT_VERSION_RC, 1)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2025)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elements-cli.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTS-CLI "1" "January 2025" "elements-cli v23.2.5" "User Commands"
.TH ELEMENTS-CLI "1" "January 2025" "elements-cli v23.2.6" "User Commands"
.SH NAME
elements-cli \- manual page for elements-cli v23.2.5
elements-cli \- manual page for elements-cli v23.2.6
.SH SYNOPSIS
.B elements-cli
[\fI\,options\/\fR] \fI\,<command> \/\fR[\fI\,params\/\fR] \fI\,Send command to Elements Core\/\fR
Expand All @@ -15,7 +15,7 @@ elements-cli \- manual page for elements-cli v23.2.5
.B elements-cli
[\fI\,options\/\fR] \fI\,help <command> Get help for a command\/\fR
.SH DESCRIPTION
Elements Core RPC client version v23.2.5
Elements Core RPC client version v23.2.6
.SH OPTIONS
.HP
\-?
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elements-qt.1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTS-QT "1" "January 2025" "elements-qt v23.2.5" "User Commands"
.TH ELEMENTS-QT "1" "January 2025" "elements-qt v23.2.6" "User Commands"
.SH NAME
elements-qt \- manual page for elements-qt v23.2.5
elements-qt \- manual page for elements-qt v23.2.6
.SH SYNOPSIS
.B elements-qt
[\fI\,command-line options\/\fR]
.SH DESCRIPTION
Elements Core version v23.2.5
Elements Core version v23.2.6
.SH OPTIONS
.HP
\-?
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elements-tx.1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTS-TX "1" "January 2025" "elements-tx v23.2.5" "User Commands"
.TH ELEMENTS-TX "1" "January 2025" "elements-tx v23.2.6" "User Commands"
.SH NAME
elements-tx \- manual page for elements-tx v23.2.5
elements-tx \- manual page for elements-tx v23.2.6
.SH SYNOPSIS
.B elements-tx
[\fI\,options\/\fR] \fI\,<hex-tx> \/\fR[\fI\,commands\/\fR] \fI\,Update hex-encoded Elements transaction\/\fR
.br
.B elements-tx
[\fI\,options\/\fR] \fI\,-create \/\fR[\fI\,commands\/\fR] \fI\,Create hex-encoded Elements transaction\/\fR
.SH DESCRIPTION
Elements Core elements\-tx utility version v23.2.5
Elements Core elements\-tx utility version v23.2.6
.SH OPTIONS
.HP
\-?
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elements-util.1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTS-UTIL "1" "January 2025" "elements-util v23.2.5" "User Commands"
.TH ELEMENTS-UTIL "1" "January 2025" "elements-util v23.2.6" "User Commands"
.SH NAME
elements-util \- manual page for elements-util v23.2.5
elements-util \- manual page for elements-util v23.2.6
.SH SYNOPSIS
.B bitcoin-util
[\fI\,options\/\fR] [\fI\,commands\/\fR] \fI\,Do stuff\/\fR
.SH DESCRIPTION
Elements Core bitcoin\-util utility version v23.2.5
Elements Core bitcoin\-util utility version v23.2.6
.SH OPTIONS
.HP
\-?
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elements-wallet.1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTS-WALLET "1" "January 2025" "elements-wallet v23.2.5" "User Commands"
.TH ELEMENTS-WALLET "1" "January 2025" "elements-wallet v23.2.6" "User Commands"
.SH NAME
elements-wallet \- manual page for elements-wallet v23.2.5
elements-wallet \- manual page for elements-wallet v23.2.6
.SH DESCRIPTION
Elements Core elements\-wallet version v23.2.5
Elements Core elements\-wallet version v23.2.6
.PP
elements\-wallet is an offline tool for creating and interacting with Elements Core wallet files.
By default elements\-wallet will act on wallets in the default mainnet wallet directory in the datadir.
Expand Down
6 changes: 3 additions & 3 deletions doc/man/elementsd.1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3.
.TH ELEMENTSD "1" "January 2025" "elementsd v23.2.5" "User Commands"
.TH ELEMENTSD "1" "January 2025" "elementsd v23.2.6" "User Commands"
.SH NAME
elementsd \- manual page for elementsd v23.2.5
elementsd \- manual page for elementsd v23.2.6
.SH SYNOPSIS
.B elementsd
[\fI\,options\/\fR] \fI\,Start Elements Core\/\fR
.SH DESCRIPTION
Elements Core version v23.2.5
Elements Core version v23.2.6
.SH OPTIONS
.HP
\-?
Expand Down
8 changes: 6 additions & 2 deletions src/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ bool operator==(const CAmountMap& a, const CAmountMap& b);
bool operator!=(const CAmountMap& a, const CAmountMap& b);
bool operator!(const CAmountMap& a); // Check if all values are 0

inline bool MoneyRange(const CAmountMap& mapValue) {
inline bool MoneyRange(const CAmountMap& mapValue, const CAsset& pegged_asset) {
for(CAmountMap::const_iterator it = mapValue.begin(); it != mapValue.end(); it++) {
if (it->second < 0 || it->second > MAX_MONEY) {
if (it->second < 0 || ((pegged_asset.IsNull() || it->first == pegged_asset) && it->second > MAX_MONEY)) {
return false;
}
}
return true;
}

inline bool MoneyRange(const CAmountMap& mapValue) {
return MoneyRange(mapValue, CAsset());
}

CAmount valueFor(const CAmountMap& mapValue, const CAsset& asset);

std::ostream& operator<<(std::ostream& out, const CAmountMap& map);
Expand Down
15 changes: 9 additions & 6 deletions src/blind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <blind.h>
#include <chainparams.h>

#include <hash.h>
#include <primitives/transaction.h>
Expand Down Expand Up @@ -157,11 +158,6 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
return false;
}

// Value sidechannel must be a transaction-valid amount (should be belt-and-suspenders check)
if (amount > (uint64_t)MAX_MONEY || !MoneyRange((CAmount)amount)) {
return false;
}

// Convenience pointers to starting point of each recovered 32 byte message
unsigned char *asset_type = msg;
unsigned char *asset_blinder = msg+32;
Expand All @@ -172,6 +168,13 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
return false;
}

CAsset asset{std::vector<unsigned char>{asset_type, asset_type + 32}};

// Value sidechannel must be a transaction-valid amount (should be belt-and-suspenders check)
if ((!committedScript.IsUnspendable() && amount == 0) || (asset == Params().GetConsensus().pegged_asset && (amount > (uint64_t)MAX_MONEY || !MoneyRange((CAmount)amount)))) {
return false;
}

// Serialize both generators then compare
unsigned char observed_generator[33];
unsigned char derived_generator[33];
Expand All @@ -182,7 +185,7 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
}

amount_out = (CAmount)amount;
asset_out = CAsset(std::vector<unsigned char>(asset_type, asset_type+32));
asset_out = asset;
asset_blinding_factor_out = uint256(std::vector<unsigned char>(asset_blinder, asset_blinder+32));
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3050,7 +3050,7 @@ static RPCHelpMan rawissueasset()
CAmount asset_amount = 0;
const UniValue& asset_amount_uni = issuance_o["asset_amount"];
if (asset_amount_uni.isNum()) {
asset_amount = AmountFromValue(asset_amount_uni);
asset_amount = AmountFromValue(asset_amount_uni, false);
if (asset_amount <= 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, asset_amount must be positive");
}
Expand All @@ -3067,7 +3067,7 @@ static RPCHelpMan rawissueasset()
CAmount token_amount = 0;
const UniValue& token_amount_uni = issuance_o["token_amount"];
if (token_amount_uni.isNum()) {
token_amount = AmountFromValue(token_amount_uni);
token_amount = AmountFromValue(token_amount_uni, false);
if (token_amount <= 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, token_amount must be positive");
}
Expand Down Expand Up @@ -3178,7 +3178,7 @@ static RPCHelpMan rawreissueasset()
CAmount asset_amount = 0;
const UniValue& asset_amount_uni = issuance_o["asset_amount"];
if (asset_amount_uni.isNum()) {
asset_amount = AmountFromValue(asset_amount_uni);
asset_amount = AmountFromValue(asset_amount_uni, false);
if (asset_amount <= 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, asset_amount must be positive");
}
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ void RPCTypeCheckObj(const UniValue& o,
}
}

CAmount AmountFromValue(const UniValue& value, int decimals)
CAmount AmountFromValue(const UniValue& value, bool check_range, int decimals)
{
if (!value.isNum() && !value.isStr())
throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string");
CAmount amount;
if (!ParseFixedPoint(value.getValStr(), decimals, &amount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
if (!MoneyRange(amount))
if (amount < 0 || (check_range && !MoneyRange(amount)))
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range");
return amount;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey);
* @param[in] decimals Number of significant digits (default: 8).
* @returns a CAmount if the various checks pass.
*/
CAmount AmountFromValue(const UniValue& value, int decimals = 8);
CAmount AmountFromValue(const UniValue& value, bool check_range = true, int decimals = 8);

using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
std::string HelpExampleCli(const std::string& methodname, const std::string& args);
Expand Down
15 changes: 10 additions & 5 deletions src/wallet/receive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ CAmountMap TxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const ismine
{
LOCK(wallet.cs_wallet);

CAsset pegged_asset{Params().GetConsensus().pegged_asset};
for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i) {
if (wallet.IsMine(wtx.tx->vout[i]) & filter) {
CAsset asset{wtx.GetOutputAsset(wallet, i)};
CAmount credit = std::max<CAmount>(0, wtx.GetOutputValueOut(wallet, i));
if (!MoneyRange(credit))
if (asset == pegged_asset && !MoneyRange(credit)) {
throw std::runtime_error(std::string(__func__) + ": value out of range");
}

nCredit[wtx.GetOutputAsset(wallet, i)] += credit;
if (!MoneyRange(nCredit))
nCredit[asset] += credit;
if (!MoneyRange(nCredit, pegged_asset))
throw std::runtime_error(std::string(__func__) + ": value out of range");
}
}
Expand Down Expand Up @@ -226,16 +229,18 @@ CAmountMap CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wt
bool allow_used_addresses = (filter & ISMINE_USED) || !wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
CAmountMap nCredit;
uint256 hashTx = wtx.GetHash();
CAsset pegged_asset{Params().GetConsensus().pegged_asset};
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{
if (!wallet.IsSpent(hashTx, i) && (allow_used_addresses || !wallet.IsSpentKey(hashTx, i))) {
if (wallet.IsMine(wtx.tx->vout[i]) & filter) {
CAsset asset = wtx.GetOutputAsset(wallet, i);
CAmount credit = std::max<CAmount>(0, wtx.GetOutputValueOut(wallet, i));
if (!MoneyRange(credit))
if (asset == pegged_asset && !MoneyRange(credit))
throw std::runtime_error(std::string(__func__) + ": value out of range");

nCredit[wtx.GetOutputAsset(wallet, i)] += std::max<CAmount>(0, wtx.GetOutputValueOut(wallet, i));
if (!MoneyRange(nCredit))
if (!MoneyRange(nCredit, pegged_asset))
throw std::runtime_error(std::string(__func__) + ": value out of range");
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpc/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,8 @@ RPCHelpMan issueasset()
throw JSONRPCError(RPC_TYPE_ERROR, "Issuance can only be done on elements-style chains. Note: `-regtest` is Bitcoin's regtest mode, instead try `-chain=<custom chain name>`");
}

CAmount nAmount = AmountFromValue(request.params[0]);
CAmount nTokens = AmountFromValue(request.params[1]);
CAmount nAmount = AmountFromValue(request.params[0], false);
CAmount nTokens = AmountFromValue(request.params[1], false);
if (nAmount == 0 && nTokens == 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Issuance must have one non-zero component");
}
Expand Down Expand Up @@ -1524,7 +1524,7 @@ RPCHelpMan reissueasset()
std::string assetstr = request.params[0].get_str();
CAsset asset = GetAssetFromString(assetstr);

CAmount nAmount = AmountFromValue(request.params[1]);
CAmount nAmount = AmountFromValue(request.params[1], false);
if (nAmount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Reissuance must create a non-zero amount.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void ParseRecipients(const UniValue& address_amounts, const UniValue& add
destinations.insert(dest);

CScript script_pub_key = GetScriptForDestination(dest);
CAmount amount = AmountFromValue(address_amounts[i++]);
CAmount amount = AmountFromValue(address_amounts[i++], asset == Params().GetConsensus().pegged_asset);

bool subtract_fee = false;
for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); idx++) {
Expand Down Expand Up @@ -124,7 +124,7 @@ static void SetFeeEstimateMode(const CWallet& wallet, CCoinControl& cc, const Un
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify both estimate_mode and fee_rate");
}
// Fee rates in sat/vB cannot represent more than 3 significant digits.
cc.m_feerate = CFeeRate{AmountFromValue(fee_rate, /* decimals */ 3)};
cc.m_feerate = CFeeRate{AmountFromValue(fee_rate, /*check_range=*/true, /*decimals=*/3)};
if (override_min_fee) cc.fOverrideFeeRate = true;
// Default RBF to true for explicit fee_rate, if unset.
if (!cc.m_signal_bip125_rbf) cc.m_signal_bip125_rbf = true;
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ void AvailableCoins(const CWallet& wallet, std::vector<COutput> &vCoins, const C
if (asset_filter && asset != *asset_filter) {
continue;
}
if (outValue < nMinimumAmount || outValue > nMaximumAmount)
if (outValue < nMinimumAmount || (asset == Params().GetConsensus().pegged_asset && outValue > nMaximumAmount)) {
continue;
}

if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(entry.first, i)))
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ CAmountMap CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter)
for (const CTxIn& txin : tx.vin)
{
nDebit += GetDebit(txin, filter);
if (!MoneyRange(nDebit))
if (!MoneyRange(nDebit, Params().GetConsensus().pegged_asset))
throw std::runtime_error(std::string(__func__) + ": value out of range");
}
return nDebit;
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
'rpc_getnewblockhex.py',
'wallet_elements_regression_1172.py --legacy-wallet',
'wallet_elements_regression_1259.py --legacy-wallet',
'wallet_elements_21million.py',
'feature_trim_headers.py',
# Longest test should go first, to favor running tests in parallel
'wallet_hd.py --legacy-wallet',
Expand Down
Loading

0 comments on commit e0a68d9

Please sign in to comment.