Skip to content

Commit

Permalink
Replace Sequentia mode with No Coin feature flag (g_con_sequentiamode…
Browse files Browse the repository at this point in the history
… -> g_con_any_asset_fees)
  • Loading branch information
JBetz committed Apr 4, 2024
1 parent a7f0f76 commit 0d0ec93
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)

// ELEMENTS:
policyAsset = CAsset(uint256S(gArgs.GetArg("-feeasset", chainparams.GetConsensus().pegged_asset.GetHex())));
if (g_con_sequentiamode) {
if (g_con_any_asset_fees) {
std::string file_path_string = gArgs.GetArg("-exchangeratesjsonfile", "");
if (!file_path_string.empty()) {
fs::path file_path = AbsPathForConfigVal(fs::PathFromString(file_path_string));
Expand Down
2 changes: 1 addition & 1 deletion src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
CMutableTransaction coinbaseTx;
coinbaseTx.vin.resize(1);
coinbaseTx.vin[0].prevout.SetNull();
if (g_con_sequentiamode && feeMap.size() > 0) {
if (g_con_any_asset_fees && feeMap.size() > 0) {
coinbaseTx.vout.resize(feeMap.size());
int index = 0;
for (auto fee : feeMap) {
Expand Down
3 changes: 1 addition & 2 deletions src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include <assert.h>

bool g_con_elementsmode = false;
// TODO: Default to false and override using new chain params class for Sequentia
bool g_con_sequentiamode = true;
bool g_con_any_asset_fees = false;

const int32_t CTransaction::CURRENT_VERSION = 2;

Expand Down
4 changes: 1 addition & 3 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;
// ELEMENTS:
// Globals to avoid circular dependencies.
extern bool g_con_elementsmode;

// SEQUENTIA:
extern bool g_con_sequentiamode;
extern bool g_con_any_asset_fees;

/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/rawtransaction_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
CAmount nAmount = AmountFromValue(output[name_]);
out.nValue = nAmount;

// SEQUENTIA: Allow fees in any asset
if (g_con_sequentiamode && output.exists("fee_asset")) {
if (g_con_any_asset_fees && output.exists("fee_asset")) {
// Override policy asset for fee payment
out.nAsset = CAsset(ParseHashO(output, "fee_asset"));
}
out.scriptPubKey = CScript();
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ UniValue AmountMapToUniv(const CAmountMap& balanceOrig, std::string strasset)
{
// Make sure the policyAsset is always present in the balance map.
CAmountMap balance = balanceOrig;
if (!g_con_sequentiamode) {
if (!g_con_any_asset_fees) {
balance[::policyAsset] += 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
int64_t nSigOpsCost = GetTransactionSigOpCost(tx, m_view, STANDARD_SCRIPT_VERIFY_FLAGS);

CAsset feeAsset;
if (g_con_sequentiamode) {
if (g_con_any_asset_fees) {
feeAsset = fee_map.begin()->first;
} else {
feeAsset = policyAsset;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/receive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
if (mapDebit > CAmountMap()) // debit>0 means we signed/sent this transaction
{
CAmountMap feeMap = GetFeeMap(*wtx.tx);
nFeeAsset = g_con_sequentiamode ? feeMap.begin()->first : ::policyAsset;
nFeeAsset = g_con_any_asset_fees ? feeMap.begin()->first : ::policyAsset;
nFee = -feeMap[nFeeAsset];
}

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 @@ -239,7 +239,7 @@ RPCHelpMan sendtoaddress()
SetFeeEstimateMode(*pwallet, coin_control, /* conf_target */ request.params[6], /* estimate_mode */ request.params[7], /* fee_rate */ request.params[11], /* override_min_fee */ false);

CAsset feeAsset = asset;
if (g_con_sequentiamode) {
if (g_con_any_asset_fees) {
if (request.params.size() > 12 && request.params[12].isStr() && !request.params[12].get_str().empty()) {
std::string strFeeAsset = request.params[12].get_str();
feeAsset = GetAssetFromString(strFeeAsset);
Expand Down Expand Up @@ -596,7 +596,7 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out,
coinControl.fAllowWatchOnly = ParseIncludeWatchonly(NullUniValue, wallet);
}

if (g_con_sequentiamode && options.exists("fee_asset")) {
if (g_con_any_asset_fees && options.exists("fee_asset")) {
std::string strFeeAsset = options["fee_asset"].get_str();
CAsset feeAsset = GetAssetFromString(strFeeAsset);
if (feeAsset.IsNull()) {
Expand Down

0 comments on commit 0d0ec93

Please sign in to comment.