Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fulfilling Proposal #110 #3275

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da3b693
This is to initiate the update necessary for the fulfillment of proposal
niyid Sep 16, 2019
c879121
Merging messages from proposal #110 messages with HEAD.
niyid Sep 16, 2019
3383f71
Cleaning up.
niyid Sep 16, 2019
39f89b5
Cleaning up.
niyid Sep 16, 2019
7a2e54f
Cleaning up formatting.
niyid Sep 16, 2019
1ac19a2
Cleaning up formatting.
niyid Sep 16, 2019
4100fe4
Quick fix; misplaced bracket.
niyid Sep 16, 2019
f06f171
Switching mode to debug from info.
niyid Sep 16, 2019
35643bc
Keeping abreast of new changes.
niyid Sep 17, 2019
6bd447f
Merge branch 'master' of https://github.com/bisq-network/bisq
niyid Sep 17, 2019
471960c
Refixing merged items.
niyid Sep 17, 2019
2825e23
Upgraded to monero-wallet-java v0.1.1
niyid Sep 17, 2019
3c7f1d2
Maven plugin resolved the problem with monero-wallet-rpc.
niyid Sep 17, 2019
4545b01
Temporary fix; adding monero-wallet-rpc library source as part of core.
niyid Sep 17, 2019
ce2e327
Removed references to view component in core component.
niyid Sep 17, 2019
66dfb26
RPC digest authentication fixed.
niyid Sep 18, 2019
fa393a7
Digest not needed.
niyid Sep 18, 2019
c117b3f
Replacing monero-java with a stripped down version of less than 10
niyid Sep 20, 2019
3f50cce
Replacing monero-java references in the view.
niyid Sep 20, 2019
1235780
Replacement of monero-java with compact version complete.
niyid Sep 20, 2019
63cff66
Test ignore for now.
niyid Sep 20, 2019
4596d29
Display destination address; filter out transactions older than 90 days.
niyid Sep 20, 2019
b8e84ae
References to Log4J and JUnit in non test-case classes removed.
niyid Sep 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,13 @@ message PreferencesPayload {
double buyer_security_deposit_as_percent_for_crypto = 52;
int32 block_notify_port = 53;
int32 css_theme = 54;
bool use_bisq_xmr_wallet = 55;
string xmr_user_host = 56;
string xmr_host_port = 57;
string xmr_rpc_user = 58;
string xmr_rpc_pwd = 59;
repeated string xmr_hosts = 60;
int32 xmr_host_option_ordinal = 61;
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/bisq/core/payment/PaymentAccountFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package bisq.core.payment;

import bisq.core.locale.TradeCurrency;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.xmr.wallet.XmrWalletRpcWrapper;


public class PaymentAccountFactory {
public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
Expand Down Expand Up @@ -91,4 +94,16 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
throw new RuntimeException("Not supported PaymentMethod: " + paymentMethod);
}
}

