Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regtest: Relax minting #2952

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/dfi/consensus/tokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ ResVal<CScript> CTokensConsensus::MintableToken(DCT_ID id,
}

if (id == DCT_ID{0}) {
if (IsRegtestNetwork()) {
ResVal<CScript> result{auth.out.scriptPubKey, Res::Ok()};
return result;
}
return Res::Err("can't mint default DFI coin!");
}

Expand All @@ -60,6 +64,7 @@ ResVal<CScript> CTokensConsensus::MintableToken(DCT_ID id,
static const auto isMainNet = Params().NetworkIDString() == CBaseChainParams::MAIN;
// may be different logic with LPS, so, dedicated check:
auto &mnview = blockCtx.GetView();

if (!token.IsMintable() || (isMainNet && !fMockNetwork && mnview.GetLoanTokenByID(id))) {
return Res::Err("token %s is not mintable!", id.ToString());
}
Expand Down Expand Up @@ -219,7 +224,7 @@ Res CTokensConsensus::operator()(const CMintTokensMessage &obj) const {

CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::MintTokens};
const auto attributes = mnview.GetAttributes();
const auto toAddressEnabled = attributes->GetValue(enabledKey, false);
const auto toAddressEnabled = attributes->GetValue(enabledKey, IsRegtestNetwork() ? true : false);

if (!toAddressEnabled && !obj.to.empty()) {
return Res::Err("Mint tokens to address is not enabled");
Expand Down
Loading