mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-23 03:59:36 +00:00
parent
d9762b06d1
commit
ed4394dc5d
1 changed files with 9 additions and 1 deletions
|
@ -19,6 +19,8 @@ package bisq.core.api;
|
||||||
|
|
||||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||||
import bisq.core.api.model.PaymentAccountForm;
|
import bisq.core.api.model.PaymentAccountForm;
|
||||||
|
import bisq.core.locale.CryptoCurrency;
|
||||||
|
import bisq.core.payment.AssetAccount;
|
||||||
import bisq.core.payment.CryptoCurrencyAccount;
|
import bisq.core.payment.CryptoCurrencyAccount;
|
||||||
import bisq.core.payment.InstantCryptoCurrencyAccount;
|
import bisq.core.payment.InstantCryptoCurrencyAccount;
|
||||||
import bisq.core.payment.PaymentAccount;
|
import bisq.core.payment.PaymentAccount;
|
||||||
|
@ -33,11 +35,13 @@ import java.io.File;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import static bisq.core.locale.CurrencyUtil.getCryptoCurrency;
|
||||||
import static java.lang.String.format;
|
import static java.lang.String.format;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -100,14 +104,18 @@ class CorePaymentAccountsService {
|
||||||
String currencyCode,
|
String currencyCode,
|
||||||
String address,
|
String address,
|
||||||
boolean tradeInstant) {
|
boolean tradeInstant) {
|
||||||
|
if (currencyCode == null) throw new RuntimeException("Cryptocurrency code is null");
|
||||||
var cryptoCurrencyAccount = tradeInstant
|
var cryptoCurrencyAccount = tradeInstant
|
||||||
? (InstantCryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS_INSTANT)
|
? (InstantCryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS_INSTANT)
|
||||||
: (CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
|
: (CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
|
||||||
cryptoCurrencyAccount.init();
|
cryptoCurrencyAccount.init();
|
||||||
cryptoCurrencyAccount.setAccountName(accountName);
|
cryptoCurrencyAccount.setAccountName(accountName);
|
||||||
cryptoCurrencyAccount.setAddress(address);
|
cryptoCurrencyAccount.setAddress(address);
|
||||||
|
Optional<CryptoCurrency> cryptoCurrency = getCryptoCurrency(currencyCode.toUpperCase());
|
||||||
|
if (!cryptoCurrency.isPresent()) throw new RuntimeException("Unsupported cryptocurrency code: " + currencyCode.toUpperCase());
|
||||||
|
cryptoCurrencyAccount.setSingleTradeCurrency(cryptoCurrency.get());
|
||||||
user.addPaymentAccount(cryptoCurrencyAccount);
|
user.addPaymentAccount(cryptoCurrencyAccount);
|
||||||
accountAgeWitnessService.publishMyAccountAgeWitness(cryptoCurrencyAccount.getPaymentAccountPayload());
|
if (!(cryptoCurrencyAccount instanceof AssetAccount)) accountAgeWitnessService.publishMyAccountAgeWitness(cryptoCurrencyAccount.getPaymentAccountPayload()); // TODO (woodser): applies to Haveno?
|
||||||
log.info("Saved crypto payment account with id {} and payment method {}.",
|
log.info("Saved crypto payment account with id {} and payment method {}.",
|
||||||
cryptoCurrencyAccount.getId(),
|
cryptoCurrencyAccount.getId(),
|
||||||
cryptoCurrencyAccount.getPaymentAccountPayload().getPaymentMethodId());
|
cryptoCurrencyAccount.getPaymentAccountPayload().getPaymentMethodId());
|
||||||
|
|
Loading…
Reference in a new issue