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());
}
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;
}
Aggregations