mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-22 20:26:50 +00:00
Restrict TRANSFER_PRIVS recipients to new (non-existent) accounts.
This commit is contained in:
@@ -241,6 +241,7 @@ public abstract class Transaction {
|
||||
ASSET_NOT_SPENDABLE(89),
|
||||
ACCOUNT_CANNOT_REWARD_SHARE(90),
|
||||
SELF_SHARE_EXISTS(91),
|
||||
ACCOUNT_ALREADY_EXISTS(92),
|
||||
NOT_YET_RELEASED(1000);
|
||||
|
||||
public final int value;
|
||||
|
@@ -83,6 +83,10 @@ public class TransferPrivsTransaction extends Transaction {
|
||||
if (!Crypto.isValidAddress(this.transferPrivsTransactionData.getRecipient()))
|
||||
return ValidationResult.INVALID_ADDRESS;
|
||||
|
||||
// Check recipient is new account
|
||||
if (this.repository.getAccountRepository().accountExists(this.transferPrivsTransactionData.getRecipient()))
|
||||
return ValidationResult.ACCOUNT_ALREADY_EXISTS;
|
||||
|
||||
return ValidationResult.OK;
|
||||
}
|
||||
|
||||
@@ -183,8 +187,11 @@ public class TransferPrivsTransaction extends Transaction {
|
||||
accountRepository.setFlags(senderData);
|
||||
|
||||
// Restore recipient's flags
|
||||
recipientData.setFlags(this.transferPrivsTransactionData.getPreviousRecipientFlags());
|
||||
accountRepository.setFlags(recipientData);
|
||||
Integer previousRecipientFlags = this.transferPrivsTransactionData.getPreviousRecipientFlags();
|
||||
if (previousRecipientFlags != null) {
|
||||
recipientData.setFlags(previousRecipientFlags);
|
||||
accountRepository.setFlags(recipientData);
|
||||
}
|
||||
|
||||
// Clean values in transaction data
|
||||
this.transferPrivsTransactionData.setPreviousSenderFlags(null);
|
||||
|
Reference in New Issue
Block a user