Browse Source

Generate random nonces for test accounts.

These don't have to be valid for unit tests, because they are treated as "cached already valid accounts" in the block validation.
online-accounts-mempow-v2
CalDescent 2 years ago
parent
commit
fe2c63e8e4
  1. 5
      src/main/java/org/qortal/controller/OnlineAccountsManager.java

5
src/main/java/org/qortal/controller/OnlineAccountsManager.java

@ -152,6 +152,7 @@ public class OnlineAccountsManager {
byte[] timestampBytes = Longs.toByteArray(onlineAccountsTimestamp);
final boolean useAggregateCompatibleSignature = onlineAccountsTimestamp >= BlockChain.getInstance().getAggregateSignatureTimestamp();
final boolean mempowActive = onlineAccountsTimestamp >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp();
Set<OnlineAccountData> replacementAccounts = new HashSet<>();
for (PrivateKeyAccount onlineAccount : onlineAccounts) {
@ -162,7 +163,9 @@ public class OnlineAccountsManager {
: onlineAccount.sign(timestampBytes);
byte[] publicKey = onlineAccount.getPublicKey();
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey);
Integer nonce = mempowActive ? new Random().nextInt(500000) : null;
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce);
replacementAccounts.add(ourOnlineAccountData);
}

Loading…
Cancel
Save