mirror of
https://github.com/Qortal/qortal.git
synced 2025-04-01 17:55:54 +00:00
Merge 4766dae062e600b8eb97f25124de41eeb5646ecb into faee7c8f6a9fe85dcc4fb3c5ffacdde72668137f
This commit is contained in:
commit
8a6d102a89
@ -22,14 +22,10 @@ public class Payment {
|
||||
private Repository repository;
|
||||
|
||||
// Constructors
|
||||
|
||||
public Payment(Repository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
// Processing
|
||||
|
||||
|
||||
// isValid
|
||||
|
||||
/** Are payments valid? */
|
||||
@ -37,14 +33,12 @@ public class Payment {
|
||||
AssetRepository assetRepository = this.repository.getAssetRepository();
|
||||
|
||||
// Check fee is positive or zero
|
||||
// We have already checked that the fee is correct in the Transaction superclass
|
||||
if (fee < 0)
|
||||
return ValidationResult.NEGATIVE_FEE;
|
||||
|
||||
// Total up payment amounts by assetId
|
||||
Map<Long, Long> amountsByAssetId = new HashMap<>();
|
||||
// Add transaction fee to start with
|
||||
amountsByAssetId.put(Asset.QORT, fee);
|
||||
amountsByAssetId.put(Asset.QORT, fee); // Add transaction fee to the map
|
||||
|
||||
// Grab sender info
|
||||
Account sender = new PublicKeyAccount(this.repository, senderPublicKey);
|
||||
@ -73,7 +67,7 @@ public class Payment {
|
||||
if (atData == null)
|
||||
return ValidationResult.AT_UNKNOWN;
|
||||
|
||||
if (atData != null && atData.getIsFinished())
|
||||
if (atData.getIsFinished())
|
||||
return ValidationResult.AT_IS_FINISHED;
|
||||
}
|
||||
|
||||
@ -121,29 +115,6 @@ public class Payment {
|
||||
return isValid(senderPublicKey, paymentData, fee, false);
|
||||
}
|
||||
|
||||
// isProcessable
|
||||
|
||||
/** Are multiple payments processable? */
|
||||
public ValidationResult isProcessable(byte[] senderPublicKey, List<PaymentData> payments, long fee, boolean isZeroAmountValid) throws DataException {
|
||||
// Essentially the same as isValid...
|
||||
return isValid(senderPublicKey, payments, fee, isZeroAmountValid);
|
||||
}
|
||||
|
||||
/** Are multiple payments processable? */
|
||||
public ValidationResult isProcessable(byte[] senderPublicKey, List<PaymentData> payments, long fee) throws DataException {
|
||||
return isProcessable(senderPublicKey, payments, fee, false);
|
||||
}
|
||||
|
||||
/** Is single payment processable? */
|
||||
public ValidationResult isProcessable(byte[] senderPublicKey, PaymentData paymentData, long fee, boolean isZeroAmountValid) throws DataException {
|
||||
return isProcessable(senderPublicKey, Collections.singletonList(paymentData), fee, isZeroAmountValid);
|
||||
}
|
||||
|
||||
/** Is single payment processable? */
|
||||
public ValidationResult isProcessable(byte[] senderPublicKey, PaymentData paymentData, long fee) throws DataException {
|
||||
return isProcessable(senderPublicKey, paymentData, fee, false);
|
||||
}
|
||||
|
||||
// process
|
||||
|
||||
/** Multiple payment processing */
|
||||
@ -241,10 +212,8 @@ public class Payment {
|
||||
Account recipient = new Account(this.repository, paymentData.getRecipient());
|
||||
long assetId = paymentData.getAssetId();
|
||||
|
||||
/*
|
||||
* For QORT amounts only: If recipient's last reference is this transaction's signature, then they can't have made any transactions of their own
|
||||
* (which would have changed their last reference) thus this is their first reference so remove it.
|
||||
*/
|
||||
// For QORT amounts only: If recipient's last reference is this transaction's signature, then they can't have made any transactions of their own
|
||||
// (which would have changed their last reference) thus this is their first reference so remove it.
|
||||
if ((alwaysUninitializeRecipientReference || assetId == Asset.QORT) && Arrays.equals(recipient.getLastReference(), signature))
|
||||
recipient.setLastReference(null);
|
||||
}
|
||||
@ -254,5 +223,4 @@ public class Payment {
|
||||
boolean alwaysUninitializeRecipientReference) throws DataException {
|
||||
orphanReferencesAndFees(senderPublicKey, Collections.singletonList(paymentData), fee, signature, reference, alwaysUninitializeRecipientReference);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user