mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Move 'rpcUser' option handling to Config
This commit is contained in:
parent
919c58eefe
commit
80754ed3d5
@ -64,6 +64,7 @@ public class Config {
|
||||
public static final String USE_ALL_PROVIDED_NODES = "useAllProvidedNodes";
|
||||
public static final String USER_AGENT = "userAgent";
|
||||
public static final String NUM_CONNECTIONS_FOR_BTC = "numConnectionsForBtc";
|
||||
public static final String RPC_USER = "rpcUser";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Config.class);
|
||||
|
||||
@ -125,6 +126,7 @@ public class Config {
|
||||
private final boolean useAllProvidedNodes;
|
||||
private final String userAgent;
|
||||
private final int numConnectionsForBtc;
|
||||
private final String rpcUser;
|
||||
|
||||
// properties derived from cli options, but not exposed as cli options themselves
|
||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||
@ -439,6 +441,11 @@ public class Config {
|
||||
.ofType(int.class)
|
||||
.defaultsTo(DEFAULT_NUM_CONNECTIONS_FOR_BTC);
|
||||
|
||||
ArgumentAcceptingOptionSpec<String> rpcUserOpt =
|
||||
parser.accepts(RPC_USER, "Bitcoind rpc username")
|
||||
.withRequiredArg()
|
||||
.defaultsTo("");
|
||||
|
||||
try {
|
||||
OptionSet cliOpts = parser.parse(args);
|
||||
|
||||
@ -526,6 +533,7 @@ public class Config {
|
||||
this.useAllProvidedNodes = options.valueOf(useAllProvidedNodesOpt);
|
||||
this.userAgent = options.valueOf(userAgentOpt);
|
||||
this.numConnectionsForBtc = options.valueOf(numConnectionsForBtcOpt);
|
||||
this.rpcUser = options.valueOf(rpcUserOpt);
|
||||
} catch (OptionException ex) {
|
||||
throw new ConfigException(format("problem parsing option '%s': %s",
|
||||
ex.options().get(0),
|
||||
@ -789,4 +797,8 @@ public class Config {
|
||||
public int getNumConnectionsForBtc() {
|
||||
return numConnectionsForBtc;
|
||||
}
|
||||
|
||||
public String getRpcUser() {
|
||||
return rpcUser;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
@Setter
|
||||
protected boolean isBitcoinLocalhostNodeRunning;
|
||||
|
||||
protected final String rpcUser, rpcPassword,
|
||||
protected final String rpcPassword,
|
||||
rpcHost, rpcPort, rpcBlockNotificationPort, rpcBlockNotificationHost, dumpBlockchainData, fullDaoNode,
|
||||
genesisTxId, genesisBlockHeight, genesisTotalSupply,
|
||||
daoActivated;
|
||||
@ -69,7 +69,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public BisqEnvironment(PropertySource commandLineProperties) {
|
||||
//DaoOptionKeys
|
||||
rpcUser = getProperty(commandLineProperties, DaoOptionKeys.RPC_USER, "");
|
||||
rpcPassword = getProperty(commandLineProperties, DaoOptionKeys.RPC_PASSWORD, "");
|
||||
rpcHost = getProperty(commandLineProperties, DaoOptionKeys.RPC_HOST, "");
|
||||
rpcPort = getProperty(commandLineProperties, DaoOptionKeys.RPC_PORT, "");
|
||||
@ -98,7 +97,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||
private PropertySource<?> defaultProperties() {
|
||||
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
|
||||
{
|
||||
setProperty(DaoOptionKeys.RPC_USER, rpcUser);
|
||||
setProperty(DaoOptionKeys.RPC_PASSWORD, rpcPassword);
|
||||
setProperty(DaoOptionKeys.RPC_HOST, rpcHost);
|
||||
setProperty(DaoOptionKeys.RPC_PORT, rpcPort);
|
||||
|
@ -285,10 +285,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||
.ofType(boolean.class);
|
||||
|
||||
//RpcOptionKeys
|
||||
parser.accepts(DaoOptionKeys.RPC_USER,
|
||||
"Bitcoind rpc username")
|
||||
.withRequiredArg();
|
||||
|
||||
parser.accepts(DaoOptionKeys.RPC_PASSWORD,
|
||||
"Bitcoind rpc password")
|
||||
.withRequiredArg();
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package bisq.core.dao;
|
||||
|
||||
import bisq.core.app.BisqEnvironment;
|
||||
import bisq.core.dao.governance.asset.AssetService;
|
||||
import bisq.core.dao.governance.ballot.BallotListPresentation;
|
||||
import bisq.core.dao.governance.ballot.BallotListService;
|
||||
@ -224,7 +223,7 @@ public class DaoModule extends AppModule {
|
||||
bind(MyProofOfBurnListService.class).in(Singleton.class);
|
||||
|
||||
// Options
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.RPC_USER)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_USER));
|
||||
bindConstant().annotatedWith(named(Config.RPC_USER)).to(config.getRpcUser());
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.RPC_PASSWORD)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_PASSWORD));
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.RPC_HOST)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_HOST));
|
||||
bindConstant().annotatedWith(named(DaoOptionKeys.RPC_PORT)).to(environment.getRequiredProperty(DaoOptionKeys.RPC_PORT));
|
||||
|
@ -21,7 +21,6 @@ package bisq.core.dao;
|
||||
* Provides program argument options used in the DAO domain.
|
||||
*/
|
||||
public class DaoOptionKeys {
|
||||
public static final String RPC_USER = "rpcUser";
|
||||
public static final String RPC_PASSWORD = "rpcPassword";
|
||||
public static final String RPC_PORT = "rpcPort";
|
||||
public static final String RPC_BLOCK_NOTIFICATION_PORT = "rpcBlockNotificationPort";
|
||||
|
@ -152,7 +152,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
@Named(Config.BTC_NODES) String btcNodesFromOptions,
|
||||
@Named(Config.REFERRAL_ID) String referralId,
|
||||
@Named(DaoOptionKeys.FULL_DAO_NODE) String fullDaoNode,
|
||||
@Named(DaoOptionKeys.RPC_USER) String rpcUser,
|
||||
@Named(Config.RPC_USER) String rpcUser,
|
||||
@Named(DaoOptionKeys.RPC_PASSWORD) String rpcPassword,
|
||||
@Named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT) String rpcBlockNotificationPort) {
|
||||
|
||||
@ -633,7 +633,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
|
||||
public void setRpcUser(String value) {
|
||||
// We only persist if we have not set the program argument
|
||||
if (rpcUserFromOptions == null || rpcUserFromOptions.isEmpty()) {
|
||||
if (!rpcUserFromOptions.isEmpty()) {
|
||||
prefPayload.setRpcUser(value);
|
||||
persist();
|
||||
}
|
||||
@ -779,7 +779,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
||||
}
|
||||
|
||||
public String getRpcUser() {
|
||||
if (rpcUserFromOptions != null && !rpcUserFromOptions.isEmpty()) {
|
||||
if (!rpcUserFromOptions.isEmpty()) {
|
||||
return rpcUserFromOptions;
|
||||
} else {
|
||||
return prefPayload.getRpcUser();
|
||||
|
@ -53,6 +53,7 @@ import bisq.core.util.validation.IntegerValidator;
|
||||
import bisq.common.UserThread;
|
||||
import bisq.common.app.DevEnv;
|
||||
import bisq.common.config.BaseCurrencyNetwork;
|
||||
import bisq.common.config.Config;
|
||||
import bisq.common.util.Tuple3;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
@ -161,7 +162,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
||||
FilterManager filterManager,
|
||||
DaoFacade daoFacade,
|
||||
@Named(DaoOptionKeys.FULL_DAO_NODE) String fullDaoNode,
|
||||
@Named(DaoOptionKeys.RPC_USER) String rpcUser,
|
||||
@Named(Config.RPC_USER) String rpcUser,
|
||||
@Named(DaoOptionKeys.RPC_PASSWORD) String rpcPassword,
|
||||
@Named(DaoOptionKeys.RPC_BLOCK_NOTIFICATION_PORT) String rpcBlockNotificationPort) {
|
||||
super(model);
|
||||
|
Loading…
Reference in New Issue
Block a user