mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Altcoin disclaimer
This commit is contained in:
parent
d320380e80
commit
7e9bc1fee8
@ -0,0 +1,25 @@
|
||||
package bisq.asset;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* When a new PaymentAccount is created for given asset, this annotation tells UI to show user a disclaimer message
|
||||
* with requirements needed to be fulfilled when conducting trade given payment method.
|
||||
*
|
||||
* I.e. in case of Monero user must use official Monero GUI wallet or Monero CLI wallet with certain options enabled,
|
||||
* user needs to keep tx private key, tx hash, recipient's address, etc.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface AltCoinAccountDisclaimer {
|
||||
|
||||
/**
|
||||
* Translation key of the message to show, i.e. "account.altcoin.popup.xmr.msg"
|
||||
* @return translation key
|
||||
*/
|
||||
String value();
|
||||
|
||||
}
|
@ -26,15 +26,22 @@ package bisq.asset;
|
||||
public class RegexAddressValidator implements AddressValidator {
|
||||
|
||||
private final String regex;
|
||||
private final String errorMessageI18nKey;
|
||||
|
||||
public RegexAddressValidator(String regex) {
|
||||
this(regex, null);
|
||||
}
|
||||
|
||||
public RegexAddressValidator(String regex, String errorMessageI18nKey) {
|
||||
this.regex = regex;
|
||||
this.errorMessageI18nKey = errorMessageI18nKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressValidationResult validate(String address) {
|
||||
if (!address.matches(regex))
|
||||
return AddressValidationResult.invalidStructure();
|
||||
if (errorMessageI18nKey == null) return AddressValidationResult.invalidStructure();
|
||||
else return AddressValidationResult.invalidAddress("", errorMessageI18nKey);
|
||||
|
||||
return AddressValidationResult.validAddress();
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package bisq.asset.coins;
|
||||
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Coin;
|
||||
import bisq.asset.CryptonoteAddressValidator;
|
||||
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.blur.msg")
|
||||
public class Blur extends Coin {
|
||||
|
||||
public Blur() {
|
||||
|
@ -17,10 +17,11 @@
|
||||
|
||||
package bisq.asset.coins;
|
||||
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Coin;
|
||||
import bisq.asset.RegexAddressValidator;
|
||||
|
||||
// Not an ICO token (see https://github.com/bisq-network/proposals/issues/57#issuecomment-441671418)
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.drgl.msg")
|
||||
public class Dragonglass extends Coin {
|
||||
|
||||
public Dragonglass() {
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package bisq.asset.coins;
|
||||
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Coin;
|
||||
import bisq.asset.CryptonoteAddressValidator;
|
||||
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.xmr.msg")
|
||||
public class Monero extends Coin {
|
||||
|
||||
public Monero() {
|
||||
|
@ -17,26 +17,15 @@
|
||||
|
||||
package bisq.asset.coins;
|
||||
|
||||
import bisq.asset.AddressValidationResult;
|
||||
import bisq.asset.AddressValidator;
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Coin;
|
||||
import bisq.asset.RegexAddressValidator;
|
||||
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.ZEC.msg")
|
||||
public class Zcash extends Coin {
|
||||
|
||||
public Zcash() {
|
||||
super("Zcash", "ZEC", new ZcashAddressValidator());
|
||||
super("Zcash", "ZEC", new RegexAddressValidator("^t.*", "validation.altcoin.zAddressesNotSupported"));
|
||||
}
|
||||
|
||||
|
||||
public static class ZcashAddressValidator implements AddressValidator {
|
||||
|
||||
@Override
|
||||
public AddressValidationResult validate(String address) {
|
||||
// We only support t addresses (transparent transactions)
|
||||
if (!address.startsWith("t"))
|
||||
return AddressValidationResult.invalidAddress("", "validation.altcoin.zAddressesNotSupported");
|
||||
|
||||
return AddressValidationResult.validAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package bisq.asset.coins;
|
||||
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Coin;
|
||||
import bisq.asset.DefaultAddressValidator;
|
||||
|
||||
@AltCoinAccountDisclaimer("account.altcoin.popup.XZC.msg")
|
||||
public class Zcoin extends Coin {
|
||||
|
||||
public Zcoin() {
|
||||
|
@ -482,6 +482,12 @@ public class CurrencyUtil {
|
||||
throw new IllegalArgumentException("We are on mainnet and we could not find an asset with network type mainnet");
|
||||
}
|
||||
|
||||
public static Optional<Asset> findAsset(String tickerSymbol) {
|
||||
return assetRegistry.stream()
|
||||
.filter(asset -> asset.getTickerSymbol().equals(tickerSymbol))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
public static Optional<Asset> findAsset(String tickerSymbol, BaseCurrencyNetwork baseCurrencyNetwork) {
|
||||
return assetRegistry.stream()
|
||||
.filter(asset -> asset.getTickerSymbol().equals(tickerSymbol))
|
||||
|
@ -1038,15 +1038,6 @@ transfer using the Blur Transaction Viewer (https://blur.cash/#tx-viewer).\n\n\
|
||||
Failure to provide the required information to the arbitrator will result in losing the dispute case. In all cases of dispute, the \
|
||||
BLUR sender bears 100% of the burden of responsibility in verifying transactions to an arbitrator. \n\n\
|
||||
If you do not understand these requirements, do not trade on Bisq. First, seek help at the Blur Network Discord (https://discord.gg/dMWaqVW).
|
||||
account.altcoin.popup.ccx.msg=Trading CCX on Bisq requires that you understand the following requirements:\n\n\
|
||||
To send CCX you must use an official Conceal wallet, either CLI or GUI. After sending a transfer payment, the wallets\n\
|
||||
display the transaction secret key. You must save it along with the transaction hash (ID) and the recipient's public\n\
|
||||
address in case arbitration is necessary. In such a case, you must give all three to the arbitrator, who will then\n\
|
||||
verify the CCX transfer using the Conceal Transaction Viewer (https://explorer.conceal.network/txviewer).\n\
|
||||
Because Conceal is a privacy coin, block explorers cannot verify transfers.\n\n\
|
||||
Failure to provide the required data to the arbitrator will result in losing the dispute case.\n\
|
||||
If you do not save the transaction secret key immediately after transferring CCX, it cannot be recovered later.\n\
|
||||
If you do not understand these requirements, seek help at the Conceal discord (http://discord.conceal.network).
|
||||
account.altcoin.popup.drgl.msg=Trading Dragonglass on Bisq requires that you understand and fulfill \
|
||||
the following requirements:\n\n\
|
||||
Because of the privacy Dragonglass provides, a transaction is not verifiable on the public blockchain. If required, you \
|
||||
@ -1064,17 +1055,10 @@ Failure to provide the above data, or if you used an incompatible wallet, will r
|
||||
dispute case. The Dragonglass sender is responsible for providing verification of the DRGL transfer to the \
|
||||
arbitrator in case of a dispute. Use of PaymentID is not required.\n\n\
|
||||
If you are unsure about any part of this process, visit Dragonglass on Discord (http://discord.drgl.info) for help.
|
||||
account.altcoin.popup.ZEC.msg=When using {0} you can only use the transparent addresses (starting with t) not \
|
||||
account.altcoin.popup.ZEC.msg=When using Zcash you can only use the transparent addresses (starting with t) not \
|
||||
the z-addresses (private), because the arbitrator would not be able to verify the transaction with z-addresses.
|
||||
account.altcoin.popup.XZC.msg=When using {0} you can only use the transparent (traceable) addresses not \
|
||||
account.altcoin.popup.XZC.msg=When using Zcoin you can only use the transparent (traceable) addresses not \
|
||||
the untraceable addresses, because the arbitrator would not be able to verify the transaction with untraceable addresses at a block explorer.
|
||||
account.altcoin.popup.bch=Bitcoin Cash and Bitcoin Clashic suffer from replay protection. If you use those coins be sure you take sufficient precautions and understand all implications.\
|
||||
You can suffer losses by sending one coin and unintentionally send the same coins on the other block chain.\
|
||||
Because those "airdrop coins" share the same history with the Bitcoin blockchain there are also security risks and a considerable risk for losing privacy.\n\n\
|
||||
Please read at the Bisq Forum more about that topic: https://forum.bisq.io/t/airdrop-coins-information-thread-bch-btg-bchc
|
||||
account.altcoin.popup.btg=Because Bitcoin Gold shares the same history as the Bitcoin blockchain it comes with certain security risks and a considerable risk for losing privacy.\
|
||||
If you use Bitcoin Gold be sure you take sufficient precautions and understand all implications.\n\n\
|
||||
Please read at the Bisq Forum more about that topic: https://forum.bisq.io/t/airdrop-coins-information-thread-bch-btg-bchc
|
||||
|
||||
account.fiat.yourFiatAccounts=Your national currency accounts
|
||||
|
||||
|
@ -29,6 +29,7 @@ import bisq.desktop.util.Layout;
|
||||
import bisq.core.dao.governance.asset.AssetService;
|
||||
import bisq.core.filter.FilterManager;
|
||||
import bisq.core.locale.CryptoCurrency;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.locale.TradeCurrency;
|
||||
import bisq.core.payment.AccountAgeWitnessService;
|
||||
@ -39,6 +40,9 @@ import bisq.core.payment.validation.AltCoinAddressValidator;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.validation.InputValidator;
|
||||
|
||||
import bisq.asset.AltCoinAccountDisclaimer;
|
||||
import bisq.asset.Asset;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
import bisq.common.util.Tuple3;
|
||||
|
||||
@ -54,6 +58,8 @@ import javafx.scene.layout.VBox;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup;
|
||||
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
|
||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||
@ -115,7 +121,6 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
|
||||
private void onSaveNewAccount(PaymentAccount paymentAccount) {
|
||||
TradeCurrency selectedTradeCurrency = paymentAccount.getSelectedTradeCurrency();
|
||||
if (selectedTradeCurrency != null) {
|
||||
String code = selectedTradeCurrency.getCode();
|
||||
if (selectedTradeCurrency instanceof CryptoCurrency && ((CryptoCurrency) selectedTradeCurrency).isAsset()) {
|
||||
String name = selectedTradeCurrency.getName();
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.wallet.msg",
|
||||
@ -126,47 +131,14 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
|
||||
.show();
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
case "XMR":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.xmr.msg"))
|
||||
final Optional<Asset> asset = CurrencyUtil.findAsset(selectedTradeCurrency.getCode());
|
||||
if (asset.isPresent()) {
|
||||
final AltCoinAccountDisclaimer disclaimerAnnotation = asset.get().getClass().getAnnotation(AltCoinAccountDisclaimer.class);
|
||||
if (disclaimerAnnotation != null) {
|
||||
new Popup<>().information(Res.get(disclaimerAnnotation.value()))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "BLUR":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.blur.msg"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "CCX":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.ccx.msg"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "DRGL":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.drgl.msg"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "ZEC":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.ZEC.msg", "ZEC"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "XZC":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.XZC.msg", "XZC"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "BCHC":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.bch"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
case "BTG":
|
||||
new Popup<>().information(Res.get("account.altcoin.popup.btg"))
|
||||
.useIUnderstandButton()
|
||||
.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.getPaymentAccounts().stream().noneMatch(e -> e.getAccountName() != null &&
|
||||
|
Loading…
Reference in New Issue
Block a user