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