Search in sources :

Example 1 with AddressEntry

use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.

the class BisqProxy method registerArbitrator.

public void registerArbitrator(List<String> languageCodes) {
    // TODO most of this code is dupplication of ArbitratorRegistrationViewModel.onRegister
    final String privKeyString = useDevPrivilegeKeys ? DevEnv.DEV_PRIVILEGE_PRIV_KEY : null;
    // TODO hm, are we going to send private key over http?
    if (null == privKeyString) {
        throw new RuntimeException("Missing private key");
    }
    ECKey registrationKey = arbitratorManager.getRegistrationKey(privKeyString);
    if (null == registrationKey) {
        throw new RuntimeException("Missing registration key");
    }
    AddressEntry arbitratorDepositAddressEntry = btcWalletService.getOrCreateAddressEntry(AddressEntry.Context.ARBITRATOR);
    String registrationSignature = arbitratorManager.signStorageSignaturePubKey(registrationKey);
    Arbitrator arbitrator = new Arbitrator(p2PService.getAddress(), arbitratorDepositAddressEntry.getPubKey(), arbitratorDepositAddressEntry.getAddressString(), keyRing.getPubKeyRing(), new ArrayList<>(languageCodes), new Date().getTime(), registrationKey.getPubKey(), registrationSignature, null, null, null);
    // TODO I don't know how to deal with those callbacks in order to send response back
    arbitratorManager.addArbitrator(arbitrator, () -> System.out.println("Arbi registered"), message -> System.out.println("Error when registering arbi: " + message));
}
Also used : AddressEntry(io.bisq.core.btc.AddressEntry) ECKey(org.bitcoinj.core.ECKey) Arbitrator(io.bisq.core.arbitration.Arbitrator)

Example 2 with AddressEntry

use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.

the class BisqProxy method updateLockedBalance.

// TODO copied from MainViewModel - refactor !
private Coin updateLockedBalance() {
    Stream<Trade> lockedTrades = Stream.concat(closedTradableManager.getLockedTradesStream(), failedTradesManager.getLockedTradesStream());
    lockedTrades = Stream.concat(lockedTrades, tradeManager.getLockedTradesStream());
    Coin sum = Coin.valueOf(lockedTrades.mapToLong(trade -> {
        final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
        if (addressEntryOptional.isPresent())
            return addressEntryOptional.get().getCoinLockedInMultiSig().getValue();
        else
            return 0;
    }).sum());
    return sum;
}
Also used : SellerAsMakerTrade(io.bisq.core.trade.SellerAsMakerTrade) Trade(io.bisq.core.trade.Trade) BuyerAsMakerTrade(io.bisq.core.trade.BuyerAsMakerTrade) Coin(org.bitcoinj.core.Coin) AddressEntry(io.bisq.core.btc.AddressEntry)

Example 3 with AddressEntry

use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.

the class MainViewModelHeadless method updateLockedBalance.

private void updateLockedBalance() {
    Stream<Trade> lockedTrades = Stream.concat(closedTradableManager.getLockedTradesStream(), failedTradesManager.getLockedTradesStream());
    lockedTrades = Stream.concat(lockedTrades, tradeManager.getLockedTradesStream());
    Coin sum = Coin.valueOf(lockedTrades.mapToLong(trade -> {
        final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
        if (addressEntryOptional.isPresent())
            return addressEntryOptional.get().getCoinLockedInMultiSig().getValue();
        else
            return 0;
    }).sum());
    lockedBalance.set(formatter.formatCoinWithCode(sum));
}
Also used : Trade(io.bisq.core.trade.Trade) Coin(org.bitcoinj.core.Coin) AddressEntry(io.bisq.core.btc.AddressEntry)

Example 4 with AddressEntry

use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.

the class MainViewModelHeadless method updateReservedBalance.

