forked from Qortal/qortal
Check for null last references at the beginning of the process when creating an arbitrary tx.
This commit is contained in:
parent
59ef66f46d
commit
1d62ef357d
@ -261,10 +261,19 @@ public class ArbitraryResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.NON_PRODUCTION);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.NON_PRODUCTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArbitraryDataFile arbitraryDataFile = null;
|
||||||
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
if (creatorPublicKeyBase58 == null || path == null) {
|
if (creatorPublicKeyBase58 == null || path == null) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
||||||
}
|
}
|
||||||
byte[] creatorPublicKey = Base58.decode(creatorPublicKeyBase58);
|
byte[] creatorPublicKey = Base58.decode(creatorPublicKeyBase58);
|
||||||
|
final String creatorAddress = Crypto.toAddress(creatorPublicKey);
|
||||||
|
final byte[] lastReference = repository.getAccountRepository().getLastReference(creatorAddress);
|
||||||
|
if (lastReference == null) {
|
||||||
|
LOGGER.info(String.format("Qortal account %s has no last reference", creatorAddress));
|
||||||
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
||||||
|
}
|
||||||
|
|
||||||
String name = null;
|
String name = null;
|
||||||
byte[] secret = null;
|
byte[] secret = null;
|
||||||
@ -283,13 +292,11 @@ public class ArbitraryResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArbitraryDataFile arbitraryDataFile = arbitraryDataWriter.getArbitraryDataFile();
|
arbitraryDataFile = arbitraryDataWriter.getArbitraryDataFile();
|
||||||
if (arbitraryDataFile == null) {
|
if (arbitraryDataFile == null) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
||||||
|
|
||||||
ArbitraryDataFile.ValidationResult validationResult = arbitraryDataFile.isValid();
|
ArbitraryDataFile.ValidationResult validationResult = arbitraryDataFile.isValid();
|
||||||
if (validationResult != ArbitraryDataFile.ValidationResult.OK) {
|
if (validationResult != ArbitraryDataFile.ValidationResult.OK) {
|
||||||
LOGGER.error("Invalid file: {}", validationResult);
|
LOGGER.error("Invalid file: {}", validationResult);
|
||||||
@ -310,9 +317,6 @@ public class ArbitraryResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String creatorAddress = Crypto.toAddress(creatorPublicKey);
|
|
||||||
final byte[] lastReference = repository.getAccountRepository().getLastReference(creatorAddress);
|
|
||||||
|
|
||||||
final BaseTransactionData baseTransactionData = new BaseTransactionData(NTP.getTime(), Group.NO_GROUP,
|
final BaseTransactionData baseTransactionData = new BaseTransactionData(NTP.getTime(), Group.NO_GROUP,
|
||||||
lastReference, creatorPublicKey, BlockChain.getInstance().getUnitFee(), null);
|
lastReference, creatorPublicKey, BlockChain.getInstance().getUnitFee(), null);
|
||||||
final int size = (int) arbitraryDataFile.size();
|
final int size = (int) arbitraryDataFile.size();
|
||||||
|
@ -96,13 +96,22 @@ public class WebsiteResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.NON_PRODUCTION);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.NON_PRODUCTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArbitraryDataFile arbitraryDataFile = null;
|
||||||
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
|
||||||
if (creatorPublicKeyBase58 == null || path == null) {
|
if (creatorPublicKeyBase58 == null || path == null) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
||||||
}
|
}
|
||||||
byte[] creatorPublicKey = Base58.decode(creatorPublicKeyBase58);
|
byte[] creatorPublicKey = Base58.decode(creatorPublicKeyBase58);
|
||||||
|
final String creatorAddress = Crypto.toAddress(creatorPublicKey);
|
||||||
|
final byte[] lastReference = repository.getAccountRepository().getLastReference(creatorAddress);
|
||||||
|
if (lastReference == null) {
|
||||||
|
LOGGER.info(String.format("Qortal account %s has no last reference", creatorAddress));
|
||||||
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
||||||
|
}
|
||||||
|
|
||||||
String name = "CalDescentTest1"; // TODO: dynamic
|
String name = "CalDescentTest1"; // TODO: dynamic
|
||||||
ArbitraryTransactionData.Method method = ArbitraryTransactionData.Method.PATCH;
|
ArbitraryTransactionData.Method method = ArbitraryTransactionData.Method.PUT; // TODO: dynamic
|
||||||
ArbitraryTransactionData.Service service = ArbitraryTransactionData.Service.WEBSITE;
|
ArbitraryTransactionData.Service service = ArbitraryTransactionData.Service.WEBSITE;
|
||||||
ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.ZIP;
|
ArbitraryTransactionData.Compression compression = ArbitraryTransactionData.Compression.ZIP;
|
||||||
|
|
||||||
@ -117,7 +126,7 @@ public class WebsiteResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArbitraryDataFile arbitraryDataFile = arbitraryDataWriter.getArbitraryDataFile();
|
arbitraryDataFile = arbitraryDataWriter.getArbitraryDataFile();
|
||||||
if (arbitraryDataFile == null) {
|
if (arbitraryDataFile == null) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
@ -128,11 +137,6 @@ public class WebsiteResource {
|
|||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
||||||
|
|
||||||
final String creatorAddress = Crypto.toAddress(creatorPublicKey);
|
|
||||||
final byte[] lastReference = repository.getAccountRepository().getLastReference(creatorAddress);
|
|
||||||
|
|
||||||
final BaseTransactionData baseTransactionData = new BaseTransactionData(NTP.getTime(), Group.NO_GROUP,
|
final BaseTransactionData baseTransactionData = new BaseTransactionData(NTP.getTime(), Group.NO_GROUP,
|
||||||
lastReference, creatorPublicKey, BlockChain.getInstance().getUnitFee(), null);
|
lastReference, creatorPublicKey, BlockChain.getInstance().getUnitFee(), null);
|
||||||
final int size = (int) arbitraryDataFile.size();
|
final int size = (int) arbitraryDataFile.size();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user