diff --git a/src/main/java/org/qortal/block/Block.java b/src/main/java/org/qortal/block/Block.java index 5c482c39..babacb5d 100644 --- a/src/main/java/org/qortal/block/Block.java +++ b/src/main/java/org/qortal/block/Block.java @@ -1079,7 +1079,7 @@ public class Block { // Validate the rest for (OnlineAccountData onlineAccount : onlineAccounts) - if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount)) + if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount, this.blockData.getTimestamp())) return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT; } diff --git a/src/main/java/org/qortal/controller/OnlineAccountsManager.java b/src/main/java/org/qortal/controller/OnlineAccountsManager.java index 871dd3b7..013585ee 100644 --- a/src/main/java/org/qortal/controller/OnlineAccountsManager.java +++ b/src/main/java/org/qortal/controller/OnlineAccountsManager.java @@ -305,8 +305,8 @@ public class OnlineAccountsManager { } // Validate mempow if feature trigger is active - if (onlineAccountTimestamp >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) { - if (!getInstance().verifyMemoryPoW(onlineAccountData)) { + if (now >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) { + if (!getInstance().verifyMemoryPoW(onlineAccountData, now)) { LOGGER.trace(() -> String.format("Rejecting online reward-share for account %s due to invalid PoW nonce", mintingAccount.getAddress())); return false; } @@ -544,7 +544,7 @@ public class OnlineAccountsManager { // Compute nonce Integer nonce; - if (isMemoryPoWActive(onlineAccountsTimestamp)) { + if (isMemoryPoWActive(NTP.getTime())) { try { nonce = this.computeMemoryPoW(mempowBytes, publicKey, onlineAccountsTimestamp); if (nonce == null) { @@ -567,7 +567,7 @@ public class OnlineAccountsManager { OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce); // Make sure to verify before adding - if (verifyMemoryPoW(ourOnlineAccountData)) { + if (verifyMemoryPoW(ourOnlineAccountData, NTP.getTime())) { ourOnlineAccounts.add(ourOnlineAccountData); } } @@ -617,7 +617,7 @@ public class OnlineAccountsManager { } private Integer computeMemoryPoW(byte[] bytes, byte[] publicKey, long onlineAccountsTimestamp) throws TimeoutException { - if (!isMemoryPoWActive(onlineAccountsTimestamp)) { + if (!isMemoryPoWActive(NTP.getTime())) { LOGGER.info("Mempow start timestamp not yet reached, and onlineAccountsMemPoWEnabled not enabled in settings"); return null; } @@ -643,8 +643,8 @@ public class OnlineAccountsManager { return nonce; } - public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData) { - if (!isMemoryPoWActive(onlineAccountData.getTimestamp())) { + public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData, Long timestamp) { + if (!isMemoryPoWActive(timestamp)) { // Not active yet, so treat it as valid return true; }