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

Add payment methods Strike and Verse #5752

Merged
merged 1 commit into from Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions core/src/main/java/bisq/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,17 @@ public static List<TradeCurrency> getAllMoneseCurrencies() {
));
}

// https://github.com/bisq-network/growth/issues/223
public static List<TradeCurrency> getAllVerseCurrencies() {
return new ArrayList<>(Arrays.asList(
new FiatCurrency("DKK"),
new FiatCurrency("EUR"),
new FiatCurrency("HUF"),
new FiatCurrency("PLN"),
new FiatCurrency("SEK")
));
}

// https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange
public static List<TradeCurrency> getAllRevolutCurrencies() {
ArrayList<TradeCurrency> currencies = new ArrayList<>(Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) {
return new MoneseAccount();
case PaymentMethod.SATISPAY_ID:
return new SatispayAccount();
case PaymentMethod.VERSE_ID:
return new VerseAccount();
case PaymentMethod.STRIKE_ID:
return new StrikeAccount();
case PaymentMethod.SWIFT_ID:
return new SwiftAccount();

Expand Down
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/StrikeAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment;

import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.payment.payload.StrikeAccountPayload;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class StrikeAccount extends CountryBasedPaymentAccount {
public StrikeAccount() {
super(PaymentMethod.STRIKE);
}

@Override
protected PaymentAccountPayload createPayload() {
return new StrikeAccountPayload(paymentMethod.getId(), id);
}

public void setHolderName(String accountId) {
((StrikeAccountPayload) paymentAccountPayload).setHolderName(accountId);
}

public String getHolderName() {
return ((StrikeAccountPayload) paymentAccountPayload).getHolderName();
}

public String getMessageForBuyer() {
return "payment.strike.info.buyer";
}

public String getMessageForSeller() {
return "payment.strike.info.seller";
}

public String getMessageForAccountCreation() {
return "payment.strike.info.account";
}
}
56 changes: 56 additions & 0 deletions core/src/main/java/bisq/core/payment/VerseAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment;

import bisq.core.payment.payload.VerseAccountPayload;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public final class VerseAccount extends PaymentAccount {
public VerseAccount() {
super(PaymentMethod.VERSE);
}

@Override
protected PaymentAccountPayload createPayload() {
return new VerseAccountPayload(paymentMethod.getId(), id);
}

public void setHolderName(String accountId) {
((VerseAccountPayload) paymentAccountPayload).setHolderName(accountId);
}

public String getHolderName() {
return ((VerseAccountPayload) paymentAccountPayload).getHolderName();
}

public String getMessageForBuyer() {
return "payment.verse.info.buyer";
}

public String getMessageForSeller() {
return "payment.verse.info.seller";
}

public String getMessageForAccountCreation() {
return "payment.verse.info.account";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static final String CELPAY_ID = "CELPAY";
public static final String MONESE_ID = "MONESE";
public static final String SATISPAY_ID = "SATISPAY";
public static final String VERSE_ID = "VERSE";
public static final String STRIKE_ID = "STRIKE";
public static final String SWIFT_ID = "SWIFT";

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -169,6 +171,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
public static PaymentMethod CELPAY;
public static PaymentMethod MONESE;
public static PaymentMethod SATISPAY;
public static PaymentMethod VERSE;
public static PaymentMethod STRIKE;
public static PaymentMethod SWIFT;

// Cannot be deleted as it would break old trade history entries
Expand Down Expand Up @@ -235,6 +239,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
CELPAY = new PaymentMethod(CELPAY_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
MONESE = new PaymentMethod(MONESE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
SATISPAY = new PaymentMethod(SATISPAY_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
VERSE = new PaymentMethod(VERSE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
STRIKE = new PaymentMethod(STRIKE_ID, DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK),
SWIFT = new PaymentMethod(SWIFT_ID, 7 * DAY, DEFAULT_TRADE_LIMIT_MID_RISK),

// Japan
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment.payload;

import bisq.core.locale.Res;

import com.google.protobuf.Message;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
import java.util.Map;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class StrikeAccountPayload extends CountryBasedPaymentAccountPayload {
private String holderName = "";

public StrikeAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}

private StrikeAccountPayload(String paymentMethod,
String id,
String countryCode,
String holderName,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
countryCode,
maxTradePeriod,
excludeFromJsonDataMap);

this.holderName = holderName;
}

@Override
public Message toProtoMessage() {
protobuf.StrikeAccountPayload.Builder builder = protobuf.StrikeAccountPayload.newBuilder()
.setHolderName(holderName);
final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder()
.getCountryBasedPaymentAccountPayloadBuilder()
.setStrikeAccountPayload(builder);
return getPaymentAccountPayloadBuilder()
.setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload)
.build();
}

public static StrikeAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload();
protobuf.StrikeAccountPayload accountPayloadPB = countryBasedPaymentAccountPayload.getStrikeAccountPayload();
return new StrikeAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
countryBasedPaymentAccountPayload.getCountryCode(),
accountPayloadPB.getHolderName(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName;
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.payment.payload;

import bisq.core.locale.Res;

import com.google.protobuf.Message;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
import java.util.Map;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@EqualsAndHashCode(callSuper = true)
@ToString
@Setter
@Getter
@Slf4j
public final class VerseAccountPayload extends PaymentAccountPayload {
private String holderName = "";

public VerseAccountPayload(String paymentMethod, String id) {
super(paymentMethod, id);
}

private VerseAccountPayload(String paymentMethod,
String id,
String holderName,
long maxTradePeriod,
Map<String, String> excludeFromJsonDataMap) {
super(paymentMethod,
id,
maxTradePeriod,
excludeFromJsonDataMap);

this.holderName = holderName;
}

@Override
public Message toProtoMessage() {
return getPaymentAccountPayloadBuilder()
.setVerseAccountPayload(protobuf.VerseAccountPayload.newBuilder().setHolderName(holderName))
.build();
}

public static VerseAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return new VerseAccountPayload(proto.getPaymentMethodId(),
proto.getId(),
proto.getVerseAccountPayload().getHolderName(),
proto.getMaxTradePeriod(),
new HashMap<>(proto.getExcludeFromJsonDataMap()));
}

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName;
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8));
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/proto/CoreProtoResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@
import bisq.core.payment.payload.SepaAccountPayload;
import bisq.core.payment.payload.SepaInstantAccountPayload;
import bisq.core.payment.payload.SpecificBanksAccountPayload;
import bisq.core.payment.payload.StrikeAccountPayload;
import bisq.core.payment.payload.SwiftAccountPayload;
import bisq.core.payment.payload.SwishAccountPayload;
import bisq.core.payment.payload.TransferwiseAccountPayload;
import bisq.core.payment.payload.USPostalMoneyOrderAccountPayload;
import bisq.core.payment.payload.UpholdAccountPayload;
import bisq.core.payment.payload.UpiAccountPayload;
import bisq.core.payment.payload.VenmoAccountPayload;
import bisq.core.payment.payload.VerseAccountPayload;
import bisq.core.payment.payload.WeChatPayAccountPayload;
import bisq.core.payment.payload.WesternUnionAccountPayload;
import bisq.core.trade.statistics.TradeStatistics2;
Expand Down Expand Up @@ -141,6 +143,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return PixAccountPayload.fromProto(proto);
case SATISPAY_ACCOUNT_PAYLOAD:
return SatispayAccountPayload.fromProto(proto);
case STRIKE_ACCOUNT_PAYLOAD:
return StrikeAccountPayload.fromProto(proto);
case IFSC_BASED_ACCOUNT_PAYLOAD:
final protobuf.IfscBasedAccountPayload.MessageCase messageCaseIfsc = proto.getCountryBasedPaymentAccountPayload().getIfscBasedAccountPayload().getMessageCase();
switch (messageCaseIfsc) {
Expand Down Expand Up @@ -210,6 +214,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) {
return CelPayAccountPayload.fromProto(proto);
case MONESE_ACCOUNT_PAYLOAD:
return MoneseAccountPayload.fromProto(proto);
case VERSE_ACCOUNT_PAYLOAD:
return VerseAccountPayload.fromProto(proto);
case SWIFT_ACCOUNT_PAYLOAD:
return SwiftAccountPayload.fromProto(proto);

Expand Down
Loading