Search in sources :

Example 1 with WalletAddress

use of network.bisq.api.model.WalletAddress in project bisq-api by mrosseel.

the class BisqProxy method convertAddressEntryToWalletAddress.

@NotNull
private static WalletAddress convertAddressEntryToWalletAddress(AddressEntry entry, BtcWalletService btcWalletService) {
    final Coin balance;
    if (AddressEntry.Context.MULTI_SIG.equals(entry.getContext())) {
        balance = entry.getCoinLockedInMultiSig();
    } else {
        balance = btcWalletService.getBalanceForAddress(entry.getAddress());
    }
    final TransactionConfidence confidence = btcWalletService.getConfidenceForAddress(entry.getAddress());
    final int confirmations = null == confidence ? 0 : confidence.getDepthInBlocks();
    return new WalletAddress(entry.getAddressString(), balance.getValue(), confirmations, entry.getContext(), entry.getOfferId());
}
Also used : Coin(org.bitcoinj.core.Coin) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) WalletAddress(network.bisq.api.model.WalletAddress) NotNull(org.jetbrains.annotations.NotNull) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull)

Example 2 with WalletAddress

use of network.bisq.api.model.WalletAddress in project bisq-api by mrosseel.

the class BisqProxy method getWalletAddresses.

public WalletAddressList getWalletAddresses(WalletAddressPurpose purpose) {
    final Stream<AddressEntry> addressEntryStream;
    if (WalletAddressPurpose.SEND_FUNDS.equals(purpose)) {
        addressEntryStream = tradeManager.getAddressEntriesForAvailableBalanceStream();
    } else if (WalletAddressPurpose.RESERVED_FUNDS.equals(purpose)) {
        addressEntryStream = getReservedFundsAddressEntryStream();
    } else if (WalletAddressPurpose.LOCKED_FUNDS.equals(purpose)) {
        addressEntryStream = getLockedFundsAddressEntryStream();
    } else if (WalletAddressPurpose.RECEIVE_FUNDS.equals(purpose)) {
        addressEntryStream = btcWalletService.getAvailableAddressEntries().stream();
    } else {
        addressEntryStream = btcWalletService.getAddressEntryListAsImmutableList().stream();
    }
    final List<WalletAddress> walletAddresses = addressEntryStream.map(entry -> convertAddressEntryToWalletAddress(entry, btcWalletService)).collect(toList());
    final WalletAddressList walletAddressList = new WalletAddressList();
    walletAddressList.walletAddresses = walletAddresses;
    walletAddressList.total = walletAddresses.size();
    return walletAddressList;
}
Also used : Arrays(java.util.Arrays) OpenOffer(bisq.core.offer.OpenOffer) User(bisq.core.user.User) PriceFeed(network.bisq.api.model.PriceFeed) Statistic(bisq.network.p2p.network.Statistic) ZoneOffset(java.time.ZoneOffset) KeyParameter(org.spongycastle.crypto.params.KeyParameter) ClosedTradableDetails(network.bisq.api.model.ClosedTradableDetails) CurrencyList(network.bisq.api.model.CurrencyList) WalletAddress(network.bisq.api.model.WalletAddress) AddressEntryException(bisq.core.btc.AddressEntryException) Offer(bisq.core.offer.Offer) ClosedTradableManager(bisq.core.trade.closed.ClosedTradableManager) SellerAsMakerProtocol(bisq.core.trade.protocol.SellerAsMakerProtocol) WalletTransactionList(network.bisq.api.model.WalletTransactionList) InsufficientFundsException(bisq.core.btc.InsufficientFundsException) Set(java.util.Set) TokenRegistry(network.bisq.api.service.TokenRegistry) BlockChainExplorer(bisq.core.user.BlockChainExplorer) TradeProtocol(bisq.core.trade.protocol.TradeProtocol) ZoneId(java.time.ZoneId) ECKey(org.bitcoinj.core.ECKey) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) AddressEntry(bisq.core.btc.AddressEntry) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) CryptoCurrency(bisq.core.locale.CryptoCurrency) Currency(network.bisq.api.model.Currency) TradeManager(bisq.core.trade.TradeManager) NodeAddress(bisq.network.p2p.NodeAddress) SellerAsTakerProtocol(bisq.core.trade.protocol.SellerAsTakerProtocol) CountryUtil(bisq.core.locale.CountryUtil) BuyerAsTakerProtocol(bisq.core.trade.protocol.BuyerAsTakerProtocol) TransactionOutput(org.bitcoinj.core.TransactionOutput) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) PaymentAccountHelper(network.bisq.api.model.payment.PaymentAccountHelper) Restrictions(bisq.core.btc.Restrictions) Arbitrator(bisq.core.arbitration.Arbitrator) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) Wallet(org.bitcoinj.wallet.Wallet) Peer(org.bitcoinj.core.Peer) ArrayList(java.util.ArrayList) ClosedTradableConverter(network.bisq.api.model.ClosedTradableConverter) OfferPayload(bisq.core.offer.OfferPayload) Country(bisq.core.locale.Country) BitcoinNetworkStatus(network.bisq.api.model.BitcoinNetworkStatus) WalletDetails(network.bisq.api.model.WalletDetails) Nullable(javax.annotation.Nullable) IOException(java.io.IOException) OfferBookService(bisq.core.offer.OfferBookService) Names(com.google.inject.name.Names) BisqEnvironment(bisq.core.app.BisqEnvironment) SeedWords(network.bisq.api.model.SeedWords) FutureCallback(com.google.common.util.concurrent.FutureCallback) File(java.io.File) OpenOfferManager(bisq.core.offer.OpenOfferManager) InputValidator(bisq.core.util.validation.InputValidator) PriceFeedService(bisq.core.provider.price.PriceFeedService) PaymentAccountList(network.bisq.api.model.PaymentAccountList) KeyRing(bisq.common.crypto.KeyRing) PreferencesAvailableValues(network.bisq.api.model.PreferencesAvailableValues) Transaction(org.bitcoinj.core.Transaction) Preferences(network.bisq.api.model.Preferences) Date(java.util.Date) Coin(org.bitcoinj.core.Coin) Key(com.google.inject.Key) AltCoinAddressValidator(bisq.core.payment.validation.AltCoinAddressValidator) VersionDetails(network.bisq.api.model.VersionDetails) Res(bisq.core.locale.Res) ErrorMessageHandler(bisq.common.handlers.ErrorMessageHandler) KeyCrypterScrypt(org.bitcoinj.crypto.KeyCrypterScrypt) PaymentAccountUtil.isPaymentAccountValidForOffer(bisq.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer) OfferUtil(bisq.core.offer.OfferUtil) P2PService(bisq.network.p2p.P2PService) Predicate(java.util.function.Predicate) ArbitratorManager(bisq.core.arbitration.ArbitratorManager) Collection(java.util.Collection) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) BsqWalletService(bisq.core.btc.wallet.BsqWalletService) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) FileUtil(bisq.common.storage.FileUtil) List(java.util.List) PaymentAccount(bisq.core.payment.PaymentAccount) DeterministicSeed(org.bitcoinj.wallet.DeterministicSeed) DevEnv(bisq.common.app.DevEnv) MarketList(network.bisq.api.model.MarketList) AppOptionKeys(bisq.core.app.AppOptionKeys) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Address(org.bitcoinj.core.Address) NotNull(org.jetbrains.annotations.NotNull) MarketPrice(bisq.core.provider.price.MarketPrice) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) TradeCurrency(bisq.core.locale.TradeCurrency) SellerAsMakerTrade(bisq.core.trade.SellerAsMakerTrade) Getter(lombok.Getter) WalletService(bisq.core.btc.wallet.WalletService) CompletableFuture(java.util.concurrent.CompletableFuture) FiatCurrency(bisq.core.locale.FiatCurrency) WalletsManager(bisq.core.btc.wallet.WalletsManager) Tuple2(bisq.common.util.Tuple2) BuyerAsMakerProtocol(bisq.core.trade.protocol.BuyerAsMakerProtocol) P2PNetworkStatus(network.bisq.api.model.P2PNetworkStatus) Market(network.bisq.api.model.Market) CurrencyUtil(bisq.core.locale.CurrencyUtil) BitcoinNodes(bisq.core.btc.BitcoinNodes) Version(bisq.common.app.Version) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) P2PNetworkConnection(network.bisq.api.model.P2PNetworkConnection) BuyerAsMakerTrade(bisq.core.trade.BuyerAsMakerTrade) Trade(bisq.core.trade.Trade) WalletAddressList(network.bisq.api.model.WalletAddressList) ResultHandler(bisq.common.handlers.ResultHandler) FailedTradesManager(bisq.core.trade.failed.FailedTradesManager) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) FileInputStream(java.io.FileInputStream) WalletTransaction(network.bisq.api.model.WalletTransaction) Injector(com.google.inject.Injector) Collectors.toList(java.util.stream.Collectors.toList) AuthResult(network.bisq.api.model.AuthResult) ValidationException(javax.validation.ValidationException) Storage(bisq.common.storage.Storage) Comparator(java.util.Comparator) Collections(java.util.Collections) CoinUtil(bisq.core.util.CoinUtil) InputStream(java.io.InputStream) AddressEntry(bisq.core.btc.AddressEntry) WalletAddressList(network.bisq.api.model.WalletAddressList) WalletAddress(network.bisq.api.model.WalletAddress)

Aggregations

DevEnv (bisq.common.app.DevEnv)1 Version (bisq.common.app.Version)1 KeyRing (bisq.common.crypto.KeyRing)1 ErrorMessageHandler (bisq.common.handlers.ErrorMessageHandler)1 ResultHandler (bisq.common.handlers.ResultHandler)1 FileUtil (bisq.common.storage.FileUtil)1 Storage (bisq.common.storage.Storage)1 Tuple2 (bisq.common.util.Tuple2)1 AppOptionKeys (bisq.core.app.AppOptionKeys)1 BisqEnvironment (bisq.core.app.BisqEnvironment)1 Arbitrator (bisq.core.arbitration.Arbitrator)1 ArbitratorManager (bisq.core.arbitration.ArbitratorManager)1 AddressEntry (bisq.core.btc.AddressEntry)1 AddressEntryException (bisq.core.btc.AddressEntryException)1 BitcoinNodes (bisq.core.btc.BitcoinNodes)1 InsufficientFundsException (bisq.core.btc.InsufficientFundsException)1 Restrictions (bisq.core.btc.Restrictions)1 BsqWalletService (bisq.core.btc.wallet.BsqWalletService)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 WalletService (bisq.core.btc.wallet.WalletService)1