Limit both divisible & indivisible asset quantites to 1e10 (with 8dp) to fit into 8byte long

This commit is contained in:
catbref 2020-04-27 16:04:19 +01:00
parent ac15dfe789
commit 2602bb01e1
2 changed files with 3 additions and 5 deletions

View File

@ -25,8 +25,7 @@ public class Asset {
public static final int MAX_DESCRIPTION_SIZE = 4000;
public static final int MAX_DATA_SIZE = 400000;
public static final long MAX_DIVISIBLE_QUANTITY = 10_000_000_000L; // but also to 8 decimal places
public static final long MAX_INDIVISIBLE_QUANTITY = 1_000_000_000_000_000_000L;
public static final long MAX_QUANTITY = 10_000_000_000L; // but also to 8 decimal places
// Properties
private Repository repository;

View File

@ -95,9 +95,8 @@ public class IssueAssetTransaction extends Transaction {
if (assetDescriptionlength < 1 || assetDescriptionlength > Asset.MAX_DESCRIPTION_SIZE)
return ValidationResult.INVALID_DESCRIPTION_LENGTH;
// Check quantity - either 10 billion or if that's not enough: a billion billion!
long maxQuantity = issueAssetTransactionData.getIsDivisible() ? Asset.MAX_DIVISIBLE_QUANTITY : Asset.MAX_INDIVISIBLE_QUANTITY;
if (issueAssetTransactionData.getQuantity() < 1 || issueAssetTransactionData.getQuantity() > maxQuantity)
// Check quantity
if (issueAssetTransactionData.getQuantity() < 1 || issueAssetTransactionData.getQuantity() > Asset.MAX_QUANTITY)
return ValidationResult.INVALID_QUANTITY;
// Check fee is positive