public static InstantCryptoCurrencyAccount producePrimaryWalletAccount(XmrWalletRpcWrapper xmrWalletRpcWrapper, TradeCurrency xmrTradeCurrency) {
InstantCryptoCurrencyAccount account = new InstantCryptoCurrencyAccount();
account.init();

account.setAddress(xmrWalletRpcWrapper.getPrimaryAddress());
account.setSingleTradeCurrency(xmrTradeCurrency);
account.setAccountName("XMR Wallet: " + account.getAddress().substring(0, 6) + "...");

return account;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import bisq.common.app.AppModule;

import bisq.core.xmr.wallet.XmrWalletRpcWrapper;

import org.springframework.core.env.Environment;

import com.google.inject.Singleton;
Expand Down
110 changes: 110 additions & 0 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
@Slf4j
@Singleton
public final class Preferences implements PersistedDataHost, BridgeAddressProvider {
//TODO(niyid) Monero Wallet params: XMR_MAIN_NET_EXPLORERS, XMR_TEST_NET_EXPLORERS
//TODO(niyid) Monero Wallet params: Local Host(127.0.0.1)/Remote Host node, Port
//TODO(niyid) Monero Wallet params: List of available remote nodes
//TODO(niyid) Monero Wallet params equivalents of: btcNodesFromOptions, useTorFlagFromOptions, rpcUserFromOptions, rpcPwFromOptions

private static final ArrayList<BlockChainExplorer> BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("Blockstream.info", "https://blockstream.info/tx/", "https://blockstream.info/address/"),
Expand Down Expand Up @@ -133,14 +137,19 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
private final ObservableList<FiatCurrency> fiatCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableList<CryptoCurrency> cryptoCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableList<TradeCurrency> tradeCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableList<String> xmrHostsAsObservable = FXCollections.observableArrayList();
private final ObservableMap<String, Boolean> dontShowAgainMapAsObservable = FXCollections.observableHashMap();

private final Storage<PreferencesPayload> storage;
private final BisqEnvironment bisqEnvironment;
private final String btcNodesFromOptions, useTorFlagFromOptions, referralIdFromOptions, fullDaoNodeFromOptions,
rpcUserFromOptions, rpcPwFromOptions, blockNotifyPortFromOptions;

private final String xmrUserHostDelegate, xmrHostPortDelegate, xmrRpcUserDelegate, xmrRpcPwdDelegate;
@Getter
private final BooleanProperty useStandbyModeProperty = new SimpleBooleanProperty(prefPayload.isUseStandbyMode());
@Getter
private final BooleanProperty useBisqXmrWalletProperty = new SimpleBooleanProperty(prefPayload.isUseBisqXmrWallet());


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -171,6 +180,11 @@ public Preferences(Storage<PreferencesPayload> storage,
this.rpcUserFromOptions = rpcUser;
this.rpcPwFromOptions = rpcPassword;
this.blockNotifyPortFromOptions = rpcBlockNotificationPort;

xmrUserHostDelegate = "127.0.0.1";
xmrHostPortDelegate = "29088";
xmrRpcUserDelegate = null;
xmrRpcPwdDelegate = null;

useAnimationsProperty.addListener((ov) -> {
prefPayload.setUseAnimations(useAnimationsProperty.get());
Expand All @@ -188,6 +202,11 @@ public Preferences(Storage<PreferencesPayload> storage,
persist();
});

useBisqXmrWalletProperty.addListener((ov) -> {
prefPayload.setUseBisqXmrWallet(useBisqXmrWalletProperty.get());
persist();
});

fiatCurrenciesAsObservable.addListener((javafx.beans.Observable ov) -> {
prefPayload.getFiatCurrencies().clear();
prefPayload.getFiatCurrencies().addAll(fiatCurrenciesAsObservable);
Expand Down Expand Up @@ -269,11 +288,13 @@ public void readPersisted() {
// set all properties
useAnimationsProperty.set(prefPayload.isUseAnimations());
useStandbyModeProperty.set(prefPayload.isUseStandbyMode());
useBisqXmrWalletProperty.set(prefPayload.isUseBisqXmrWallet());
useCustomWithdrawalTxFeeProperty.set(prefPayload.isUseCustomWithdrawalTxFee());
withdrawalTxFeeInBytesProperty.set(prefPayload.getWithdrawalTxFeeInBytes());

tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies());
tradeCurrenciesAsObservable.addAll(prefPayload.getCryptoCurrencies());
xmrHostsAsObservable.addAll(prefPayload.getXmrHosts());
dontShowAgainMapAsObservable.putAll(getDontShowAgainMap());

// Override settings with options if set
Expand Down Expand Up @@ -382,6 +403,27 @@ public void removeCryptoCurrency(CryptoCurrency tradeCurrency) {
}
}

public void addXmrHost(String host) {
if (!xmrHostsAsObservable.contains(host)) {
xmrHostsAsObservable.add(host);
}
}

public void removeXmrHost(String host) {
if (xmrHostsAsObservable.size() > 1) {
if (xmrHostsAsObservable.contains(host))
xmrHostsAsObservable.remove(host);

if (prefPayload.getXmrUserHost() != null &&
prefPayload.getXmrUserHost().equals(host)) {
setXmrUserHost(xmrHostsAsObservable.get(0));
}
} else {
log.error("you cannot remove the last Monero host");
}
}


public void setBlockChainExplorer(BlockChainExplorer blockChainExplorer) {
if (BisqEnvironment.getBaseCurrencyNetwork().isMainnet())
setBlockChainExplorerMainNet(blockChainExplorer);
Expand Down Expand Up @@ -622,6 +664,10 @@ public void setUseStandbyMode(boolean useStandbyMode) {
this.useStandbyModeProperty.set(useStandbyMode);
}

public void setUseBisqXmrWallet(boolean useBisqXmrWallet) {
this.useBisqXmrWalletProperty.set(useBisqXmrWallet);
}

public void setTakeOfferSelectedPaymentAccountId(String value) {
prefPayload.setTakeOfferSelectedPaymentAccountId(value);
persist();
Expand Down Expand Up @@ -653,6 +699,32 @@ public void setRpcPw(String value) {
}
}

public void setXmrUserHostDelegate(String value) {
prefPayload.setXmrUserHost(value);
persist();
}

public void setXmrHostPortDelegate(String value) {
prefPayload.setXmrHostPort(value);
persist();
}

public void setXmrRpcUserDelegate(String value) {
// We only persist if we have not set the program argument
if (xmrRpcUserDelegate == null || xmrRpcUserDelegate.isEmpty()) {
prefPayload.setXmrRpcUser(value);
persist();
}
}

public void setXmrRpcPwdDelegate(String value) {
// We only persist if we have not set the program argument
if (xmrRpcPwdDelegate == null || xmrRpcPwdDelegate.isEmpty()) {
prefPayload.setXmrRpcPwd(value);
persist();
}
}

public void setBlockNotifyPort(int value) {
// We only persist if we have not set the program argument
if (blockNotifyPortFromOptions == null || blockNotifyPortFromOptions.isEmpty()) {
Expand Down Expand Up @@ -686,6 +758,10 @@ public ObservableList<CryptoCurrency> getCryptoCurrenciesAsObservable() {
public ObservableList<TradeCurrency> getTradeCurrenciesAsObservable() {
return tradeCurrenciesAsObservable;
}

public ObservableList<String> getXmrHostsAsObservable() {
return xmrHostsAsObservable;
}

public ObservableMap<String, Boolean> getDontShowAgainMapAsObservable() {
return dontShowAgainMapAsObservable;
Expand Down Expand Up @@ -805,6 +881,38 @@ public String getRpcPw() {
}
}

public String getXmrUserHostDelegate() {
if (xmrUserHostDelegate != null && !xmrUserHostDelegate.isEmpty()) {
return xmrUserHostDelegate;
} else {
return prefPayload.getXmrUserHost();
}
}

public String getXmrHostPortDelegate() {
if (xmrHostPortDelegate != null && !xmrHostPortDelegate.isEmpty()) {
return xmrHostPortDelegate;
} else {
return prefPayload.getXmrUserHost();
}
}

public String getXmrRpcUserDelegate() {
if (xmrRpcUserDelegate != null && !xmrRpcUserDelegate.isEmpty()) {
return xmrRpcUserDelegate;
} else {
return prefPayload.getXmrRpcUser();
}
}

public String getXmrRpcPwdDelegate() {
if (xmrRpcPwdDelegate != null && !xmrRpcPwdDelegate.isEmpty()) {
return xmrRpcPwdDelegate;
} else {
return prefPayload.getXmrRpcPwd();
}
}

public int getBlockNotifyPort() {
if (blockNotifyPortFromOptions != null && !blockNotifyPortFromOptions.isEmpty()) {
try {
Expand Down Expand Up @@ -927,6 +1035,8 @@ private interface ExcludesDelegateMethods {
long getWithdrawalTxFeeInBytes();

void setUseStandbyMode(boolean useStandbyMode);

void setUseBisqXmrWallet(boolean useBisqXmrWallet);

void setTakeOfferSelectedPaymentAccountId(String value);

Expand Down
36 changes: 29 additions & 7 deletions core/src/main/java/bisq/core/user/PreferencesPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public final class PreferencesPayload implements PersistableEnvelope {
private long buyerSecurityDepositAsLong;

private boolean useAnimations;
private int cssTheme;
@Nullable
private PaymentAccount selectedPaymentAccountForCreateOffer;
private boolean payFeeInBtc = true;
Expand Down Expand Up @@ -125,8 +124,17 @@ public final class PreferencesPayload implements PersistableEnvelope {
private int ignoreDustThreshold = 600;
private double buyerSecurityDepositAsPercentForCrypto = getDefaultBuyerSecurityDepositAsPercent(new CryptoCurrencyAccount());
private int blockNotifyPort;


private int cssTheme;

private boolean useBisqXmrWallet = false;
private String xmrUserHost = "127.0.0.1";
private String xmrHostPort = "29088";
@Nullable
private String xmrRpcUser;
@Nullable
private String xmrRpcPwd;
private List<String> xmrHosts = new ArrayList<>();
private int xmrHostOptionOrdinal;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -171,7 +179,6 @@ public Message toProtoMessage() {
.setDirectoryChooserPath(directoryChooserPath)
.setBuyerSecurityDepositAsLong(buyerSecurityDepositAsLong)
.setUseAnimations(useAnimations)
.setCssTheme(cssTheme)
.setPayFeeInBtc(payFeeInBtc)
.setBridgeOptionOrdinal(bridgeOptionOrdinal)
.setTorTransportOrdinal(torTransportOrdinal)
Expand All @@ -185,7 +192,15 @@ public Message toProtoMessage() {
.setBuyerSecurityDepositAsPercent(buyerSecurityDepositAsPercent)
.setIgnoreDustThreshold(ignoreDustThreshold)
.setBuyerSecurityDepositAsPercentForCrypto(buyerSecurityDepositAsPercentForCrypto)
.setBlockNotifyPort(blockNotifyPort);
.setBlockNotifyPort(blockNotifyPort)
.setCssTheme(cssTheme)
.setUseBisqXmrWallet(useBisqXmrWallet)
.setXmrUserHost(xmrUserHost)
.setXmrHostPort(xmrHostPort)
.setXmrRpcUser(xmrRpcUser)
.setXmrRpcPwd(xmrRpcPwd)
.addAllXmrHosts(xmrHosts)
.setXmrHostOptionOrdinal(xmrHostOptionOrdinal);
Optional.ofNullable(backupDirectory).ifPresent(builder::setBackupDirectory);
Optional.ofNullable(preferredTradeCurrency).ifPresent(e -> builder.setPreferredTradeCurrency((protobuf.TradeCurrency) e.toProtoMessage()));
Optional.ofNullable(offerBookChartScreenCurrencyCode).ifPresent(builder::setOfferBookChartScreenCurrencyCode);
Expand Down Expand Up @@ -249,7 +264,6 @@ public static PersistableEnvelope fromProto(protobuf.PreferencesPayload proto, C
proto.getDirectoryChooserPath(),
proto.getBuyerSecurityDepositAsLong(),
proto.getUseAnimations(),
proto.getCssTheme(),
paymentAccount,
proto.getPayFeeInBtc(),
proto.getBridgeAddressesList().isEmpty() ? null : new ArrayList<>(proto.getBridgeAddressesList()),
Expand All @@ -271,7 +285,15 @@ public static PersistableEnvelope fromProto(protobuf.PreferencesPayload proto, C
proto.getBuyerSecurityDepositAsPercent(),
proto.getIgnoreDustThreshold(),
proto.getBuyerSecurityDepositAsPercentForCrypto(),
proto.getBlockNotifyPort());
proto.getBlockNotifyPort(),
proto.getCssTheme(),
proto.getUseBisqXmrWallet(),
proto.getXmrUserHost(),
proto.getXmrHostPort(),
proto.getXmrRpcUser(),
proto.getXmrRpcPwd(),
proto.getXmrHostsList(),
proto.getXmrHostOptionOrdinal());

}
}
Loading