-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5752 from jmacxx/add_strike_verse
Add payment methods Strike and Verse
- Loading branch information
Showing
15 changed files
with
617 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
core/src/main/java/bisq/core/payment/payload/StrikeAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
core/src/main/java/bisq/core/payment/payload/VerseAccountPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.