DevEnv: Make DEV_PRIVILEGE_PUB_KEY private and add getter

This commit is contained in:
Alva Swanson 2023-12-23 15:19:54 +01:00
parent b255dad5c3
commit c96b7d2ade
No known key found for this signature in database
GPG Key ID: 004760E77F753090
8 changed files with 11 additions and 9 deletions

View File

@ -19,6 +19,7 @@ package bisq.common.app;
import bisq.common.config.Config;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ -29,7 +30,8 @@ public class DevEnv {
// peer (click user icon and alt+r), filter/block offers by various data like offer ID (cmd + f).
// The user can set a program argument to ignore all of those privileged network_messages. They are intended for
// emergency cases only (beside update message and arbitrator registration).
public static final String DEV_PRIVILEGE_PUB_KEY = "027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee";
@Getter
private static final String DEV_PRIVILEGE_PUB_KEY = "027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee";
public static final String DEV_PRIVILEGE_PRIV_KEY = "6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a";
public static void setup(Config config) {

View File

@ -105,7 +105,7 @@ public class AlertManager {
});
}
pubKeyAsHex = useDevPrivilegeKeys ?
DevEnv.DEV_PRIVILEGE_PUB_KEY :
DevEnv.getDEV_PRIVILEGE_PUB_KEY() :
"036d8a1dfcb406886037d2381da006358722823e1940acc2598c844bbc0fd1026f";
}

View File

@ -106,7 +106,7 @@ public class PrivateNotificationManager implements MessageListener {
this.mailboxMessageService.addDecryptedMailboxListener(this::handleMessage);
}
pubKeyAsHex = useDevPrivilegeKeys ?
DevEnv.DEV_PRIVILEGE_PUB_KEY :
DevEnv.getDEV_PRIVILEGE_PUB_KEY() :
"02ba7c5de295adfe57b60029f3637a2c6b1d0e969a8aaefb9e0ddc3a7963f26925";
}

View File

@ -108,7 +108,7 @@ public abstract class AccountingNode implements DaoSetupService, DaoStateListene
}
private static Set<String> getPermittedPubKeys(boolean useDevPrivilegeKeys) {
return useDevPrivilegeKeys ? Set.of(DevEnv.DEV_PRIVILEGE_PUB_KEY) : PERMITTED_PUB_KEYS;
return useDevPrivilegeKeys ? Set.of(DevEnv.getDEV_PRIVILEGE_PUB_KEY()) : PERMITTED_PUB_KEYS;
}

View File

@ -92,7 +92,7 @@ public class AccountingFullNodeNetworkService implements MessageListener, PeerMa
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
if (useDevPrivilegeKeys) {
bmOracleNodePubKey = DevEnv.DEV_PRIVILEGE_PUB_KEY;
bmOracleNodePubKey = DevEnv.getDEV_PRIVILEGE_PUB_KEY();
bmOracleNodePrivKey = DevEnv.DEV_PRIVILEGE_PRIV_KEY;
}
this.bmOracleNodePubKey = bmOracleNodePubKey.isEmpty() ? null : bmOracleNodePubKey;

View File

@ -133,7 +133,7 @@ public class FilterManager {
this.ignoreDevMsg = ignoreDevMsg;
publicKeys = useDevPrivilegeKeys ?
Collections.singletonList(DevEnv.DEV_PRIVILEGE_PUB_KEY) :
Collections.singletonList(DevEnv.getDEV_PRIVILEGE_PUB_KEY()) :
List.of("0358d47858acdc41910325fce266571540681ef83a0d6fedce312bef9810793a27",
"029340c3e7d4bb0f9e651b5f590b434fecb6175aeaa57145c7804ff05d210e534f",
"034dc7530bf66ffd9580aa98031ea9a18ac2d269f7c56c0e71eca06105b9ed69f9");

View File

@ -100,7 +100,7 @@ public abstract class DisputeAgentManager<T extends DisputeAgent> {
this.disputeAgentService = disputeAgentService;
this.user = user;
this.filterManager = filterManager;
publicKeys = useDevPrivilegeKeys ? Collections.singletonList(DevEnv.DEV_PRIVILEGE_PUB_KEY) : getPubKeyList();
publicKeys = useDevPrivilegeKeys ? Collections.singletonList(DevEnv.getDEV_PRIVILEGE_PUB_KEY()) : getPubKeyList();
}
@ -193,7 +193,7 @@ public abstract class DisputeAgentManager<T extends DisputeAgent> {
String pubKeyAsHex = Utils.HEX.encode(e.getRegistrationPubKey());
boolean isInPublicKeyInList = isPublicKeyInList(pubKeyAsHex);
if (!isInPublicKeyInList) {
if (DevEnv.DEV_PRIVILEGE_PUB_KEY.equals(pubKeyAsHex))
if (DevEnv.getDEV_PRIVILEGE_PUB_KEY().equals(pubKeyAsHex))
log.info("We got the DEV_PRIVILEGE_PUB_KEY in our list of publicKeys. RegistrationPubKey={}, nodeAddress={}",
Utilities.bytesAsHexString(e.getRegistrationPubKey()),
e.getNodeAddress().getFullAddress());

View File

@ -63,7 +63,7 @@ public abstract class DisputeAgentService<T extends DisputeAgent> {
ErrorMessageHandler errorMessageHandler) {
log.debug("addDisputeAgent disputeAgent.hashCode() " + disputeAgent.hashCode());
if (!Config.baseCurrencyNetwork().isMainnet() ||
!Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) {
!Utilities.encodeToHex(disputeAgent.getRegistrationPubKey()).equals(DevEnv.getDEV_PRIVILEGE_PUB_KEY())) {
boolean result = p2PService.addProtectedStorageEntry(disputeAgent);
if (result) {
log.trace("Add disputeAgent to network was successful. DisputeAgent.hashCode() = {}", disputeAgent.hashCode());