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
44 changes: 27 additions & 17 deletions src/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,13 +1700,13 @@ bool CheckIssueBurnTx(const CTxOut& txOut, const AssetType& type, const int numb
CAmount burnAmount = 0;
std::string burnAddress = "";

if (type == AssetType::SUB) {
if (type == SUB) {
burnAmount = GetIssueSubAssetBurnAmount();
burnAddress = Params().IssueSubAssetBurnAddress();
} else if (type == AssetType::ROOT) {
} else if (type == ROOT) {
burnAmount = GetIssueAssetBurnAmount();
burnAddress = Params().IssueAssetBurnAddress();
} else if (type == AssetType::UNIQUE) {
} else if (type == UNIQUE) {
burnAmount = GetIssueUniqueAssetBurnAmount();
burnAddress = Params().IssueUniqueAssetBurnAddress();
} else {
Expand Down Expand Up @@ -2173,44 +2173,54 @@ CAmount GetIssueUniqueAssetBurnAmount()
return Params().IssueUniqueAssetBurnAmount();
}

CAmount GetBurnAmount(const int nType)
{
return GetBurnAmount((AssetType(nType)));
}

CAmount GetBurnAmount(const AssetType type)
{
switch (type) {
case AssetType::ROOT:
case ROOT:
return GetIssueAssetBurnAmount();
case AssetType::SUB:
case SUB:
return GetIssueSubAssetBurnAmount();
case AssetType::MSGCHANNEL:
case MSGCHANNEL:
return 0;
case AssetType::OWNER:
case OWNER:
return 0;
case AssetType::UNIQUE:
case UNIQUE:
return GetIssueUniqueAssetBurnAmount();
case AssetType::VOTE:
case VOTE:
return 0;
case AssetType::REISSUE:
case REISSUE:
return GetReissueAssetBurnAmount();
default:
return 0;
}
}

std::string GetBurnAddress(const int nType)
{
return GetBurnAddress((AssetType(nType)));
}

std::string GetBurnAddress(const AssetType type)
{
switch (type) {
case AssetType::ROOT:
case ROOT:
return Params().IssueAssetBurnAddress();
case AssetType::SUB:
case SUB:
return Params().IssueSubAssetBurnAddress();
case AssetType::MSGCHANNEL:
case MSGCHANNEL:
return "";
case AssetType::OWNER:
case OWNER:
return "";
case AssetType::UNIQUE:
case UNIQUE:
return Params().IssueUniqueAssetBurnAddress();
case AssetType::VOTE:
case VOTE:
return "";
case AssetType::REISSUE:
case REISSUE:
return Params().ReissueAssetBurnAddress();
default:
return "";
Expand Down
2 changes: 2 additions & 0 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ CAmount GetReissueAssetBurnAmount();
CAmount GetIssueSubAssetBurnAmount();
CAmount GetIssueUniqueAssetBurnAmount();
CAmount GetBurnAmount(const AssetType type);
CAmount GetBurnAmount(const int nType);
std::string GetBurnAddress(const AssetType type);
std::string GetBurnAddress(const int nType);

bool IsAssetNameValid(const std::string& name);
bool IsAssetNameValid(const std::string& name, AssetType& assetType);
Expand Down
27 changes: 10 additions & 17 deletions src/assets/assettypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,30 @@ class CAssetsCache;

enum AssetType
{
ROOT,
OWNER,
SUB,
UNIQUE,
MSGCHANNEL,
VOTE,
INVALID,
REISSUE
ROOT = 0,
SUB = 1,
UNIQUE = 2,
OWNER = 3,
MSGCHANNEL = 4,
VOTE = 5,
REISSUE = 6,
INVALID = 7
};

std::string PrintAssetType(AssetType& assetType) {
switch (assetType) {
case ROOT: return "ROOT";
case OWNER: return "OWNER";
case SUB: return "SUB";
case UNIQUE: return "UNIQUE";
case OWNER: return "OWNER";
case MSGCHANNEL: return "MSGCHANNEL";
case VOTE: return "VOTE";
case INVALID: return "INVALID";
case REISSUE: return "REISSUE";
case INVALID: return "INVALID";
default: return "UNKNOWN";
}
}

enum IssueAssetType
{
ISSUE_ROOT = 0,
ISSUE_SUB = 1,
ISSUE_UNIQUE = 2
};

class CNewAsset {
public:
std::string strName; // MAX 31 Bytes
Expand Down
49 changes: 27 additions & 22 deletions src/qt/createassetdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ void CreateAssetDialog::setUpValues()
QStringList list;
list.append(tr("Main Asset"));
list.append(tr("Sub Asset"));
// list.append(tr("Unique Asset"));
list.append(tr("Unique Asset"));
ui->assetType->addItems(list);
type = ISSUE_ROOT;
type = ROOT;
ui->assetTypeLabel->setText(tr("Asset Type") + ":");

// Setup the asset list
Expand Down Expand Up @@ -161,13 +161,13 @@ void CreateAssetDialog::CheckFormState()

AssetType assetType;
bool assetNameValid = IsAssetNameValid(name.toStdString(), assetType);
if (assetNameValid && assetType == ROOT && type != ISSUE_ROOT)
if (assetNameValid && assetType == ROOT && type != ROOT)
return;

if (assetNameValid && assetType == SUB && type != ISSUE_SUB)
if (assetNameValid && assetType == SUB && type != SUB)
return;

if (assetNameValid && assetType == UNIQUE && type != ISSUE_UNIQUE)
if (assetNameValid && assetType == UNIQUE && type != UNIQUE)
return;

if (!(IsValidDestination(dest) || ui->addressText->text().isEmpty()) && assetNameValid) {
Expand Down Expand Up @@ -237,7 +237,7 @@ void CreateAssetDialog::checkAvailabilityClicked()
void CreateAssetDialog::onNameChanged(QString name)
{
// Update the displayed name to uppercase if the type only accepts uppercase
name = name.toUpper();
name = type == UNIQUE ? name : name.toUpper();
UpdateAssetNameToUpper();

QString assetName = name;
Expand All @@ -252,7 +252,7 @@ void CreateAssetDialog::onNameChanged(QString name)
return;
}

if (type == ISSUE_ROOT) {
if (type == ROOT) {
if (name.size() < 3) {
ui->nameText->setStyleSheet("border: 1px solid red");
showMessage("Invalid: Minimum of 3 character in length");
Expand All @@ -269,7 +269,7 @@ void CreateAssetDialog::onNameChanged(QString name)
ui->nameText->setStyleSheet("border: 1px solid red");
showMessage("Invalid: Max Size 30 Characters. Allowed characters include: A-Z 0-9 . _");
}
} else if (type == ISSUE_SUB || type == ISSUE_UNIQUE) {
} else if (type == SUB || type == UNIQUE) {
if (name.size() == 0) {
hideMessage();
ui->availabilityButton->setDisabled(true);
Expand All @@ -288,7 +288,7 @@ void CreateAssetDialog::onNameChanged(QString name)
}

// Set the assetName
updatePresentedAssetName(format.arg(type == ISSUE_ROOT ? "" : ui->assetList->currentText(), identifier, name));
updatePresentedAssetName(format.arg(type == ROOT ? "" : ui->assetList->currentText(), identifier, name));

checkedAvailablity = false;
disableCreateButton();
Expand Down Expand Up @@ -346,10 +346,10 @@ void CreateAssetDialog::onCreateAssetClicked()
QStringList formatted;

// generate bold amount string
QString amount = "<b>" + QString::fromStdString(ValueFromAmountString(GetIssueAssetBurnAmount(), 8)) + " RVN";
QString amount = "<b>" + QString::fromStdString(ValueFromAmountString(GetBurnAmount(type), 8)) + " RVN";
amount.append("</b>");
// generate monospace address string
QString addressburn = "<span style='font-family: monospace;'>" + QString::fromStdString(Params().IssueAssetBurnAddress());
QString addressburn = "<span style='font-family: monospace;'>" + QString::fromStdString(GetBurnAddress(type));
addressburn.append("</span>");

QString recipientElement1;
Expand Down Expand Up @@ -410,7 +410,7 @@ void CreateAssetDialog::onCreateAssetClicked()
// Create the transaction and broadcast it
std::string txid;
if (!SendAssetTransaction(model->getWallet(), tx, reservekey, error, txid)) {
showMessage("Invalid: " + QString::fromStdString(error.second));
showMessage(tr("Invalid: ") + QString::fromStdString(error.second));
} else {
QMessageBox msgBox;
QPushButton *copyButton = msgBox.addButton(tr("Copy"), QMessageBox::ActionRole);
Expand Down Expand Up @@ -478,6 +478,11 @@ void CreateAssetDialog::onAssetTypeActivated(int index)
// Update the selected type
type = index;

// Make sure the type is only the the supported issue types
if(!(type == ROOT || type == SUB || type == UNIQUE))
type = ROOT;


// Get the identifier for the asset type
QString identifier = GetSpecialCharacter();

Expand All @@ -490,7 +495,7 @@ void CreateAssetDialog::onAssetTypeActivated(int index)
UpdateAssetNameMaxSize();

// Set assetName
updatePresentedAssetName(format.arg(type == ISSUE_ROOT ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));
updatePresentedAssetName(format.arg(type == ROOT ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));

if (ui->nameText->text().size())
ui->availabilityButton->setDisabled(false);
Expand All @@ -507,7 +512,7 @@ void CreateAssetDialog::onAssetListActivated(int index)
UpdateAssetNameMaxSize();

// Set assetName
updatePresentedAssetName(format.arg(type == ISSUE_ROOT ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));
updatePresentedAssetName(format.arg(type == ROOT ? "" : ui->assetList->currentText(), identifier, ui->nameText->text()));

if (ui->nameText->text().size())
ui->availabilityButton->setDisabled(false);
Expand All @@ -523,37 +528,37 @@ void CreateAssetDialog::updatePresentedAssetName(QString name)

QString CreateAssetDialog::GetSpecialCharacter()
{
if (type == ISSUE_SUB)
if (type == SUB)
return "/";
else if (type == ISSUE_UNIQUE)
else if (type == UNIQUE)
return "#";

return "";
}

QString CreateAssetDialog::GetAssetName()
{
if (type == ISSUE_ROOT)
if (type == ROOT)
return ui->nameText->text();
else if (type == ISSUE_SUB)
else if (type == SUB)
return ui->assetList->currentText() + "/" + ui->nameText->text();
else if (type == ISSUE_UNIQUE)
else if (type == UNIQUE)
return ui->assetList->currentText() + "#" + ui->nameText->text();
return "";
}

void CreateAssetDialog::UpdateAssetNameMaxSize()
{
if (type == ISSUE_ROOT) {
if (type == ROOT) {
ui->nameText->setMaxLength(30);
} else if (type == ISSUE_SUB || type == ISSUE_UNIQUE) {
} else if (type == SUB || type == UNIQUE) {
ui->nameText->setMaxLength(30 - (ui->assetList->currentText().size() + 1));
}
}

void CreateAssetDialog::UpdateAssetNameToUpper()
{
if (type == ISSUE_ROOT || type == ISSUE_SUB) {
if (type == ROOT || type == SUB) {
ui->nameText->setText(ui->nameText->text().toUpper());
}
}
24 changes: 12 additions & 12 deletions src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;

enum txnouttype
{
TX_NONSTANDARD,
TX_NONSTANDARD = 0,
// 'standard' transaction types:
TX_PUBKEY,
TX_PUBKEYHASH,
TX_SCRIPTHASH,
TX_MULTISIG,
TX_NULL_DATA, //!< unspendable OP_RETURN script that carries data
TX_WITNESS_V0_SCRIPTHASH,
TX_WITNESS_V0_KEYHASH,
TX_PUBKEY = 1,
TX_PUBKEYHASH = 2,
TX_SCRIPTHASH = 3,
TX_MULTISIG = 4,
TX_NULL_DATA = 5, //!< unspendable OP_RETURN script that carries data
TX_WITNESS_V0_SCRIPTHASH = 6,
TX_WITNESS_V0_KEYHASH = 7,
/** RVN START */
TX_NEW_ASSET,
TX_REISSUE_ASSET,
TX_TRANSFER_ASSET,
TX_RESERVED_ASSET
TX_NEW_ASSET = 8,
TX_REISSUE_ASSET = 9,
TX_TRANSFER_ASSET = 10,
TX_RESERVED_ASSET = 11
/** RVN END */
};

Expand Down