diff --git a/src/masternodes/tokens.cpp b/src/masternodes/tokens.cpp index 2c6364659d6..bb927ffb579 100644 --- a/src/masternodes/tokens.cpp +++ b/src/masternodes/tokens.cpp @@ -135,7 +135,7 @@ Res CTokensView::RevertCreateToken(const uint256 & txid) return Res::Ok(); } -Res CTokensView::UpdateToken(const CTokenImpl& newToken, bool isPreBayfront, const bool skipNameValidation) +Res CTokensView::UpdateToken(const CTokenImpl& newToken, bool isPreBayfront, const bool tokenSplitUpdate) { auto pair = GetTokenByCreationTx(newToken.creationTx); if (!pair) { @@ -152,7 +152,7 @@ Res CTokensView::UpdateToken(const CTokenImpl& newToken, bool isPreBayfront, con oldToken.name = newToken.name; // check new symbol correctness - if (!skipNameValidation) { + if (!tokenSplitUpdate) { auto checkSymbolRes = newToken.IsValidSymbol(); if (!checkSymbolRes.ok) { return checkSymbolRes; @@ -186,6 +186,9 @@ Res CTokensView::UpdateToken(const CTokenImpl& newToken, bool isPreBayfront, con if (!oldToken.IsFinalized() && newToken.IsFinalized()) // IsFinalized() itself was checked upthere (with Err) oldToken.flags |= (uint8_t)CToken::TokenFlags::Finalized; + if (tokenSplitUpdate && oldToken.IsLoanToken() != newToken.IsLoanToken()) + oldToken.flags ^= (uint8_t)CToken::TokenFlags::LoanToken; + if (oldToken.destructionHeight != newToken.destructionHeight) { oldToken.destructionHeight = newToken.destructionHeight; } diff --git a/src/masternodes/tokens.h b/src/masternodes/tokens.h index 5416b320e6a..d75c53af74a 100644 --- a/src/masternodes/tokens.h +++ b/src/masternodes/tokens.h @@ -151,7 +151,7 @@ class CTokensView : public virtual CStorageView Res CreateDFIToken(); ResVal CreateToken(CTokenImpl const & token, bool isPreBayfront = false); Res RevertCreateToken(uint256 const & txid); - Res UpdateToken(CTokenImpl const & newToken, bool isPreBayfront = false, const bool skipNameValidation = false); + Res UpdateToken(CTokenImpl const & newToken, bool isPreBayfront = false, const bool tokenSplitUpdatea = false); Res BayfrontFlagsCleanup(); Res AddMintedTokens(DCT_ID const & id, CAmount const & amount); diff --git a/src/validation.cpp b/src/validation.cpp index 2de0769a5a0..40aa9a8ab9e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4141,7 +4141,7 @@ void CChainState::ProcessTokenSplits(const CBlock& block, const CBlockIndex* pin token->symbol += newTokenSuffix; token->destructionHeight = pindex->nHeight; token->destructionTx = pindex->GetBlockHash(); - token->flags &= ~static_cast(CToken::TokenFlags::Default); + token->flags &= ~(static_cast(CToken::TokenFlags::Default) | static_cast(CToken::TokenFlags::LoanToken)); token->flags |= static_cast(CToken::TokenFlags::Finalized); res = view.SubMintedTokens(oldTokenId, token->minted); diff --git a/test/functional/feature_token_split.py b/test/functional/feature_token_split.py old mode 100644 new mode 100755 index 4bf5a7e26cd..2e3c1acf58e --- a/test/functional/feature_token_split.py +++ b/test/functional/feature_token_split.py @@ -249,6 +249,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['mintable'], False) assert_equal(result['tradeable'], False) assert_equal(result['finalized'], True) + assert_equal(result['isLoanToken'], False) assert_equal(result['destructionTx'], self.nodes[0].getbestblockhash()) assert_equal(result['destructionHeight'], self.nodes[0].getblockcount()) @@ -287,6 +288,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['mintable'], True) assert_equal(result['tradeable'], True) assert_equal(result['finalized'], False) + assert_equal(result['isLoanToken'], True) assert_equal(result['creationTx'], self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'][1]) assert_equal(result['creationHeight'], self.nodes[0].getblockcount()) assert_equal(result['destructionTx'], '0000000000000000000000000000000000000000000000000000000000000000')