forked from Qortal/qortal
Enforce version 2+ for DEPLOY_AT
This commit is contained in:
parent
b4284515e7
commit
74f89af841
@ -137,31 +137,30 @@ public class DeployAtTransaction extends Transaction {
|
|||||||
return ValidationResult.NO_BALANCE;
|
return ValidationResult.NO_BALANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check version from creation bytes
|
||||||
|
if (this.getVersion() < 2)
|
||||||
|
return ValidationResult.INVALID_CREATION_BYTES;
|
||||||
|
|
||||||
// Check creation bytes are valid (for v2+)
|
// Check creation bytes are valid (for v2+)
|
||||||
if (this.getVersion() >= 2) {
|
this.ensureATAddress();
|
||||||
// Do actual validation
|
|
||||||
ensureATAddress();
|
|
||||||
|
|
||||||
// Just enough AT data to allow API to query initial balances, etc.
|
// Just enough AT data to allow API to query initial balances, etc.
|
||||||
String atAddress = this.deployATTransactionData.getAtAddress();
|
String atAddress = this.deployATTransactionData.getAtAddress();
|
||||||
byte[] creatorPublicKey = this.deployATTransactionData.getCreatorPublicKey();
|
byte[] creatorPublicKey = this.deployATTransactionData.getCreatorPublicKey();
|
||||||
long creation = this.deployATTransactionData.getTimestamp();
|
long creation = this.deployATTransactionData.getTimestamp();
|
||||||
ATData skeletonAtData = new ATData(atAddress, creatorPublicKey, creation, assetId);
|
ATData skeletonAtData = new ATData(atAddress, creatorPublicKey, creation, assetId);
|
||||||
|
|
||||||
int height = this.repository.getBlockRepository().getBlockchainHeight() + 1;
|
int height = this.repository.getBlockRepository().getBlockchainHeight() + 1;
|
||||||
long blockTimestamp = Timestamp.toLong(height, 0);
|
long blockTimestamp = Timestamp.toLong(height, 0);
|
||||||
|
|
||||||
QortalATAPI api = new QortalATAPI(repository, skeletonAtData, blockTimestamp);
|
QortalATAPI api = new QortalATAPI(repository, skeletonAtData, blockTimestamp);
|
||||||
QortalAtLoggerFactory loggerFactory = QortalAtLoggerFactory.getInstance();
|
QortalAtLoggerFactory loggerFactory = QortalAtLoggerFactory.getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new MachineState(api, loggerFactory, this.deployATTransactionData.getCreationBytes());
|
new MachineState(api, loggerFactory, this.deployATTransactionData.getCreationBytes());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
// Not valid
|
// Not valid
|
||||||
return ValidationResult.INVALID_CREATION_BYTES;
|
return ValidationResult.INVALID_CREATION_BYTES;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Skip validation for old, dead ATs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ValidationResult.OK;
|
return ValidationResult.OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user