Search in sources :

Example 6 with NodeAddress

use of bisq.network.p2p.NodeAddress in project bisq-core by bisq-network.

the class MakerVerifyMediatorSelection method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        final NodeAddress selectedAddress = MediatorSelectionRule.select(processModel.getTakerAcceptedMediatorNodeAddresses(), processModel.getOffer());
        if (trade.getMediatorNodeAddress() != null && trade.getMediatorNodeAddress().equals(selectedAddress))
            complete();
        else
            failed("Mediator selection verification failed");
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : NodeAddress(bisq.network.p2p.NodeAddress)

Example 7 with NodeAddress

use of bisq.network.p2p.NodeAddress in project bisq-core by bisq-network.

the class SeedNodeAddressLookupTest method testResolveNodeAddressesWhenLocalAddressSpecified.

@Test
public void testResolveNodeAddressesWhenLocalAddressSpecified() {
    SeedNodeAddressLookup lookup = new SeedNodeAddressLookup(mock(BisqEnvironment.class), false, 1, "192.168.0.1:1234", "192.168.0.1:1234, 192.168.0.2:9897");
    Set<NodeAddress> actual = lookup.resolveNodeAddresses();
    Set<NodeAddress> expected = Collections.singleton(new NodeAddress("192.168.0.2:9897"));
    assertEquals(expected, actual);
}
Also used : BisqEnvironment(bisq.core.app.BisqEnvironment) NodeAddress(bisq.network.p2p.NodeAddress) Test(org.junit.Test)

Example 8 with NodeAddress

use of bisq.network.p2p.NodeAddress in project bisq-core by bisq-network.

the class SeedNodeAddressesTest method testCollector.

@Test
public void testCollector() {
    List<NodeAddress> addresses = Lists.newArrayList(new NodeAddress("192.168.0.1:1111"), new NodeAddress("192.168.0.1:1111"), new NodeAddress("192.168.0.2:2222"));
    Set<NodeAddress> expected = new HashSet<>(addresses);
    SeedNodeAddresses actual = addresses.stream().collect(SeedNodeAddresses.collector());
    assertEquals(expected, actual);
}
Also used : NodeAddress(bisq.network.p2p.NodeAddress) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with NodeAddress

use of bisq.network.p2p.NodeAddress in project bisq-core by bisq-network.

the class SeedNodeAddressesTest method testFromString.

@Test
public void testFromString() {
    Set<NodeAddress> expected = Sets.newHashSet(new NodeAddress("192.168.0.1:1111"), new NodeAddress("192.168.0.2:2222"));
    SeedNodeAddresses actual = SeedNodeAddresses.fromString("192.168.0.1:1111, 192.168.0.2:2222");
    assertEquals(expected, actual);
}
Also used : NodeAddress(bisq.network.p2p.NodeAddress) Test(org.junit.Test)

Example 10 with NodeAddress

use of bisq.network.p2p.NodeAddress in project bisq-core by bisq-network.

the class TakerSendPayDepositRequest method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        checkNotNull(trade.getTradeAmount(), "TradeAmount must not be null");
        checkNotNull(trade.getTakerFeeTxId(), "TakeOfferFeeTxId must not be null");
        final User user = processModel.getUser();
        checkNotNull(user, "User must not be null");
        final List<NodeAddress> acceptedArbitratorAddresses = user.getAcceptedArbitratorAddresses();
        final List<NodeAddress> acceptedMediatorAddresses = user.getAcceptedMediatorAddresses();
        checkNotNull(acceptedArbitratorAddresses, "acceptedArbitratorAddresses must not be null");
        checkNotNull(acceptedMediatorAddresses, "acceptedMediatorAddresses must not be null");
        BtcWalletService walletService = processModel.getBtcWalletService();
        String id = processModel.getOffer().getId();
        checkArgument(!walletService.getAddressEntry(id, AddressEntry.Context.MULTI_SIG).isPresent(), "addressEntry must not be set here.");
        AddressEntry addressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.MULTI_SIG);
        byte[] takerMultiSigPubKey = addressEntry.getPubKey();
        processModel.setMyMultiSigPubKey(takerMultiSigPubKey);
        AddressEntry takerPayoutAddressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT);
        String takerPayoutAddressString = takerPayoutAddressEntry.getAddressString();
        final String offerId = processModel.getOfferId();
        // Taker has to use offerId as nonce (he cannot manipulate that - so we avoid to have a challenge protocol for passing the nonce we want to get signed)
        // He cannot manipulate the offerId - so we avoid to have a challenge protocol for passing the nonce we want to get signed.
        final PaymentAccountPayload paymentAccountPayload = checkNotNull(processModel.getPaymentAccountPayload(trade), "processModel.getPaymentAccountPayload(trade) must not be null");
        byte[] sig = Sig.sign(processModel.getKeyRing().getSignatureKeyPair().getPrivate(), offerId.getBytes());
        PayDepositRequest message = new PayDepositRequest(offerId, processModel.getMyNodeAddress(), trade.getTradeAmount().value, trade.getTradePrice().getValue(), trade.getTxFee().getValue(), trade.getTakerFee().getValue(), trade.isCurrencyForTakerFeeBtc(), processModel.getRawTransactionInputs(), processModel.getChangeOutputValue(), processModel.getChangeOutputAddress(), takerMultiSigPubKey, takerPayoutAddressString, processModel.getPubKeyRing(), paymentAccountPayload, processModel.getAccountId(), trade.getTakerFeeTxId(), new ArrayList<>(acceptedArbitratorAddresses), new ArrayList<>(acceptedMediatorAddresses), trade.getArbitratorNodeAddress(), trade.getMediatorNodeAddress(), UUID.randomUUID().toString(), Version.getP2PMessageVersion(), sig, new Date().getTime());
        processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeerNodeAddress(), processModel.getTradingPeer().getPubKeyRing(), message, new SendDirectMessageListener() {

            @Override
            public void onArrived() {
                log.debug("Message arrived at peer. tradeId={}, message{}", id, message);
                complete();
            }

            @Override
            public void onFault() {
                appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage);
                failed();
            }
        });
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : User(bisq.core.user.User) AddressEntry(bisq.core.btc.AddressEntry) PaymentAccountPayload(bisq.core.payment.payload.PaymentAccountPayload) SendDirectMessageListener(bisq.network.p2p.SendDirectMessageListener) Date(java.util.Date) PayDepositRequest(bisq.core.trade.messages.PayDepositRequest) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) NodeAddress(bisq.network.p2p.NodeAddress)

Aggregations

NodeAddress (bisq.network.p2p.NodeAddress)32 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)6 Contract (bisq.core.trade.Contract)5 Test (org.junit.Test)5 PubKeyRing (bisq.common.crypto.PubKeyRing)4 AddressEntry (bisq.core.btc.AddressEntry)4 Offer (bisq.core.offer.Offer)4 PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)4 SendMailboxMessageListener (bisq.network.p2p.SendMailboxMessageListener)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Insets (javafx.geometry.Insets)4 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)3 MailboxMessage (bisq.network.p2p.MailboxMessage)3 List (java.util.List)3 TableCell (javafx.scene.control.TableCell)3 TableColumn (javafx.scene.control.TableColumn)3 ErrorMessageHandler (bisq.common.handlers.ErrorMessageHandler)2 ResultHandler (bisq.common.handlers.ResultHandler)2 BisqEnvironment (bisq.core.app.BisqEnvironment)2