forked from Qortal/qortal
Modified post-trigger last reference checking, to now require a non-null value
This allows for compatibility with TRANSFER_PRIVS validation in commit 8950bb7, which treats any account with a non-null reference as "existing". It also avoids possible unknown side effects from trying to process and store transactions with a null reference - something that wouldn't have been possible until the validation was removed.
This commit is contained in:
parent
f887fcafe3
commit
922ffcc0be
@ -90,7 +90,8 @@ public class ArbitraryTransaction extends Transaction {
|
||||
|
||||
// Disable reference checking after feature trigger timestamp
|
||||
if (this.arbitraryTransactionData.getTimestamp() >= BlockChain.getInstance().getDisableReferenceTimestamp()) {
|
||||
return true;
|
||||
// Allow any non-null value
|
||||
return this.arbitraryTransactionData.getReference() != null;
|
||||
}
|
||||
|
||||
if (this.arbitraryTransactionData.getReference() == null) {
|
||||
|
@ -78,7 +78,8 @@ public class AtTransaction extends Transaction {
|
||||
public boolean hasValidReference() throws DataException {
|
||||
// Disable reference checking after feature trigger timestamp
|
||||
if (this.atTransactionData.getTimestamp() >= BlockChain.getInstance().getDisableReferenceTimestamp()) {
|
||||
return true;
|
||||
// Allow any non-null value
|
||||
return this.atTransactionData.getReference() != null;
|
||||
}
|
||||
|
||||
// Check reference is correct, using AT account, not transaction creator which is null account
|
||||
|
@ -167,7 +167,8 @@ public class MessageTransaction extends Transaction {
|
||||
|
||||
// Disable reference checking after feature trigger timestamp
|
||||
if (this.messageTransactionData.getTimestamp() >= BlockChain.getInstance().getDisableReferenceTimestamp()) {
|
||||
return true;
|
||||
// Allow any non-null value
|
||||
return this.messageTransactionData.getReference() != null;
|
||||
}
|
||||
|
||||
if (this.messageTransactionData.getReference() == null)
|
||||
|
@ -907,7 +907,8 @@ public abstract class Transaction {
|
||||
public boolean hasValidReference() throws DataException {
|
||||
// Disable reference checking after feature trigger timestamp
|
||||
if (this.transactionData.getTimestamp() >= BlockChain.getInstance().getDisableReferenceTimestamp()) {
|
||||
return true;
|
||||
// Allow any non-null value
|
||||
return this.transactionData.getReference() != null;
|
||||
}
|
||||
|
||||
Account creator = getCreator();
|
||||
|
@ -80,4 +80,30 @@ public class TransactionReferenceTests extends Common {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullReferenceAfterFeatureTrigger() throws DataException {
|
||||
Common.useSettings("test-settings-v2-disable-reference.json");
|
||||
Random random = new Random();
|
||||
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
PrivateKeyAccount alice = Common.getTestAccount(repository, "alice");
|
||||
|
||||
byte[] randomPrivateKey = new byte[32];
|
||||
random.nextBytes(randomPrivateKey);
|
||||
PrivateKeyAccount recipient = new PrivateKeyAccount(repository, randomPrivateKey);
|
||||
|
||||
// Create payment transaction data
|
||||
TransactionData paymentTransactionData = new PaymentTransactionData(TestTransaction.generateBase(alice), recipient.getAddress(), 100000L);
|
||||
|
||||
// Set null reference
|
||||
paymentTransactionData.setReference(null);
|
||||
|
||||
Transaction paymentTransaction = Transaction.fromData(repository, paymentTransactionData);
|
||||
|
||||
// Transaction should be invalid, as we require a non-null reference
|
||||
Transaction.ValidationResult validationResult = paymentTransaction.isValidUnconfirmed();
|
||||
assertEquals(Transaction.ValidationResult.INVALID_REFERENCE, validationResult);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user