Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 13 additions & 4 deletions src/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ bool IsAssetNameASubQualifier(const std::string& name)

bool IsAssetNameValid(const std::string& name, AssetType& assetType, std::string& error)
{
// Do a max length check first to stop the possibility of a stack exhaustion.
// We check for a value that is larger than the max asset name
if (name.length() > 40)
return false;

assetType = AssetType::INVALID;
if (std::regex_match(name, UNIQUE_INDICATOR))
{
Expand Down Expand Up @@ -900,6 +905,14 @@ bool AssetNullVerifierDataFromScript(const CScript& scriptPubKey, CNullAssetTxVe
//! Call VerifyNewAsset if this function returns true
bool CTransaction::IsNewAsset() const
{
// New Asset transaction will always have at least three outputs.
// 1. Owner Token output
// 2. Issue Asset output
// 3. RVN Burn Fee
if (vout.size() < 3) {
return false;
}

// Check for the assets data CTxOut. This will always be the last output in the transaction
if (!CheckIssueDataTx(vout[vout.size() - 1]))
return false;
Expand Down Expand Up @@ -5292,10 +5305,6 @@ bool CheckNewAsset(const CNewAsset& asset, std::string& strError)
}
}

if (assetType == AssetType::RESTRICTED) {
// TODO add more restricted asset checks
}

if (IsAssetNameAnOwner(std::string(asset.strName))) {
strError = _("Invalid parameters: asset_name can't have a '!' at the end of it. See help for more details.");
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
}

for (auto name: setNullGlobalAssetChanges) {
if (name.size() == 0)
return state.DoS(100, false, REJECT_INVALID,"bad-txns-tx-contains-global-asset-null-tx-with-null-asset-name");

std::string rootName = name.substr(1, name.size()); // $TOKEN into TOKEN
if (!setAssetTransferNames.count(rootName + OWNER_TAG)) {
return state.DoS(100, false, REJECT_INVALID, "bad-txns-tx-contains-global-asset-null-tx-without-asset-transfer");
Expand Down
2 changes: 1 addition & 1 deletion src/script/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ bool CScript::IsAssetScript(int& nType, bool& isOwner) const

bool CScript::IsAssetScript(int& nType, bool& fIsOwner, int& nStartingIndex) const
{
if (this->size() > 30) {
if (this->size() > 31) {
if ((*this)[25] == OP_RVN_ASSET) { // OP_RVN_ASSET is always in the 25 index of the script if it exists
int index = -1;
if ((*this)[27] == RVN_R) { // Check to see if RVN starts at 27 ( this->size() < 105)
Expand Down