private void updateReservedBalance() {
    Coin sum = Coin.valueOf(openOfferManager.getObservableList().stream().map(openOffer -> {
        final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(openOffer.getId(), AddressEntry.Context.RESERVED_FOR_TRADE);
        if (addressEntryOptional.isPresent()) {
            Address address = addressEntryOptional.get().getAddress();
            return btcWalletService.getBalanceForAddress(address);
        } else {
            return null;
        }
    }).filter(e -> e != null).mapToLong(Coin::getValue).sum());
    reservedBalance.set(formatter.formatCoinWithCode(sum));
}
Also used : Alert(io.bisq.core.alert.Alert) AccountAgeWitnessService(io.bisq.core.payment.AccountAgeWitnessService) Transaction(org.bitcoinj.core.Transaction) NotificationCenter(io.bisq.gui.main.overlays.notifications.NotificationCenter) Coin(org.bitcoinj.core.Coin) Inject(com.google.inject.Inject) User(io.bisq.core.user.User) UserThread(io.bisq.common.UserThread) Security(java.security.Security) TimeoutException(java.util.concurrent.TimeoutException) PrivateNotificationPayload(io.bisq.core.alert.PrivateNotificationPayload) ChainFileLockedException(org.bitcoinj.store.ChainFileLockedException) ListChangeListener(javafx.collections.ListChangeListener) FeeService(io.bisq.core.provider.fee.FeeService) ClosedTradableManager(io.bisq.core.trade.closed.ClosedTradableManager) DecryptedDataTuple(io.bisq.network.crypto.DecryptedDataTuple) DisputeManager(io.bisq.core.arbitration.DisputeManager) CurrencyUtil(io.bisq.common.locale.CurrencyUtil) BlockStoreException(org.bitcoinj.store.BlockStoreException) PaymentMethod(io.bisq.core.payment.payload.PaymentMethod) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) BootstrapListener(io.bisq.network.p2p.BootstrapListener) GUIUtil(io.bisq.gui.util.GUIUtil) PrivateNotificationManager(io.bisq.core.alert.PrivateNotificationManager) Ping(io.bisq.network.p2p.peers.keepalive.messages.Ping) DaoManager(io.bisq.core.dao.DaoManager) BSFormatter(io.bisq.gui.util.BSFormatter) PriceFeedComboBoxItem(io.bisq.gui.main.PriceFeedComboBoxItem) GlobalSettings(io.bisq.common.GlobalSettings) Res(io.bisq.common.locale.Res) WalletsManager(io.bisq.core.btc.wallet.WalletsManager) Subscription(org.fxmisc.easybind.Subscription) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) BtcWalletService(io.bisq.core.btc.wallet.BtcWalletService) EncryptionService(io.bisq.network.crypto.EncryptionService) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) OpenOfferManager(io.bisq.core.offer.OpenOfferManager) Address(org.bitcoinj.core.Address) KeyRing(io.bisq.common.crypto.KeyRing) ObservableList(javafx.collections.ObservableList) PriceFeedService(io.bisq.core.provider.price.PriceFeedService) CryptoCurrencyAccount(io.bisq.core.payment.CryptoCurrencyAccount) TradeManager(io.bisq.core.trade.TradeManager) Socket(java.net.Socket) java.util(java.util) Dispute(io.bisq.core.arbitration.Dispute) ArbitratorManager(io.bisq.core.arbitration.ArbitratorManager) TradeCurrency(io.bisq.common.locale.TradeCurrency) Clock(io.bisq.common.Clock) Preferences(io.bisq.core.user.Preferences) FXCollections(javafx.collections.FXCollections) PerfectMoneyAccount(io.bisq.core.payment.PerfectMoneyAccount) TradeStatisticsManager(io.bisq.core.trade.statistics.TradeStatisticsManager) DontShowAgainLookup(io.bisq.core.user.DontShowAgainLookup) AlertManager(io.bisq.core.alert.AlertManager) FilterManager(io.bisq.core.filter.FilterManager) ConnectionListener(io.bisq.network.p2p.network.ConnectionListener) Trade(io.bisq.core.trade.Trade) FailedTradesManager(io.bisq.core.trade.failed.FailedTradesManager) MarketPrice(io.bisq.core.provider.price.MarketPrice) P2PServiceListener(io.bisq.network.p2p.P2PServiceListener) OpenOffer(io.bisq.core.offer.OpenOffer) Connection(io.bisq.network.p2p.network.Connection) Nullable(javax.annotation.Nullable) javafx.beans.property(javafx.beans.property) BisqEnvironment(io.bisq.core.app.BisqEnvironment) AddressEntry(io.bisq.core.btc.AddressEntry) SealedAndSigned(io.bisq.common.crypto.SealedAndSigned) SetupUtils(io.bisq.core.app.SetupUtils) AppOptionKeys(io.bisq.core.app.AppOptionKeys) IOException(java.io.IOException) CryptoException(io.bisq.common.crypto.CryptoException) TimeUnit(java.util.concurrent.TimeUnit) WalletsSetup(io.bisq.core.btc.wallet.WalletsSetup) CloseConnectionReason(io.bisq.network.p2p.network.CloseConnectionReason) BalanceListener(io.bisq.core.btc.listeners.BalanceListener) P2PService(io.bisq.network.p2p.P2PService) EasyBind(org.fxmisc.easybind.EasyBind) DevEnv(io.bisq.common.app.DevEnv) Timer(io.bisq.common.Timer) InetAddresses(com.google.common.net.InetAddresses) ChangeListener(javafx.beans.value.ChangeListener) Coin(org.bitcoinj.core.Coin) InetSocketAddress(java.net.InetSocketAddress) Address(org.bitcoinj.core.Address) AddressEntry(io.bisq.core.btc.AddressEntry)

