Search in sources :

Example 1 with Offer

use of bisq.core.offer.Offer in project bisq-core by bisq-network.

the class SellerSignAndFinalizePayoutTx method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        checkNotNull(trade.getTradeAmount(), "trade.getTradeAmount() must not be null");
        Offer offer = trade.getOffer();
        TradingPeer tradingPeer = processModel.getTradingPeer();
        BtcWalletService walletService = processModel.getBtcWalletService();
        String id = processModel.getOffer().getId();
        final byte[] buyerSignature = tradingPeer.getSignature();
        Coin buyerPayoutAmount = offer.getBuyerSecurityDeposit().add(trade.getTradeAmount());
        Coin sellerPayoutAmount = offer.getSellerSecurityDeposit();
        final String buyerPayoutAddressString = tradingPeer.getPayoutAddressString();
        String sellerPayoutAddressString = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT).getAddressString();
        final byte[] buyerMultiSigPubKey = tradingPeer.getMultiSigPubKey();
        byte[] sellerMultiSigPubKey = processModel.getMyMultiSigPubKey();
        Optional<AddressEntry> MultiSigAddressEntryOptional = walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG);
        checkArgument(MultiSigAddressEntryOptional.isPresent() && Arrays.equals(sellerMultiSigPubKey, MultiSigAddressEntryOptional.get().getPubKey()), "sellerMultiSigPubKey from AddressEntry must match the one from the trade data. trade id =" + id);
        DeterministicKey multiSigKeyPair = walletService.getMultiSigKeyPair(id, sellerMultiSigPubKey);
        Transaction transaction = processModel.getTradeWalletService().sellerSignsAndFinalizesPayoutTx(trade.getDepositTx(), buyerSignature, buyerPayoutAmount, sellerPayoutAmount, buyerPayoutAddressString, sellerPayoutAddressString, multiSigKeyPair, buyerMultiSigPubKey, sellerMultiSigPubKey, trade.getArbitratorBtcPubKey());
        trade.setPayoutTx(transaction);
        walletService.swapTradeEntryToAvailableEntry(id, AddressEntry.Context.MULTI_SIG);
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : Coin(org.bitcoinj.core.Coin) TradingPeer(bisq.core.trade.protocol.TradingPeer) Transaction(org.bitcoinj.core.Transaction) Offer(bisq.core.offer.Offer) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) AddressEntry(bisq.core.btc.AddressEntry) DeterministicKey(org.bitcoinj.crypto.DeterministicKey)

Example 2 with Offer

use of bisq.core.offer.Offer in project bisq-core by bisq-network.

the class ReceiptPredicatesTest method testIsEqualPaymentMethods.

@Test
public void testIsEqualPaymentMethods() {
    final PaymentMethod method = new PaymentMethod("1");
    Offer offer = mock(Offer.class);
    when(offer.getPaymentMethod()).thenReturn(method);
    PaymentAccount account = mock(PaymentAccount.class);
    when(account.getPaymentMethod()).thenReturn(method);
    assertTrue(predicates.isEqualPaymentMethods(offer, account));
}
Also used : Offer(bisq.core.offer.Offer) PaymentMethod(bisq.core.payment.payload.PaymentMethod) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class BSFormatterTest method testFormatSameVolume.

@Test
public void testFormatSameVolume() {
    Offer offer = mock(Offer.class);
    Volume btc = Volume.parse("0.10", "BTC");
    when(offer.getMinVolume()).thenReturn(btc);
    when(offer.getVolume()).thenReturn(btc);
    assertEquals("0.10000000", formatter.formatVolume(offer.getVolume()));
}
Also used : OfferMaker.btcUsdOffer(bisq.core.offer.OfferMaker.btcUsdOffer) Offer(bisq.core.offer.Offer) Volume(bisq.core.monetary.Volume) VolumeMaker.usdVolume(bisq.core.monetary.VolumeMaker.usdVolume) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class BSFormatterTest method testFormatNullAmount.

@Test
public void testFormatNullAmount() {
    Offer offer = mock(Offer.class);
    when(offer.getMinAmount()).thenReturn(null);
    when(offer.getAmount()).thenReturn(null);
    assertEquals("", formatter.formatAmount(offer));
}
Also used : OfferMaker.btcUsdOffer(bisq.core.offer.OfferMaker.btcUsdOffer) Offer(bisq.core.offer.Offer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with Offer

use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.

the class BSFormatterTest method testFormatSameAmount.

@Test
public void testFormatSameAmount() {
    Offer offer = mock(Offer.class);
    when(offer.getMinAmount()).thenReturn(Coin.valueOf(10000000));
    when(offer.getAmount()).thenReturn(Coin.valueOf(10000000));
    assertEquals("0.10", formatter.formatAmount(offer));
}
Also used : OfferMaker.btcUsdOffer(bisq.core.offer.OfferMaker.btcUsdOffer) Offer(bisq.core.offer.Offer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Offer (bisq.core.offer.Offer)53 Coin (org.bitcoinj.core.Coin)18 Test (org.junit.Test)13 OfferPayload (bisq.core.offer.OfferPayload)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 Price (bisq.core.monetary.Price)9 OfferMaker.btcUsdOffer (bisq.core.offer.OfferMaker.btcUsdOffer)8 NodeAddress (bisq.network.p2p.NodeAddress)8 PaymentMethod (bisq.core.payment.payload.PaymentMethod)7 Contract (bisq.core.trade.Contract)7 Volume (bisq.core.monetary.Volume)6 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 OpenOffer (bisq.core.offer.OpenOffer)5 PaymentAccount (bisq.core.payment.PaymentAccount)5 MainView (bisq.desktop.main.MainView)5 Button (javafx.scene.control.Button)5 TableCell (javafx.scene.control.TableCell)5 TableColumn (javafx.scene.control.TableColumn)5 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)4