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