Example 5 with AddressEntry

use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.

the class BtcWalletResource method getOrCreateBtcWalletAddresses.

@ApiOperation("Get or create wallet addresses")
@POST
@Path("/addresses")
public BtcWalletAddress getOrCreateBtcWalletAddresses(@Valid CreateBtcWalletAddress payload) {
    final AddressEntry addressEntry = bisqProxy.getOrCreateBtcWalletAddresses(payload.context, payload.unused);
    final BtcWalletAddress btcWalletAddress = new BtcWalletAddress();
    btcWalletAddress.address = addressEntry.getAddressString();
    return btcWalletAddress;
}
Also used : AddressEntry(io.bisq.core.btc.AddressEntry) BtcWalletAddress(io.bisq.api.model.BtcWalletAddress) CreateBtcWalletAddress(io.bisq.api.model.CreateBtcWalletAddress) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

AddressEntry (io.bisq.core.btc.AddressEntry)5 Trade (io.bisq.core.trade.Trade)3 Coin (org.bitcoinj.core.Coin)3 InetAddresses (com.google.common.net.InetAddresses)1 Inject (com.google.inject.Inject)1 BtcWalletAddress (io.bisq.api.model.BtcWalletAddress)1 CreateBtcWalletAddress (io.bisq.api.model.CreateBtcWalletAddress)1 Clock (io.bisq.common.Clock)1 GlobalSettings (io.bisq.common.GlobalSettings)1 Timer (io.bisq.common.Timer)1 UserThread (io.bisq.common.UserThread)1 DevEnv (io.bisq.common.app.DevEnv)1 CryptoException (io.bisq.common.crypto.CryptoException)1 KeyRing (io.bisq.common.crypto.KeyRing)1 SealedAndSigned (io.bisq.common.crypto.SealedAndSigned)1 CurrencyUtil (io.bisq.common.locale.CurrencyUtil)1 Res (io.bisq.common.locale.Res)1 TradeCurrency (io.bisq.common.locale.TradeCurrency)1 Alert (io.bisq.core.alert.Alert)1 AlertManager (io.bisq.core.alert.AlertManager)1