mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
all toProto implemented on messages and payloads, remaining: fromProto
This commit is contained in:
parent
113e28f9ed
commit
219ea61f85
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.common.crypto;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -114,4 +116,10 @@ public final class PubKeyRing implements Payload {
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PubKeyRing toProtoBuf() {
|
||||
return Messages.PubKeyRing.newBuilder().setSignaturePubKeyBytes(ByteString.copyFrom(signaturePubKeyBytes))
|
||||
.setEncryptionPubKeyBytes(ByteString.copyFrom(encryptionPubKeyBytes)).build();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.common.crypto;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -51,13 +53,13 @@ public final class SealedAndSigned implements Payload {
|
||||
}
|
||||
|
||||
public SealedAndSigned(byte[] encryptedSecretKey, byte[] encryptedPayloadWithHmac, byte[] signature, byte[] sigPublicKeyBytes) {
|
||||
this(encryptedSecretKey, encryptedPayloadWithHmac, signature, SealedAndSigned.createSigPublicKey(sigPublicKeyBytes));
|
||||
this(encryptedSecretKey, encryptedPayloadWithHmac, signature, SealedAndSigned.init(sigPublicKeyBytes));
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
in.defaultReadObject();
|
||||
sigPublicKey = createSigPublicKey(sigPublicKeyBytes);
|
||||
sigPublicKey = init(sigPublicKeyBytes);
|
||||
} catch (Throwable t) {
|
||||
log.warn("Exception at readObject: " + t.getMessage());
|
||||
}
|
||||
@ -67,7 +69,7 @@ public final class SealedAndSigned implements Payload {
|
||||
* We have the bytes, now recreate the sigPublicKey. This happens when receiving this class over the wire,
|
||||
* because the public key is transient.
|
||||
*/
|
||||
static PublicKey createSigPublicKey(byte[] sigPublicKeyBytes) {
|
||||
static PublicKey init(byte[] sigPublicKeyBytes) {
|
||||
PublicKey publicKey = null;
|
||||
try {
|
||||
publicKey = KeyFactory.getInstance(Sig.KEY_ALGO, "BC")
|
||||
@ -78,6 +80,14 @@ public final class SealedAndSigned implements Payload {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
|
||||
public Messages.SealedAndSigned toProtoBuf() {
|
||||
return Messages.SealedAndSigned.newBuilder().setEncryptedSecretKey(ByteString.copyFrom(encryptedSecretKey))
|
||||
.setEncryptedPayloadWithHmac(ByteString.copyFrom(encryptedPayloadWithHmac))
|
||||
.setSignature(ByteString.copyFrom(signature)).setSigPublicKeyBytes(ByteString.copyFrom(sigPublicKeyBytes))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@ -100,4 +110,5 @@ public final class SealedAndSigned implements Payload {
|
||||
result = 31 * result + (sigPublicKey != null ? sigPublicKey.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package io.bitsquare.common.wire;
|
||||
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Marker interface for data which is sent over the wire
|
||||
*/
|
||||
public interface Payload extends Serializable {
|
||||
Object toProtoBuf();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package io.bitsquare.proto;
|
||||
|
||||
//
|
||||
@ -25,12 +24,23 @@ message Envelope {
|
||||
SendersNodeAddressMessage senders_node_address_message = 12;
|
||||
PrefixedSealedAndSignedMessage prefixed_sealed_and_signed_message = 13;
|
||||
OfferAvailabilityResponse offer_availability_response = 14;
|
||||
|
||||
|
||||
RemoveDataMessage remove_data_message = 15;
|
||||
AddDataMessage add_data_message = 16;
|
||||
RemoveMailboxDataMessage remove_mailbox_data_message = 17;
|
||||
DepositTxPublishedMessage deposit_tx_published_message = 18;
|
||||
FinalizePayoutTxRequest finalize_payout_tx_request = 19;
|
||||
DisputeCommunicationMessage dispute_communication_message = 20;
|
||||
OpenNewDisputeMessage open_new_dispute_message = 21;
|
||||
PeerOpenedDisputeMessage peer_opened_dispute_message = 22;
|
||||
DisputeResultMessage dispute_result_message = 23;
|
||||
PeerPublishedPayoutTxMessage peer_published_payout_tx_message = 24;
|
||||
PayDepositRequest pay_deposit_request = 25;
|
||||
PublishDepositTxRequest publish_deposit_tx_request = 26;
|
||||
FiatTransferStartedMessage fiat_transfer_started_message = 27;
|
||||
PayoutTxFinalizedMessage payout_tx_finalized_message = 28;
|
||||
CashDepositAccountContractData cash_deposit_account_contract_data = 29;
|
||||
SpecificBanksAccountContractData specific_banks_account_contract_data = 30;
|
||||
PrivateNotificationMessage private_notification_message = 31;
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,8 +161,16 @@ message RemoveMailboxDataMessage {
|
||||
|
||||
// start storagepayloads
|
||||
message StoragePayload {
|
||||
//oneof message {
|
||||
//}
|
||||
oneof message {
|
||||
Alert alert = 1;
|
||||
Arbitrator arbitrator = 2;
|
||||
Filter filter = 3;
|
||||
PaymentAccountFilter payment_account_filter = 4;
|
||||
CompensationRequestPayload compensation_request_payload = 5;
|
||||
TradeStatistics trade_statistics = 6;
|
||||
MailboxStoragePayload mailbox_storage_payload = 7;
|
||||
Offer offer = 8;
|
||||
}
|
||||
}
|
||||
|
||||
message Alert {
|
||||
@ -421,7 +439,7 @@ message Contract {
|
||||
Offer offer = 1;
|
||||
int64 trade_amount = 2;
|
||||
int64 trade_price = 3;
|
||||
string take_offer_fee_tx_i_d = 4;
|
||||
string take_offer_fee_tx_id = 4;
|
||||
NodeAddress arbitrator_node_address = 5;
|
||||
bool is_buyer_offerer_and_seller_taker = 6;
|
||||
string offerer_account_id = 7;
|
||||
@ -458,6 +476,12 @@ message MockMailboxPayload {
|
||||
string uid = 5;
|
||||
}
|
||||
|
||||
message MockPayload {
|
||||
string messageVersion = 1;
|
||||
string msg = 2;
|
||||
string ttl = 3;
|
||||
}
|
||||
|
||||
message PayDepositRequest {
|
||||
string trade_id = 1;
|
||||
int64 trade_amount = 2;
|
||||
@ -504,6 +528,7 @@ message PrivateNotificationMessage {
|
||||
PrivateNotification private_notification = 4;
|
||||
}
|
||||
|
||||
|
||||
message PrivateNotification {
|
||||
string message = 1;
|
||||
string signature_as_base64 = 2;
|
||||
@ -571,32 +596,45 @@ message PaymentAccountContractData {
|
||||
string id = 1;
|
||||
string payment_method_name = 2;
|
||||
int64 max_trade_period = 3;
|
||||
oneof message {
|
||||
AliPayAccountContractData ali_pay_account_contract_data = 4;
|
||||
ChaseQuickPayAccountContractData chase_quick_pay_account_contract_data = 5;
|
||||
ClearXchangeAccountContractData clear_xchange_account_contract_data = 6;
|
||||
CountryBasedPaymentAccountContractData country_based_payment_account_contract_data = 7;
|
||||
CryptoCurrencyAccountContractData crypto_currency_account_contract_data = 8;
|
||||
FasterPaymentsAccountContractData faster_payments_account_contract_data = 9;
|
||||
InteracETransferAccountContractData interac_e_transfer_account_contract_data = 10;
|
||||
OKPayAccountContractData o_k_pay_account_contract_data = 11;
|
||||
PerfectMoneyAccountContractData perfect_money_account_contract_data = 12;
|
||||
SwishAccountContractData swish_account_contract_data = 13;
|
||||
USPostalMoneyOrderAccountContractData u_s_postal_money_order_account_contract_data = 14;
|
||||
}
|
||||
}
|
||||
|
||||
message AliPayAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string account_nr = 2;
|
||||
string account_nr = 1;
|
||||
}
|
||||
|
||||
message ChaseQuickPayAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string email = 2;
|
||||
string holder_name = 3;
|
||||
string email = 1;
|
||||
string holder_name = 2;
|
||||
}
|
||||
|
||||
message ClearXchangeAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string holder_name = 2;
|
||||
string email_or_mobile_nr = 3;
|
||||
string holder_name = 1;
|
||||
string email_or_mobile_nr = 2;
|
||||
}
|
||||
|
||||
message CountryBasedPaymentAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string countryCode = 2;
|
||||
string countryCode = 1;
|
||||
oneof message {
|
||||
BankAccountContractData bank_account_contract_data = 2;
|
||||
CashDepositAccountContractData cash_deposit_account_contract_data = 3;
|
||||
SepaAccountContractData sepa_account_contract_data = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message BankAccountContractData {
|
||||
CountryBasedPaymentAccountContractData country_based_payment_account_contract_data = 1;
|
||||
string holder_name = 2;
|
||||
string bank_name = 3;
|
||||
string bank_id = 4;
|
||||
@ -604,80 +642,73 @@ message BankAccountContractData {
|
||||
string account_nr = 6;
|
||||
string account_type = 7;
|
||||
string holder_tax_id = 8;
|
||||
oneof message {
|
||||
NationalBankAccountContractData national_bank_account_contract_data = 9;
|
||||
SameBankAccountContractData same_bank_accont_contract_data = 10;
|
||||
SpecificBanksAccountContractData specific_banks_account_contract_data = 11;
|
||||
}
|
||||
}
|
||||
|
||||
message NationalBankAccountContractData {
|
||||
BankAccountContractData bank_account_contract_data = 1;
|
||||
}
|
||||
|
||||
message SameBankAccountContractData {
|
||||
BankAccountContractData bank_account_contract_data = 1;
|
||||
}
|
||||
message SpecificBanksAccountContractData {
|
||||
BankAccountContractData bank_account_contract_data = 1;
|
||||
repeated string accepted_banks = 2;
|
||||
}
|
||||
|
||||
message CashDepositAccountContractData {
|
||||
CountryBasedPaymentAccountContractData country_based_payment_account_contract_data = 1;
|
||||
string holder_name = 2;
|
||||
string holder_email = 3;
|
||||
string bank_name = 4;
|
||||
string bank_id = 5;
|
||||
string branch_id = 6;
|
||||
string account_nr = 7;
|
||||
string account_type = 8;
|
||||
string requirements = 9;
|
||||
string holder_tax_id = 10;
|
||||
string holder_name = 1;
|
||||
string holder_email = 2;
|
||||
string bank_name = 3;
|
||||
string bank_id = 4;
|
||||
string branch_id = 5;
|
||||
string account_nr = 6;
|
||||
string account_type = 7;
|
||||
string requirements = 8;
|
||||
string holder_tax_id = 9;
|
||||
}
|
||||
|
||||
message SepaAccountContractData {
|
||||
CountryBasedPaymentAccountContractData country_based_payment_account_contract_data = 1;
|
||||
string holder_name = 2;
|
||||
string iban = 3;
|
||||
string bic = 4;
|
||||
repeated string accepted_country_codes = 5;
|
||||
string holder_name = 1;
|
||||
string iban = 2;
|
||||
string bic = 3;
|
||||
repeated string accepted_country_codes = 4;
|
||||
}
|
||||
|
||||
message CryptoCurrencyAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string address = 2;
|
||||
string address = 1;
|
||||
}
|
||||
|
||||
message FasterPaymentsAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string sort_code = 2;
|
||||
string account_nr = 3;
|
||||
string sort_code = 1;
|
||||
string account_nr = 2;
|
||||
}
|
||||
|
||||
message InteracETransferAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string email = 2;
|
||||
string holder_name = 3;
|
||||
string question = 4;
|
||||
string answer = 5;
|
||||
string email = 1;
|
||||
string holder_name = 2;
|
||||
string question = 3;
|
||||
string answer = 4;
|
||||
}
|
||||
|
||||
message OKPayAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string account_nr = 2;
|
||||
string account_nr = 1;
|
||||
}
|
||||
|
||||
message PerfectMoneyAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string account_nr = 2;
|
||||
string account_nr = 1;
|
||||
}
|
||||
|
||||
message SwishAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string mobile_nr = 2;
|
||||
string holder_name = 3;
|
||||
string mobile_nr = 1;
|
||||
string holder_name = 2;
|
||||
}
|
||||
|
||||
message USPostalMoneyOrderAccountContractData {
|
||||
PaymentAccountContractData payment_account_contract_data = 1;
|
||||
string postal_address = 2;
|
||||
string holder_name = 3;
|
||||
string postal_address = 1;
|
||||
string holder_name = 2;
|
||||
}
|
||||
|
||||
message ProtectedMailboxStorageEntry {
|
||||
|
@ -34,6 +34,7 @@ public class ProtoBufferTest {
|
||||
//log.info("peerseesd empty: '{}'",envelope3.getPong().equals(Messages.Envelope.) == "");
|
||||
assertTrue(isPing(envelope3));
|
||||
assertTrue(!isPing(envelope4));
|
||||
|
||||
log.info("3 = {} 4 = {}",isPing(envelope3), isPing(envelope4));
|
||||
log.info(envelope3.toString());
|
||||
log.info(envelope4.toString());
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.alert;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -81,7 +83,7 @@ public final class Alert implements StoragePayload {
|
||||
}
|
||||
|
||||
public boolean isNewVersion() {
|
||||
// Usually we use 3 digits (0.4.8) but to support also 4 digits in case of hotfixes (0.4.8.1) we
|
||||
// Usually we use 3 digits (0.4.8) but to support also 4 digits in case of hotfixes (0.4.8.1) we
|
||||
// add a 0 at all 3 digit versions to allow correct comparison: 0.4.8 -> 480; 0.4.8.1 -> 481; 481 > 480
|
||||
String myVersionString = Version.VERSION.replace(".", "");
|
||||
if (myVersionString.length() == 3)
|
||||
@ -105,6 +107,16 @@ public final class Alert implements StoragePayload {
|
||||
return storagePublicKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setAlert(Messages.Alert.newBuilder().setTTL(TTL)
|
||||
.setMessage(message)
|
||||
.setVersion(version)
|
||||
.setIsUpdateInfo(isUpdateInfo)
|
||||
.setSignatureAsBase64(signatureAsBase64)
|
||||
.setStoragePublicKeyBytes(ByteString.copyFrom(storagePublicKeyBytes))).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package io.bitsquare.alert;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -111,4 +113,12 @@ public final class PrivateNotification implements Payload {
|
||||
", publicKeyBytes=" + Arrays.toString(publicKeyBytes) +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PrivateNotification toProtoBuf() {
|
||||
return Messages.PrivateNotification.newBuilder()
|
||||
.setMessage(message)
|
||||
.setSignatureAsBase64(signatureAsBase64)
|
||||
.setPublicKeyBytes(ByteString.copyFrom(publicKeyBytes)).build();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.bitsquare.alert;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -37,6 +39,16 @@ public class PrivateNotificationMessage implements MailboxMessage {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPrivateNotificationMessage(baseEnvelope.getPrivateNotificationMessageBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
.setUid(uid)
|
||||
.setMyNodeAddress(myNodeAddress.toProtoBuf())
|
||||
.setPrivateNotification(privateNotification.toProtoBuf())).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
|
||||
@ -110,6 +112,22 @@ public final class Arbitrator implements StoragePayload {
|
||||
return registrationPubKey;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setArbitrator(Messages.Arbitrator.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.setBtcPubKey(ByteString.copyFrom(btcPubKey))
|
||||
.setPubKeyRing((Messages.PubKeyRing) pubKeyRing.toProtoBuf())
|
||||
.setArbitratorNodeAddress(arbitratorNodeAddress.toProtoBuf())
|
||||
.addAllLanguageCodes(languageCodes)
|
||||
.setBtcAddress(btcAddress)
|
||||
.setRegistrationDate(registrationDate)
|
||||
.setRegistrationSignature(registrationSignature)
|
||||
.setRegistrationPubKey(ByteString.copyFrom(registrationPubKey))).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -17,10 +17,13 @@
|
||||
|
||||
package io.bitsquare.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.messages.DisputeCommunicationMessage;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.storage.Storage;
|
||||
import io.bitsquare.trade.Contract;
|
||||
import javafx.beans.property.*;
|
||||
@ -37,6 +40,7 @@ import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode
|
||||
@ -330,4 +334,31 @@ public final class Dispute implements Payload {
|
||||
", disputeResultProperty=" + disputeResultProperty +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Dispute toProtoBuf() {
|
||||
return Messages.Dispute.newBuilder().setTradeId(tradeId)
|
||||
.setId(id)
|
||||
.setTraderId(traderId)
|
||||
.setDisputeOpenerIsBuyer(disputeOpenerIsBuyer)
|
||||
.setDisputeOpenerIsOfferer(disputeOpenerIsOfferer)
|
||||
.setOpeningDate(openingDate)
|
||||
.setTraderPubKeyRing(traderPubKeyRing.toProtoBuf())
|
||||
.setTradeDate(tradeDate)
|
||||
.setContract(contract.toProtoBuf())
|
||||
.setContractHash(ByteString.copyFrom(contractHash))
|
||||
.setDepositTxSerialized(ByteString.copyFrom(depositTxSerialized))
|
||||
.setPayoutTxId(payoutTxId)
|
||||
.setDepositTxId(depositTxId)
|
||||
.setPayoutTxId(payoutTxId)
|
||||
.setContractAsJson(contractAsJson)
|
||||
.setOffererContractSignature(offererContractSignature)
|
||||
.setTakerContractSignature(takerContractSignature)
|
||||
.setArbitratorPubKeyRing(arbitratorPubKeyRing.toProtoBuf())
|
||||
.setIsSupportTicket(isSupportTicket)
|
||||
.addAllDisputeCommunicationMessages(disputeCommunicationMessages.stream().map(disputeCommunicationMessage -> disputeCommunicationMessage.toProtoBuf().getDisputeCommunicationMessage()).collect(Collectors.toList()))
|
||||
.setIsClosed(isClosed)
|
||||
.setDisputeResult((Messages.DisputeResult) disputeResult.toProtoBuf())
|
||||
.setDisputePayoutTxId(disputePayoutTxId).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package io.bitsquare.arbitration;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.messages.DisputeCommunicationMessage;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import javafx.beans.property.*;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.slf4j.Logger;
|
||||
@ -36,6 +38,29 @@ public final class DisputeResult implements Payload {
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
|
||||
|
||||
@Override
|
||||
public Messages.DisputeResult toProtoBuf() {
|
||||
return Messages.DisputeResult.newBuilder()
|
||||
.setTradeId(tradeId)
|
||||
.setTraderId(traderId)
|
||||
.setDisputeFeePolicy(Messages.DisputeResult.DisputeFeePolicy.forNumber(disputeFeePolicy.ordinal()))
|
||||
.setWinner(Messages.DisputeResult.Winner.forNumber(winner.ordinal()))
|
||||
.setReasonOrdinal(reasonOrdinal)
|
||||
.setTamperProofEvidence(tamperProofEvidence)
|
||||
.setIdVerification(idVerification)
|
||||
.setScreenCast(screenCast)
|
||||
.setSummaryNotes(summaryNotes)
|
||||
.setDisputeCommunicationMessage(disputeCommunicationMessage.toProtoBuf().getDisputeCommunicationMessage())
|
||||
.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature))
|
||||
.setBuyerPayoutAmount(buyerPayoutAmount)
|
||||
.setSellerPayoutAmount(sellerPayoutAmount)
|
||||
.setArbitratorPayoutAmount(arbitratorPayoutAmount)
|
||||
.setArbitratorAddressAsstring(arbitratorAddressAsString)
|
||||
.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey))
|
||||
.setCloseDate(closeDate)
|
||||
.setIsLoserPublisher(isLoserPublisher).build();
|
||||
}
|
||||
|
||||
public enum DisputeFeePolicy {
|
||||
LOSER,
|
||||
SPLIT,
|
||||
@ -50,10 +75,10 @@ public final class DisputeResult implements Payload {
|
||||
|
||||
// only append new values as we use the ordinal value
|
||||
public enum Reason {
|
||||
OTHER,
|
||||
BUG,
|
||||
USABILITY,
|
||||
SCAM,
|
||||
OTHER,
|
||||
PROTOCOL_VIOLATION,
|
||||
NO_REPLY
|
||||
}
|
||||
|
@ -17,9 +17,12 @@
|
||||
|
||||
package io.bitsquare.arbitration.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.payload.Attachment;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import org.slf4j.Logger;
|
||||
@ -30,6 +33,7 @@ import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class DisputeCommunicationMessage extends DisputeMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -193,4 +197,20 @@ public final class DisputeCommunicationMessage extends DisputeMessage {
|
||||
", attachments=" + attachments +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setDisputeCommunicationMessage(Messages.DisputeCommunicationMessage.newBuilder()
|
||||
.setDate(date)
|
||||
.setTradeId(tradeId)
|
||||
.setTraderId(traderId)
|
||||
.setSenderIsTrader(senderIsTrader)
|
||||
.setMessage(message)
|
||||
.addAllAttachments(attachments.stream().map(attachment -> attachment.toProtoBuf()).collect(Collectors.toList()))
|
||||
.setArrived(arrived)
|
||||
.setStoredInMailbox(storedInMailbox)
|
||||
.setIsSystemMessage(isSystemMessage)
|
||||
.setMyNodeAddress(myNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ package io.bitsquare.arbitration.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.DisputeResult;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
public final class DisputeResultMessage extends DisputeMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -57,4 +59,12 @@ public final class DisputeResultMessage extends DisputeMessage {
|
||||
public NodeAddress getSenderNodeAddress() {
|
||||
return myNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setDisputeResultMessage(Messages.DisputeResultMessage.newBuilder()
|
||||
.setDisputeResult(disputeResult.toProtoBuf())
|
||||
.setMyNodeAddress(myNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,12 @@
|
||||
|
||||
package io.bitsquare.arbitration.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
public final class OpenNewDisputeMessage extends DisputeMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -63,4 +66,11 @@ public final class OpenNewDisputeMessage extends DisputeMessage {
|
||||
public NodeAddress getSenderNodeAddress() {
|
||||
return myNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setOpenNewDisputeMessage(Messages.OpenNewDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProtoBuf()).setMyNodeAddress(myNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ package io.bitsquare.arbitration.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.Dispute;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -62,4 +64,12 @@ public final class PeerOpenedDisputeMessage extends DisputeMessage {
|
||||
public NodeAddress getSenderNodeAddress() {
|
||||
return myNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPeerOpenedDisputeMessage(Messages.PeerOpenedDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProtoBuf())
|
||||
.setMyNodeAddress(myNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
package io.bitsquare.arbitration.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -70,4 +73,12 @@ public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
|
||||
return myNodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPeerPublishedPayoutTxMessage(Messages.PeerPublishedPayoutTxMessage.newBuilder()
|
||||
.setTransaction(ByteString.copyFrom(transaction))
|
||||
.setTradeId(tradeId)
|
||||
.setMyNodeAddress(myNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.bitsquare.arbitration.payload;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -54,4 +56,10 @@ public final class Attachment implements Payload {
|
||||
", data=" + Arrays.toString(bytes) +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Attachment toProtoBuf() {
|
||||
return Messages.Attachment.newBuilder().setBytes(ByteString.copyFrom(bytes))
|
||||
.setFileName(fileName).build();
|
||||
}
|
||||
}
|
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.btc.data;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -65,4 +67,11 @@ public final class RawTransactionInput implements Payload {
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.RawTransactionInput toProtoBuf() {
|
||||
return Messages.RawTransactionInput.newBuilder().setIndex(index)
|
||||
.setParentTransaction(ByteString.copyFrom(parentTransaction))
|
||||
.setValue(value).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,11 @@
|
||||
|
||||
package io.bitsquare.dao.compensation;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.payload.LazyProcessedStoragePayload;
|
||||
import io.bitsquare.p2p.storage.payload.PersistedStoragePayload;
|
||||
@ -71,7 +73,7 @@ public final class CompensationRequestPayload implements LazyProcessedStoragePay
|
||||
// used for json
|
||||
private final String p2pStorageSignaturePubKeyAsHex;
|
||||
|
||||
// Signature of the JSON data of this object excluding the signature and feeTxId fields using the standard Bitcoin
|
||||
// Signature of the JSON data of this object excluding the signature and feeTxId fields using the standard Bitcoin
|
||||
// messaging signing format as a base64 encoded string.
|
||||
@JsonExclude
|
||||
public String signature;
|
||||
@ -173,6 +175,30 @@ public final class CompensationRequestPayload implements LazyProcessedStoragePay
|
||||
return uid.substring(0, 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setCompensationRequestPayload(
|
||||
Messages.CompensationRequestPayload.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.setVersion(version)
|
||||
.setCreationDate(creationDate)
|
||||
.setUid(uid)
|
||||
.setName(name)
|
||||
.setTitle(title)
|
||||
.setCategory(category)
|
||||
.setDescription(description)
|
||||
.setLink(link)
|
||||
.setStartDate(startDate)
|
||||
.setEndDate(endDate)
|
||||
.setRequestedBtc(requestedBtc)
|
||||
.setBtcAddress(btcAddress)
|
||||
.setNodeAddress(nodeAddress)
|
||||
.setP2PStorageSignaturePubKeyAsHex(p2pStorageSignaturePubKeyAsHex)
|
||||
.setSignature(signature)
|
||||
.setFeeTxId(feeTxId)).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package io.bitsquare.filter;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -32,7 +34,9 @@ import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class Filter implements StoragePayload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -93,6 +97,21 @@ public final class Filter implements StoragePayload {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
List<Messages.PaymentAccountFilter> paymentAccountFilterList;
|
||||
paymentAccountFilterList = bannedPaymentAccounts.stream()
|
||||
.map(paymentAccountFilter -> paymentAccountFilter.toProtoBuf()).collect(Collectors.toList());
|
||||
return Messages.StoragePayload.newBuilder().setFilter(Messages.Filter.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.addAllBannedNodeAddress(bannedNodeAddress)
|
||||
.addAllBannedOfferIds(bannedOfferIds)
|
||||
.addAllBannedPaymentAccounts(paymentAccountFilterList)
|
||||
.setSignatureAsBase64(signatureAsBase64)
|
||||
.setPublicKeyBytes(ByteString.copyFrom(publicKeyBytes))).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.bitsquare.filter;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -29,4 +30,11 @@ public class PaymentAccountFilter implements Serializable {
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Messages.PaymentAccountFilter toProtoBuf() {
|
||||
return Messages.PaymentAccountFilter.newBuilder()
|
||||
.setPaymentMethodId(paymentMethodId)
|
||||
.setGetMethodName(getMethodName)
|
||||
.setValue(value).build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class AliPayAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -47,6 +48,19 @@ public final class AliPayAccountContractData extends PaymentAccountContractData
|
||||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.AliPayAccountContractData.Builder thisClass =
|
||||
Messages.AliPayAccountContractData.newBuilder().setAccountNr(accountNr);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setAliPayAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AliPayAccountContractData{" +
|
||||
|
@ -18,8 +18,10 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.locale.BankUtil;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -74,6 +76,31 @@ public class CashDepositAccountContractData extends CountryBasedPaymentAccountCo
|
||||
"Country of bank: " + CountryUtil.getNameAndCode(getCountryCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.CashDepositAccountContractData.Builder cashDepositAccountContractData =
|
||||
Messages.CashDepositAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setHolderEmail(holderEmail)
|
||||
.setBankName(bankName)
|
||||
.setBankId(bankId)
|
||||
.setBranchId(branchId)
|
||||
.setAccountNr(accountNr)
|
||||
.setRequirements(requirements)
|
||||
.setHolderTaxId(holderTaxId);
|
||||
Messages.CountryBasedPaymentAccountContractData.Builder countryBasedPaymentAccountContractData =
|
||||
Messages.CountryBasedPaymentAccountContractData.newBuilder()
|
||||
.setCountryCode(countryCode)
|
||||
.setCashDepositAccountContractData(cashDepositAccountContractData);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCountryBasedPaymentAccountContractData(countryBasedPaymentAccountContractData);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
|
||||
|
||||
protected String getHolderIdLabel() {
|
||||
return BankUtil.getHolderIdLabel(countryCode);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class ChaseQuickPayAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -56,4 +57,19 @@ public final class ChaseQuickPayAccountContractData extends PaymentAccountContra
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Email: " + email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.ChaseQuickPayAccountContractData.Builder chaseQuickPayAccountContractData =
|
||||
Messages.ChaseQuickPayAccountContractData.newBuilder()
|
||||
.setEmail(email)
|
||||
.setHolderName(holderName);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setChaseQuickPayAccountContractData(chaseQuickPayAccountContractData);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class ClearXchangeAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -56,4 +57,19 @@ public final class ClearXchangeAccountContractData extends PaymentAccountContrac
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Email or mobile no.: " + emailOrMobileNr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.ClearXchangeAccountContractData.Builder thisClass =
|
||||
Messages.ClearXchangeAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setEmailOrMobileNr(emailOrMobileNr);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setClearXchangeAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class CryptoCurrencyAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -51,4 +52,17 @@ public final class CryptoCurrencyAccountContractData extends PaymentAccountContr
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.CryptoCurrencyAccountContractData.Builder cryptoCurrencyAccountContractData =
|
||||
Messages.CryptoCurrencyAccountContractData.newBuilder().setAddress(address);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCryptoCurrencyAccountContractData(cryptoCurrencyAccountContractData);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class FasterPaymentsAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -63,4 +64,19 @@ public final class FasterPaymentsAccountContractData extends PaymentAccountContr
|
||||
return "UK Sort code: " + sortCode + "\n" +
|
||||
"Account number: " + accountNr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.FasterPaymentsAccountContractData.Builder thisClass =
|
||||
Messages.FasterPaymentsAccountContractData.newBuilder()
|
||||
.setSortCode(sortCode)
|
||||
.setAccountNr(accountNr);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setFasterPaymentsAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class InteracETransferAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -85,4 +86,21 @@ public final class InteracETransferAccountContractData extends PaymentAccountCon
|
||||
"Secret question: " + question + "\n" +
|
||||
"Answer: " + answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.InteracETransferAccountContractData.Builder interacETransferAccountContractData =
|
||||
Messages.InteracETransferAccountContractData.newBuilder()
|
||||
.setEmail(email)
|
||||
.setHolderName(holderName)
|
||||
.setQuestion(question)
|
||||
.setAnswer(answer);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setInteracETransferAccountContractData(interacETransferAccountContractData);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -35,4 +36,31 @@ public final class NationalBankAccountContractData extends BankAccountContractDa
|
||||
public String getPaymentDetails() {
|
||||
return "National Bank transfer - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.NationalBankAccountContractData.Builder thisClass =
|
||||
Messages.NationalBankAccountContractData.newBuilder();
|
||||
Messages.BankAccountContractData.Builder bankAccountContractData =
|
||||
Messages.BankAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setBankName(bankName)
|
||||
.setBankId(bankId)
|
||||
.setBranchId(branchId)
|
||||
.setAccountNr(accountNr)
|
||||
.setAccountType(accountType)
|
||||
.setHolderTaxId(holderTaxId)
|
||||
.setNationalBankAccountContractData(thisClass);
|
||||
Messages.CountryBasedPaymentAccountContractData.Builder countryBasedPaymentAccountContractData =
|
||||
Messages.CountryBasedPaymentAccountContractData.newBuilder()
|
||||
.setCountryCode(countryCode)
|
||||
.setBankAccountContractData(bankAccountContractData);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCountryBasedPaymentAccountContractData(countryBasedPaymentAccountContractData);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class OKPayAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -51,4 +52,17 @@ public final class OKPayAccountContractData extends PaymentAccountContractData {
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.OKPayAccountContractData.Builder thisClass =
|
||||
Messages.OKPayAccountContractData.newBuilder().setAccountNr(accountNr);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setOKPayAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public abstract class PaymentAccountContractData implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -59,6 +60,8 @@ public abstract class PaymentAccountContractData implements Payload {
|
||||
return maxTradePeriod;
|
||||
}
|
||||
|
||||
abstract public Messages.PaymentAccountContractData toProtoBuf();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class PerfectMoneyAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -52,4 +53,16 @@ public final class PerfectMoneyAccountContractData extends PaymentAccountContrac
|
||||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.PerfectMoneyAccountContractData.Builder thisClass =
|
||||
Messages.PerfectMoneyAccountContractData.newBuilder().setAccountNr(accountNr);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setPerfectMoneyAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -36,4 +38,32 @@ public final class SameBankAccountContractData extends BankAccountContractData {
|
||||
public String getPaymentDetails() {
|
||||
return "Transfer with same Bank - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.SameBankAccountContractData sameBankAccountContractData =
|
||||
Messages.SameBankAccountContractData.getDefaultInstance();
|
||||
Messages.BankAccountContractData.Builder bankAccountContractData =
|
||||
Messages.BankAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setBankName(bankName)
|
||||
.setBankId(bankId)
|
||||
.setBranchId(branchId)
|
||||
.setAccountNr(accountNr)
|
||||
.setAccountType(accountType)
|
||||
.setHolderTaxId(holderTaxId)
|
||||
.setSameBankAccontContractData(sameBankAccountContractData);
|
||||
Messages.CountryBasedPaymentAccountContractData.Builder countryBasedPaymentAccountContractData =
|
||||
Messages.CountryBasedPaymentAccountContractData.newBuilder()
|
||||
.setCountryCode(countryCode)
|
||||
.setBankAccountContractData(bankAccountContractData);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCountryBasedPaymentAccountContractData(countryBasedPaymentAccountContractData);
|
||||
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.locale.CountryUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -97,4 +98,26 @@ public final class SepaAccountContractData extends CountryBasedPaymentAccountCon
|
||||
"BIC: " + bic + "\n" +
|
||||
"Country of bank: " + CountryUtil.getNameAndCode(getCountryCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.SepaAccountContractData.Builder sepaAccountContractData =
|
||||
Messages.SepaAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setIban(iban)
|
||||
.setBic(bic)
|
||||
.addAllAcceptedCountryCodes(acceptedCountryCodes);
|
||||
Messages.CountryBasedPaymentAccountContractData.Builder countryBasedPaymentAccountContractData =
|
||||
Messages.CountryBasedPaymentAccountContractData.newBuilder()
|
||||
.setCountryCode(countryCode)
|
||||
.setSepaAccountContractData(sepaAccountContractData);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCountryBasedPaymentAccountContractData(countryBasedPaymentAccountContractData);
|
||||
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package io.bitsquare.payment;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -63,4 +64,32 @@ public final class SpecificBanksAccountContractData extends BankAccountContractD
|
||||
return super.getPaymentDetailsForTradePopup() + "\n" +
|
||||
"Accepted banks: " + Joiner.on(", ").join(acceptedBanks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.SpecificBanksAccountContractData.Builder specificBanksAccountContractData =
|
||||
Messages.SpecificBanksAccountContractData.newBuilder().addAllAcceptedBanks(acceptedBanks);
|
||||
Messages.BankAccountContractData.Builder bankAccountContractData =
|
||||
Messages.BankAccountContractData.newBuilder()
|
||||
.setHolderName(holderName)
|
||||
.setBankName(bankName)
|
||||
.setBankId(bankId)
|
||||
.setBranchId(branchId)
|
||||
.setAccountNr(accountNr)
|
||||
.setAccountType(accountType)
|
||||
.setHolderTaxId(holderTaxId)
|
||||
.setSpecificBanksAccountContractData(specificBanksAccountContractData);
|
||||
Messages.CountryBasedPaymentAccountContractData.Builder countryBasedPaymentAccountContractData =
|
||||
Messages.CountryBasedPaymentAccountContractData.newBuilder()
|
||||
.setCountryCode(countryCode)
|
||||
.setBankAccountContractData(bankAccountContractData);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setCountryBasedPaymentAccountContractData(countryBasedPaymentAccountContractData);
|
||||
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class SwishAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -63,4 +64,19 @@ public final class SwishAccountContractData extends PaymentAccountContractData {
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Mobile no.: " + mobileNr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.SwishAccountContractData.Builder thisClass =
|
||||
Messages.SwishAccountContractData.newBuilder()
|
||||
.setMobileNr(mobileNr)
|
||||
.setHolderName(holderName);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setSwishAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
public final class USPostalMoneyOrderAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -65,4 +66,19 @@ public final class USPostalMoneyOrderAccountContractData extends PaymentAccountC
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Postal address: " + postalAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.PaymentAccountContractData toProtoBuf() {
|
||||
Messages.USPostalMoneyOrderAccountContractData.Builder thisClass =
|
||||
Messages.USPostalMoneyOrderAccountContractData.newBuilder()
|
||||
.setPostalAddress(postalAddress)
|
||||
.setHolderName(holderName);
|
||||
Messages.PaymentAccountContractData.Builder paymentAccountContractData =
|
||||
Messages.PaymentAccountContractData.newBuilder()
|
||||
.setId(id)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setUSPostalMoneyOrderAccountContractData(thisClass);
|
||||
return paymentAccountContractData.build();
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,12 @@
|
||||
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import io.bitsquare.trade.offer.Offer;
|
||||
@ -257,4 +259,23 @@ public final class Contract implements Payload {
|
||||
"\n\ttakerBtcPubKey=" + Arrays.toString(takerBtcPubKey) +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Contract toProtoBuf() {
|
||||
return Messages.Contract.newBuilder()
|
||||
.setOffer(offer.toProtoBuf().getOffer())
|
||||
.setTradeAmount(tradeAmount)
|
||||
.setTradePrice(tradePrice)
|
||||
.setTakeOfferFeeTxId(takeOfferFeeTxID)
|
||||
.setArbitratorNodeAddress(arbitratorNodeAddress.toProtoBuf())
|
||||
.setTakerPaymentAccountContractData((Messages.PaymentAccountContractData) takerPaymentAccountContractData.toProtoBuf())
|
||||
.setOffererPubKeyRing(offererPubKeyRing.toProtoBuf())
|
||||
.setTakerPubKeyRing(takerPubKeyRing.toProtoBuf())
|
||||
.setBuyerNodeAddress(buyerNodeAddress.toProtoBuf())
|
||||
.setSellerNodeAddress(sellerNodeAddress.toProtoBuf())
|
||||
.setOffererPayoutAddressstring(offererPayoutAddressString)
|
||||
.setTakerPayoutAddressstring(takerPayoutAddressString)
|
||||
.setOffererBtcPubKey(ByteString.copyFrom(offererBtcPubKey))
|
||||
.setTakerBtcPubKey(ByteString.copyFrom(takerBtcPubKey)).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.bitsquare.trade.offer;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.DevFlags;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.Restrictions;
|
||||
@ -28,6 +29,7 @@ import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.common.util.MathUtils;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
||||
@ -53,6 +55,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -124,11 +127,11 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
||||
//TODO add support for altcoin price or fix precision issue
|
||||
private final long fiatPrice;
|
||||
|
||||
// Distance form market price if percentage based price is used (usePercentageBasedPrice = true), otherwise 0.
|
||||
// Distance form market price if percentage based price is used (usePercentageBasedPrice = true), otherwise 0.
|
||||
// E.g. 0.1 -> 10%. Can be negative as well. Depending on direction the marketPriceMargin is above or below the market price.
|
||||
// Positive values is always the usual case where you want a better price as the market.
|
||||
// E.g. Buy offer with market price 400.- leads to a 360.- price.
|
||||
// Sell offer with market price 400.- leads to a 440.- price.
|
||||
// Positive values is always the usual case where you want a better price as the market.
|
||||
// E.g. Buy offer with market price 400.- leads to a 360.- price.
|
||||
// Sell offer with market price 400.- leads to a 440.- price.
|
||||
private final double marketPriceMargin;
|
||||
|
||||
private final long amount;
|
||||
@ -165,7 +168,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
||||
|
||||
@JsonExclude
|
||||
transient private State state = State.UNDEFINED;
|
||||
// Those state properties are transient and only used at runtime!
|
||||
// Those state properties are transient and only used at runtime!
|
||||
// don't access directly as it might be null; use getStateProperty() which creates an object if not instantiated
|
||||
@JsonExclude
|
||||
transient private ObjectProperty<State> stateProperty = new SimpleObjectProperty<>(state);
|
||||
@ -476,7 +479,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
||||
double factor = (double) takersTradePrice / (double) offerPriceAsFiat.value;
|
||||
// We allow max. 2 % difference between own offer price calculation and takers calculation.
|
||||
// Market price might be different at offerer's and takers side so we need a bit of tolerance.
|
||||
// The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations
|
||||
// The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations
|
||||
// from one provider.
|
||||
if (Math.abs(1 - factor) > 0.02) {
|
||||
String msg = "Taker's trade price is too far away from our calculated price based on the market price.\n" +
|
||||
@ -625,6 +628,48 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
||||
return extraDataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setOffer(Messages.Offer.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.setDirectionValue(direction.ordinal())
|
||||
.setCurrencyCode(currencyCode)
|
||||
.setPaymentMethodName(paymentMethodName)
|
||||
.setCountryCode(countryCode)
|
||||
.addAllAcceptedCountryCodes(acceptedCountryCodes)
|
||||
.setBankId(bankId)
|
||||
.addAllAcceptedBankIds(getAcceptedBankIds())
|
||||
.addAllArbitratorNodeAddresses(arbitratorNodeAddresses.stream()
|
||||
.map(nodeAddress -> nodeAddress.toProtoBuf()).collect(Collectors.toList()))
|
||||
.setId(id)
|
||||
.setDate(date)
|
||||
.setProtocolVersion(protocolVersion)
|
||||
.setUseMarketBasedPrice(useMarketBasedPrice)
|
||||
.setFiatPrice(fiatPrice)
|
||||
.setMarketPriceMargin(marketPriceMargin)
|
||||
.setAmount(amount)
|
||||
.setMinAmount(minAmount)
|
||||
.setOffererNodeAddress(offererNodeAddress.toProtoBuf())
|
||||
.setPubKeyRing(pubKeyRing.toProtoBuf())
|
||||
.setOffererPaymentAccountId(offererPaymentAccountId)
|
||||
.setOfferFeePaymentTxID(offerFeePaymentTxID)
|
||||
.setVersionNr(versionNr)
|
||||
.setBlockHeightAtOfferCreation(blockHeightAtOfferCreation)
|
||||
.setTxFee(txFee)
|
||||
.setCreateOfferFee(createOfferFee)
|
||||
.setSecurityDeposit(securityDeposit)
|
||||
.setMaxTradeLimit(maxTradeLimit)
|
||||
.setMaxTradePeriod(maxTradePeriod)
|
||||
.setUseAutoClose(useAutoClose)
|
||||
.setUseReOpenAfterAutoClose(useReOpenAfterAutoClose)
|
||||
.setLowerClosePrice(lowerClosePrice)
|
||||
.setUpperClosePrice(upperClosePrice)
|
||||
.setIsPrivateOffer(isPrivateOffer)
|
||||
.setHashOfChallenge(hashOfChallenge)
|
||||
.putAllExtraDataMap(extraDataMap)).build();
|
||||
}
|
||||
|
||||
|
||||
//TODO update with new properties
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package io.bitsquare.trade.protocol.availability;
|
||||
|
||||
public enum AvailabilityResult {
|
||||
UNKNOWN_FAILURE,
|
||||
AVAILABLE,
|
||||
OFFER_TAKEN,
|
||||
PRICE_OUT_OF_TOLERANCE,
|
||||
MARKET_PRICE_NOT_AVAILABLE,
|
||||
NO_ARBITRATORS,
|
||||
USER_IGNORED,
|
||||
UNKNOWN_FAILURE
|
||||
USER_IGNORED
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package io.bitsquare.trade.protocol.availability.messages;
|
||||
import io.bitsquare.app.Capabilities;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.messaging.SupportedCapabilitiesMessage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -58,4 +59,9 @@ public final class OfferAvailabilityRequest extends OfferMessage implements Supp
|
||||
"pubKeyRing=" + pubKeyRing +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import io.bitsquare.app.Capabilities;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferMessage;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.SupportedCapabilitiesMessage;
|
||||
import io.bitsquare.trade.protocol.availability.AvailabilityResult;
|
||||
|
||||
@ -59,4 +60,13 @@ public final class OfferAvailabilityResponse extends OfferMessage implements Sup
|
||||
"availabilityResult=" + availabilityResult +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setOfferAvailabilityResponse(Messages.OfferAvailabilityResponse.newBuilder().setMessageVersion(getMessageVersion())
|
||||
.setOfferId(offerId)
|
||||
.setAvailabilityResult(Messages.AvailabilityResult.forNumber(availabilityResult.ordinal()))
|
||||
.addAllSupportedCapabilities(supportedCapabilities)).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@ -78,4 +81,15 @@ public final class DepositTxPublishedMessage extends TradeMessage implements Mai
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setDepositTxPublishedMessage(Messages.DepositTxPublishedMessage.newBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
.setTradeId(tradeId)
|
||||
.setDepositTx(ByteString.copyFrom(depositTx))
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setUid(uid)).build();
|
||||
}
|
||||
}
|
||||
|
@ -18,14 +18,16 @@
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.UUID;
|
||||
|
||||
@Immutable
|
||||
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
||||
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
@ -88,4 +90,15 @@ import java.util.UUID;
|
||||
", uid='" + uid + '\'' +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setFiatTransferStartedMessage(baseEnvelope.getFiatTransferStartedMessageBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
.setTradeId(tradeId)
|
||||
.setBuyerPayoutAddress(buyerPayoutAddress)
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setUid(uid)).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@ -97,4 +100,17 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setFinalizePayoutTxRequest(Messages.FinalizePayoutTxRequest.newBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
.setTradeId(tradeId)
|
||||
.setSellerSignature(ByteString.copyFrom(sellerSignature))
|
||||
.setSellerPayoutAddress(sellerPayoutAddress)
|
||||
.setLockTimeAsBlockHeight(lockTimeAsBlockHeight)
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setUid(uid)).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,13 @@
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import org.bitcoinj.core.Coin;
|
||||
@ -29,6 +32,7 @@ import javax.annotation.concurrent.Immutable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Immutable
|
||||
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
|
||||
@ -154,4 +158,28 @@ public final class PayDepositRequest extends TradeMessage implements MailboxMess
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPayDepositRequest(Messages.PayDepositRequest.newBuilder()
|
||||
.setTradeId(tradeId)
|
||||
.setTradeAmount(tradeAmount)
|
||||
.setTradePrice(tradePrice)
|
||||
.setTakerMultiSigPubKey(ByteString.copyFrom(takerMultiSigPubKey))
|
||||
.setTxFee(Messages.Coin.newBuilder().setValue(txFee.getValue()))
|
||||
.setTakeOfferFee(Messages.Coin.newBuilder().setValue(takeOfferFee.getValue()))
|
||||
.addAllRawTransactionInputs(rawTransactionInputs.stream().map(rawTransactionInput -> rawTransactionInput.toProtoBuf()).collect(Collectors.toList()))
|
||||
.setChangeOutputValue(changeOutputValue)
|
||||
.setChangeOutputAddress(changeOutputAddress)
|
||||
.setTakerPayoutAddressString(takerPayoutAddressString)
|
||||
.setTakerPubKeyRing(takerPubKeyRing.toProtoBuf())
|
||||
.setTakerPaymentAccountContractData(takerPaymentAccountContractData.toProtoBuf())
|
||||
.setTakerAccountId(takerAccountId)
|
||||
.setTakeOfferFeeTxId(takeOfferFeeTxId)
|
||||
.addAllAcceptedArbitratorNodeAddresses(acceptedArbitratorNodeAddresses.stream().map(nodeAddress -> nodeAddress.toProtoBuf()).collect(Collectors.toList()))
|
||||
.setArbitratorNodeAddress(arbitratorNodeAddress.toProtoBuf())
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setUid(uid)).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
@ -78,4 +81,15 @@ public final class PayoutTxFinalizedMessage extends TradeMessage implements Mail
|
||||
result = 31 * result + (uid != null ? uid.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPayoutTxFinalizedMessage(baseEnvelope.getPayoutTxFinalizedMessageBuilder()
|
||||
.setUid(uid)
|
||||
.setMessageVersion(getMessageVersion())
|
||||
.setTradeId(tradeId)
|
||||
.setPayoutTx(ByteString.copyFrom(payoutTx))
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,19 @@
|
||||
|
||||
package io.bitsquare.trade.protocol.trade.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.data.RawTransactionInput;
|
||||
import io.bitsquare.common.util.Utilities;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Immutable
|
||||
|
||||
@ -69,4 +73,19 @@ public final class PublishDepositTxRequest extends TradeMessage {
|
||||
log.trace("preparedDepositTx size " + preparedDepositTx.length);
|
||||
log.trace("offererInputs size " + Utilities.serialize(new ArrayList<>(offererInputs)).length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPublishDepositTxRequest(baseEnvelope.getPublishDepositTxRequestBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
.setTradeId(tradeId)
|
||||
.setOffererPaymentAccountContractData(offererPaymentAccountContractData.toProtoBuf())
|
||||
.setOffererAccountId(offererAccountId)
|
||||
.setOffererContractAsJson(offererContractAsJson)
|
||||
.setOffererContractSignature(offererContractSignature)
|
||||
.setOffererPayoutAddressstring(offererPayoutAddressString)
|
||||
.setPreparedDepositTx(ByteString.copyFrom(preparedDepositTx))
|
||||
.addAllOffererInputs(offererInputs.stream().map(rawTransactionInput -> rawTransactionInput.toProtoBuf()).collect(Collectors.toList()))).build();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.bitsquare.trade.statistics;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Capabilities;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.storage.payload.CapabilityRequiringPayload;
|
||||
import io.bitsquare.p2p.storage.payload.LazyProcessedStoragePayload;
|
||||
import io.bitsquare.p2p.storage.payload.PersistedStoragePayload;
|
||||
@ -101,7 +103,28 @@ public final class TradeStatistics implements LazyProcessedStoragePayload, Capab
|
||||
return offerId;
|
||||
}
|
||||
|
||||
// We don't include the pubKeyRing as both traders might publish it if the offerer uses an old
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setTradeStatistics(Messages.TradeStatistics.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.setCurrency(currency)
|
||||
.setDirection(Messages.Offer.Direction.forNumber(direction.ordinal()))
|
||||
.setTradePrice(tradePrice)
|
||||
.setTradeAmount(tradeAmount)
|
||||
.setTradeDate(tradeDate)
|
||||
.setPaymentMethod(paymentMethod)
|
||||
.setOfferDate(offerDate)
|
||||
.setUseMarketBasedPrice(useMarketBasedPrice)
|
||||
.setMarketPriceMargin(marketPriceMargin)
|
||||
.setOfferAmount(offerAmount)
|
||||
.setOfferMinAmount(offerMinAmount)
|
||||
.setOfferId(offerId)
|
||||
.setDepositTxId(depositTxId)
|
||||
.setPubKeyRing((Messages.PubKeyRing) pubKeyRing.toProtoBuf())).build();
|
||||
}
|
||||
|
||||
|
||||
// We don't include the pubKeyRing as both traders might publish it if the offerer uses an old
|
||||
// version and update later (taker publishes first, then later offerer)
|
||||
// We also don't include the trade date as that is set locally and different for offerer and taker
|
||||
@Override
|
||||
|
@ -95,3 +95,120 @@ public interface Message extends Serializable {
|
||||
public static final class DataAndSeqNrPair implements Serializable {
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Actually transformed subtypes of Message
|
||||
|
||||
```
|
||||
I Message (io.bitsquare.p2p)
|
||||
I AnonymousMessage (io.bitsquare.p2p.network.messages)
|
||||
+ PreliminaryGetDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
C BroadcastMessage (io.bitsquare.p2p.storage.messages)
|
||||
+ AddDataMessage (io.bitsquare.p2p.storage.messages)
|
||||
+ RefreshTTLMessage (io.bitsquare.p2p.storage.messages)
|
||||
+ RemoveDataMessage (io.bitsquare.p2p.storage.messages)
|
||||
+ RemoveMailboxDataMessage (io.bitsquare.p2p.storage.messages)
|
||||
+ CloseConnectionMessage (io.bitsquare.p2p.network.messages)
|
||||
I DirectMessage (io.bitsquare.p2p.messaging)
|
||||
I MailboxMessage (io.bitsquare.p2p.messaging)
|
||||
+ DepositTxPublishedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
C DisputeMessage (io.bitsquare.arbitration.messages)
|
||||
+ DisputeCommunicationMessage (io.bitsquare.arbitration.messages)
|
||||
+ DisputeResultMessage (io.bitsquare.arbitration.messages)
|
||||
+ OpenNewDisputeMessage (io.bitsquare.arbitration.messages)
|
||||
+ PeerOpenedDisputeMessage (io.bitsquare.arbitration.messages)
|
||||
+ PeerPublishedPayoutTxMessage (io.bitsquare.arbitration.messages)
|
||||
+ FiatTransferStartedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ FinalizePayoutTxRequest (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ MockMailboxPayload (io.bitsquare.p2p.mocks)
|
||||
+ PayDepositRequest (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ PayoutTxFinalizedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ PrefixedSealedAndSignedMessage (io.bitsquare.p2p.messaging)
|
||||
+ PrivateNotificationMessage (io.bitsquare.alert)
|
||||
T StressTestMailboxMessage (io.bitsquare.p2p.network)
|
||||
T TestMessage (io.bitsquare.crypto)
|
||||
C OfferMessage (io.bitsquare.trade.protocol.availability.messages)
|
||||
+ OfferAvailabilityRequest (io.bitsquare.trade.protocol.availability.messages)
|
||||
+ OfferAvailabilityResponse (io.bitsquare.trade.protocol.availability.messages)
|
||||
T StressTestDirectMessage (io.bitsquare.p2p.network)
|
||||
C TradeMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ DepositTxPublishedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
D FiatTransferStartedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
D FinalizePayoutTxRequest (io.bitsquare.trade.protocol.trade.messages)
|
||||
D PayDepositRequest (io.bitsquare.trade.protocol.trade.messages)
|
||||
D PayoutTxFinalizedMessage (io.bitsquare.trade.protocol.trade.messages)
|
||||
+ PublishDepositTxRequest (io.bitsquare.trade.protocol.trade.messages)
|
||||
I GetDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
+ GetUpdatedDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
D PreliminaryGetDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
C KeepAliveMessage (io.bitsquare.p2p.peers.keepalive.messages)
|
||||
+ Ping (io.bitsquare.p2p.peers.keepalive.messages)
|
||||
+ Pong (io.bitsquare.p2p.peers.keepalive.messages)
|
||||
T MockPayload (io.bitsquare.p2p.mocks)
|
||||
C PeerExchangeMessage (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
+ GetPeersRequest (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
+ GetPeersResponse (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
I SendersNodeAddressMessage (io.bitsquare.p2p.network.messages)
|
||||
D GetPeersRequest (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
D GetUpdatedDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
D PrefixedSealedAndSignedMessage (io.bitsquare.p2p.messaging)
|
||||
I SupportedCapabilitiesMessage (io.bitsquare.p2p.messaging)
|
||||
+ GetDataResponse (io.bitsquare.p2p.peers.getdata.messages)
|
||||
D GetPeersRequest (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
D GetPeersResponse (io.bitsquare.p2p.peers.peerexchange.messages)
|
||||
D OfferAvailabilityRequest (io.bitsquare.trade.protocol.availability.messages)
|
||||
D OfferAvailabilityResponse (io.bitsquare.trade.protocol.availability.messages)
|
||||
D PreliminaryGetDataRequest (io.bitsquare.p2p.peers.getdata.messages)
|
||||
```
|
||||
|
||||
== Actually transformed subtypes of Payload
|
||||
|
||||
```
|
||||
+ Attachment (io.bitsquare.arbitration.payload)
|
||||
I CapabilityRequiringPayload (io.bitsquare.p2p.storage.payload)
|
||||
+ TradeStatistics (io.bitsquare.trade.statistics)
|
||||
+ Contract (io.bitsquare.trade)
|
||||
+ Dispute (io.bitsquare.arbitration)
|
||||
+ DisputeResult (io.bitsquare.arbitration)
|
||||
I ExpirablePayload (io.bitsquare.p2p.storage.payload)
|
||||
I StoragePayload (io.bitsquare.p2p.storage.payload)
|
||||
+ Alert (io.bitsquare.alert)
|
||||
+ Arbitrator (io.bitsquare.arbitration)
|
||||
+ Filter (io.bitsquare.filter)
|
||||
I LazyProcessedStoragePayload (io.bitsquare.p2p.storage.payload)
|
||||
+ CompensationRequestPayload (io.bitsquare.dao.compensation)
|
||||
D TradeStatistics (io.bitsquare.trade.statistics)
|
||||
+ MailboxStoragePayload (io.bitsquare.p2p.storage.payload)
|
||||
+ Offer (io.bitsquare.trade.offer)
|
||||
I PersistedStoragePayload (io.bitsquare.p2p.storage.payload)
|
||||
D CompensationRequestPayload (io.bitsquare.dao.compensation)
|
||||
D TradeStatistics (io.bitsquare.trade.statistics)
|
||||
+ NodeAddress (io.bitsquare.p2p)
|
||||
C+PaymentAccountContractData (io.bitsquare.payment)
|
||||
+ AliPayAccountContractData (io.bitsquare.payment)
|
||||
+ ChaseQuickPayAccountContractData (io.bitsquare.payment)
|
||||
+ ClearXchangeAccountContractData (io.bitsquare.payment)
|
||||
C+ CountryBasedPaymentAccountContractData (io.bitsquare.payment)
|
||||
C+ BankAccountContractData (io.bitsquare.payment)
|
||||
+ NationalBankAccountContractData (io.bitsquare.payment)
|
||||
+ SameBankAccountContractData (io.bitsquare.payment)
|
||||
+ SpecificBanksAccountContractData (io.bitsquare.payment)
|
||||
+ CashDepositAccountContractData (io.bitsquare.payment)
|
||||
+ SepaAccountContractData (io.bitsquare.payment)
|
||||
+ CryptoCurrencyAccountContractData (io.bitsquare.payment)
|
||||
+ FasterPaymentsAccountContractData (io.bitsquare.payment)
|
||||
+ InteracETransferAccountContractData (io.bitsquare.payment)
|
||||
+ OKPayAccountContractData (io.bitsquare.payment)
|
||||
+ PerfectMoneyAccountContractData (io.bitsquare.payment)
|
||||
+ SwishAccountContractData (io.bitsquare.payment)
|
||||
+ USPostalMoneyOrderAccountContractData (io.bitsquare.payment)
|
||||
+ Peer (io.bitsquare.p2p.peers.peerexchange)
|
||||
+ PrivateNotification (io.bitsquare.alert)
|
||||
+ ProtectedStorageEntry (io.bitsquare.p2p.storage.storageentry)
|
||||
+ ProtectedMailboxStorageEntry (io.bitsquare.p2p.storage.storageentry)
|
||||
+ PubKeyRing (io.bitsquare.common.crypto)
|
||||
+ RawTransactionInput (io.bitsquare.btc.data)
|
||||
I RequiresOwnerIsOnlinePayload (io.bitsquare.p2p.storage.payload)
|
||||
D Offer (io.bitsquare.trade.offer)
|
||||
+ SealedAndSigned (io.bitsquare.common.crypto)
|
||||
```
|
@ -1,11 +1,16 @@
|
||||
package io.bitsquare.p2p;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface Message extends Serializable {
|
||||
int getMessageVersion();
|
||||
|
||||
//Messages.Envelope toProtoBuf();
|
||||
Messages.Envelope toProtoBuf();
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ public final class NodeAddress implements Persistable, Payload {
|
||||
}
|
||||
|
||||
|
||||
public Messages.NodeAddress toProtoBuf() {
|
||||
return Messages.NodeAddress.newBuilder().setHostName(hostName).setPort(port).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.bitsquare.p2p;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.SealedAndSigned;
|
||||
import io.bitsquare.p2p.messaging.PrefixedSealedAndSignedMessage;
|
||||
import io.bitsquare.p2p.network.messages.CloseConnectionMessage;
|
||||
@ -16,7 +17,9 @@ import io.bitsquare.p2p.peers.peerexchange.messages.GetPeersRequest;
|
||||
import io.bitsquare.p2p.peers.peerexchange.messages.GetPeersResponse;
|
||||
import io.bitsquare.p2p.storage.P2PDataStorage;
|
||||
import io.bitsquare.p2p.storage.messages.RefreshTTLMessage;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -25,15 +28,52 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by mike on 31/01/2017.
|
||||
|
||||
If the Messages class is giving errors in IntelliJ, you should change the IntelliJ IDEA Platform Properties file,
|
||||
idea.properties, to something bigger like 12500:
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Maximum file size (kilobytes) IDE should provide code assistance for.
|
||||
# The larger file is the slower its editor works and higher overall system memory requirements are
|
||||
# if code assistance is enabled. Remove this property or set to very large number if you need
|
||||
# code assistance for any files available regardless their size.
|
||||
#---------------------------------------------------------------------
|
||||
idea.max.intellisense.filesize=2500
|
||||
|
||||
*/
|
||||
@Slf4j
|
||||
public class ProtoBufferUtilities {
|
||||
|
||||
public static boolean isPrefixedSealedAndSignedMessage(Messages.Envelope envelope) {
|
||||
return !Messages.PrefixedSealedAndSignedMessage.getDefaultInstance()
|
||||
.equals(envelope.getPrefixedSealedAndSignedMessage());
|
||||
|
||||
|
||||
public static Optional<Message> fromProtoBuf(Messages.Envelope envelope) {
|
||||
Message result = null;
|
||||
switch(envelope.getMessageCase()) {
|
||||
case PING:
|
||||
result = new Ping(envelope.getPing().getNonce(), envelope.getPing().getLastRoundTripTime());
|
||||
break;
|
||||
case PONG:
|
||||
break;
|
||||
case REFRESH_TTL_MESSAGE: break;
|
||||
case GET_DATA_RESPONSE: break;
|
||||
case CLOSE_CONNECTION_MESSAGE: break;
|
||||
case PREFIXED_SEALED_AND_SIGNED_MESSAGE: break;
|
||||
case GET_UPDATED_DATA_REQUEST: break;
|
||||
case PRELIMINARY_GET_DATA_REQUEST: break;
|
||||
case GET_PEERS_REQUEST: break;
|
||||
case GET_PEERS_RESPONSE: break;
|
||||
default: log.warn("Unknown message case:{}", envelope.getMessageCase());
|
||||
}
|
||||
return Optional.ofNullable(result);
|
||||
}
|
||||
|
||||
|
||||
public static Messages.Envelope.Builder getBaseEnvelope() {
|
||||
return Messages.Envelope.newBuilder().setP2PNetworkVersion(Version.P2P_NETWORK_VERSION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static PrefixedSealedAndSignedMessage createPrefixedSealedAndSignedMessage(Messages.Envelope envelope) {
|
||||
Messages.PrefixedSealedAndSignedMessage msg = envelope.getPrefixedSealedAndSignedMessage();
|
||||
NodeAddress nodeAddress = new NodeAddress(msg.getNodeAddress().getHostName(), msg.getNodeAddress().getPort());
|
||||
@ -43,15 +83,6 @@ public class ProtoBufferUtilities {
|
||||
return new PrefixedSealedAndSignedMessage(nodeAddress, sealedAndSigned, msg.getAddressPrefixHash().toByteArray());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSendersNodeAddressMessage(Messages.Envelope envelope) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGetDataResponse(Messages.Envelope envelope) {
|
||||
return !Messages.GetDataResponse.getDefaultInstance().equals(envelope.getGetDataResponse());
|
||||
}
|
||||
|
||||
// TODO protectedstorageentry is NULL
|
||||
public static GetDataResponse createGetDataResponse(Messages.Envelope envelope) {
|
||||
HashSet<ProtectedStorageEntry> set =new HashSet<ProtectedStorageEntry>(
|
||||
@ -63,24 +94,6 @@ public class ProtoBufferUtilities {
|
||||
}
|
||||
|
||||
|
||||
// This is an interface, maybe not needed
|
||||
public static boolean isGetDataRequest(Messages.Envelope envelope) {
|
||||
return isGetUpdatedDataRequest(envelope) || isPreliminaryGetDataRequest(envelope);
|
||||
}
|
||||
|
||||
public static boolean isPreliminaryGetDataRequest(Messages.Envelope envelope) {
|
||||
return !Messages.PreliminaryGetDataRequest.getDefaultInstance().equals(envelope.getPreliminaryGetDataRequest());
|
||||
}
|
||||
|
||||
private static PreliminaryGetDataRequest createPreliminaryGetDataRequest(Messages.Envelope envelope) {
|
||||
return new PreliminaryGetDataRequest(envelope.getPreliminaryGetDataRequest().getNonce(),
|
||||
getByteSet(envelope.getPreliminaryGetDataRequest().getExcludedKeysList()));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isGetUpdatedDataRequest(Messages.Envelope envelope) {
|
||||
return !Messages.GetUpdatedDataRequest.getDefaultInstance().equals(envelope.getGetUpdatedDataRequest());
|
||||
}
|
||||
|
||||
private static GetUpdatedDataRequest createGetUpdatedDataRequest(Messages.Envelope envelope) {
|
||||
Messages.GetUpdatedDataRequest msg = envelope.getGetUpdatedDataRequest();
|
||||
@ -89,10 +102,6 @@ public class ProtoBufferUtilities {
|
||||
return new GetUpdatedDataRequest(nodeAddress, msg.getNonce(), set);
|
||||
}
|
||||
|
||||
public static boolean isGetPeersRequest(Messages.Envelope envelope) {
|
||||
return !Messages.GetPeersRequest.getDefaultInstance().equals(envelope.getGetPeersRequest());
|
||||
}
|
||||
|
||||
private static GetPeersRequest createGetPeersRequest(Messages.Envelope envelope) {
|
||||
Messages.GetPeersRequest msg = envelope.getGetPeersRequest();
|
||||
NodeAddress nodeAddress = new NodeAddress(msg.getSenderNodeAddress().getHostName(), msg.getSenderNodeAddress().getPort());
|
||||
@ -105,10 +114,6 @@ public class ProtoBufferUtilities {
|
||||
return new GetPeersRequest(nodeAddress, msg.getNonce(), set);
|
||||
}
|
||||
|
||||
public static boolean isGetPeersResponse(Messages.Envelope envelope) {
|
||||
return !Messages.GetPeersResponse.getDefaultInstance().equals(envelope.getGetPeersResponse());
|
||||
}
|
||||
|
||||
private static GetPeersResponse createGetPeersResponse(Messages.Envelope envelope) {
|
||||
Messages.GetPeersResponse msg = envelope.getGetPeersResponse();
|
||||
HashSet<Peer> set =new HashSet<>(
|
||||
@ -120,26 +125,14 @@ public class ProtoBufferUtilities {
|
||||
return new GetPeersResponse(msg.getRequestNonce(), set);
|
||||
}
|
||||
|
||||
public static boolean isPing(Messages.Envelope envelope) {
|
||||
return !Messages.Ping.getDefaultInstance().equals(envelope.getPing());
|
||||
}
|
||||
|
||||
public static Ping createPing(Messages.Envelope envelope) {
|
||||
return new Ping(envelope.getPing().getNonce(), envelope.getPing().getLastRoundTripTime());
|
||||
}
|
||||
|
||||
public static boolean isPong(Messages.Envelope envelope) {
|
||||
return !Messages.Pong.getDefaultInstance().equals(envelope.getPong());
|
||||
}
|
||||
|
||||
public static Pong createPong(Messages.Envelope envelope) {
|
||||
return new Pong(envelope.getPong().getRequestNonce());
|
||||
}
|
||||
|
||||
public static boolean isRefreshTTLMessage(Messages.Envelope envelope) {
|
||||
return !Messages.RefreshTTLMessage.getDefaultInstance().equals(envelope.getRefreshTtlMessage());
|
||||
}
|
||||
|
||||
public static RefreshTTLMessage createRefreshTTLMessage(Messages.Envelope envelope) {
|
||||
Messages.RefreshTTLMessage msg = envelope.getRefreshTtlMessage();
|
||||
return new RefreshTTLMessage(msg.getHashOfDataAndSeqNr().toByteArray(),
|
||||
@ -147,10 +140,6 @@ public class ProtoBufferUtilities {
|
||||
msg.getHashOfPayload().toByteArray(), msg.getSequenceNumber());
|
||||
}
|
||||
|
||||
public static boolean isCloseConnectionMessage(Messages.Envelope envelope) {
|
||||
return !Messages.CloseConnectionMessage.getDefaultInstance().equals(envelope.getCloseConnectionMessage());
|
||||
}
|
||||
|
||||
public static CloseConnectionMessage createCloseConnectionMessage(Messages.Envelope envelope) {
|
||||
return new CloseConnectionMessage(envelope.getCloseConnectionMessage().getReason());
|
||||
}
|
||||
@ -162,41 +151,16 @@ public class ProtoBufferUtilities {
|
||||
.map(ByteString::toByteArray).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static Optional<Message> fromProtoBuf(Messages.Envelope envelope) {
|
||||
if (isPing(envelope)) {
|
||||
return Optional.of(createPing(envelope));
|
||||
} else if (isPong(envelope)) {
|
||||
return Optional.of(createPong(envelope));
|
||||
} else if (isGetDataResponse(envelope)) {
|
||||
return Optional.of(createGetDataResponse(envelope));
|
||||
} else if (isRefreshTTLMessage(envelope)) {
|
||||
return Optional.of(createRefreshTTLMessage(envelope));
|
||||
} else if (isCloseConnectionMessage(envelope)) {
|
||||
return Optional.of(createCloseConnectionMessage(envelope));
|
||||
} else if (isPrefixedSealedAndSignedMessage(envelope)) {
|
||||
return Optional.of(createPrefixedSealedAndSignedMessage(envelope));
|
||||
} else if (isGetUpdatedDataRequest(envelope)) {
|
||||
return Optional.of(createGetUpdatedDataRequest(envelope));
|
||||
} else if (isPreliminaryGetDataRequest(envelope)) {
|
||||
return Optional.of(createPreliminaryGetDataRequest(envelope));
|
||||
} else if (isGetPeersRequest(envelope)) {
|
||||
return Optional.of(createGetPeersRequest(envelope));
|
||||
} else if (isGetPeersResponse(envelope)) {
|
||||
return Optional.of(createGetPeersResponse(envelope));
|
||||
/*
|
||||
public static Messages.StoragePayload convertToStoragePayload(StoragePayload storagePayload) {
|
||||
Messages.StoragePayload.Builder builder = Messages.StoragePayload.newBuilder();
|
||||
switch(storagePayload.getClass().getSimpleName()) {
|
||||
case "Alert": builder.setAlert((Alert)storagePayload);
|
||||
|
||||
}
|
||||
//envelope.
|
||||
/*
|
||||
else if (isPong(envelope)) {
|
||||
return Optional.of(createPong(envelope));
|
||||
} else if (isPong(envelope)) {
|
||||
return Optional.of(createPong(envelope));
|
||||
} else if (isPong(envelope)) {
|
||||
return Optional.of(createPong(envelope));
|
||||
}
|
||||
*/
|
||||
return Optional.empty();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.bitsquare.p2p.messaging;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.SealedAndSigned;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.network.messages.SendersNodeAddressMessage;
|
||||
|
||||
@ -48,6 +50,16 @@ public final class PrefixedSealedAndSignedMessage implements MailboxMessage, Sen
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
return Messages.Envelope.newBuilder().setPrefixedSealedAndSignedMessage(
|
||||
Messages.PrefixedSealedAndSignedMessage.newBuilder()
|
||||
.setMessageVersion(messageVersion).setNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setSealedAndSigned(sealedAndSigned.toProtoBuf())
|
||||
.setAddressPrefixHash(ByteString.copyFrom(addressPrefixHash))
|
||||
.setUid(uid)).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PrefixedSealedAndSignedMessage{" +
|
||||
|
@ -896,11 +896,11 @@ public class Connection implements MessageListener {
|
||||
}
|
||||
} else if (!stopped) {
|
||||
// We don't want to get the activity ts updated by ping/pong msg
|
||||
if (!(isPing(envelope) || isPong(envelope))) {
|
||||
if (!(message instanceof KeepAliveMessage)) {
|
||||
connection.statistic.updateLastActivityTimestamp();
|
||||
}
|
||||
|
||||
if (isGetDataRequest(envelope)) {
|
||||
if (message instanceof GetDataRequest) {
|
||||
connection.setPeerType(PeerType.INITIAL_DATA_REQUEST);
|
||||
}
|
||||
// First a seed node gets a message from a peer (PreliminaryDataRequest using
|
||||
@ -933,7 +933,7 @@ public class Connection implements MessageListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (isPrefixedSealedAndSignedMessage(envelope))
|
||||
if (message instanceof PrefixedSealedAndSignedMessage)
|
||||
connection.setPeerType(Connection.PeerType.DIRECT_MSG_PEER);
|
||||
|
||||
// Further treatment of the incoming message
|
||||
|
@ -2,12 +2,15 @@ package io.bitsquare.p2p.peers.getdata.messages;
|
||||
|
||||
import io.bitsquare.app.Capabilities;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.messaging.SupportedCapabilitiesMessage;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GetDataResponse implements SupportedCapabilitiesMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -38,6 +41,17 @@ public final class GetDataResponse implements SupportedCapabilitiesMessage {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.GetDataResponse.Builder builder = Messages.GetDataResponse.newBuilder();
|
||||
builder.addAllDataSet(
|
||||
dataSet.stream()
|
||||
.map(protectedStorageEntry -> protectedStorageEntry.toProtoBuf()).collect(Collectors.toList()))
|
||||
.setRequestNonce(requestNonce)
|
||||
.setIsGetUpdatedDataResponse(isGetUpdatedDataResponse);
|
||||
return Messages.Envelope.newBuilder().setGetDataResponse(builder).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetDataResponse{" +
|
||||
|
@ -1,10 +1,13 @@
|
||||
package io.bitsquare.p2p.peers.getdata.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.network.messages.SendersNodeAddressMessage;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -44,6 +47,18 @@ public final class GetUpdatedDataRequest implements SendersNodeAddressMessage, G
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
return Messages.Envelope.newBuilder().setP2PNetworkVersion(Version.P2P_NETWORK_VERSION)
|
||||
.setGetUpdatedDataRequest(
|
||||
Messages.GetUpdatedDataRequest.newBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
.setSenderNodeAddress(senderNodeAddress.toProtoBuf())
|
||||
.setNonce(nonce)
|
||||
.addAllExcludedKeys(excludedKeys.stream()
|
||||
.map(bytes -> ByteString.copyFrom(bytes)).collect(Collectors.toList()))).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GetUpdatedDataRequest{" +
|
||||
|
@ -59,7 +59,7 @@ public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDat
|
||||
'}';
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder envelopeBuilder = Messages.Envelope.newBuilder().setP2PNetworkVersion(Version.P2P_NETWORK_VERSION);
|
||||
Messages.PreliminaryGetDataRequest.Builder msgBuilder = envelopeBuilder.getPreliminaryGetDataRequestBuilder()
|
||||
@ -69,4 +69,5 @@ public final class PreliminaryGetDataRequest implements AnonymousMessage, GetDat
|
||||
msgBuilder.addAllExcludedKeys(excludedKeys.stream().map(ByteString::copyFrom).collect(Collectors.toList()));
|
||||
return envelopeBuilder.setPreliminaryGetDataRequest(msgBuilder).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package io.bitsquare.p2p.peers.keepalive.messages;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferMessage;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
public final class Ping extends KeepAliveMessage implements ProtoBufferMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -17,8 +18,8 @@ public final class Ping extends KeepAliveMessage implements ProtoBufferMessage {
|
||||
}
|
||||
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder builder = Messages.Envelope.newBuilder().setP2PNetworkVersion(Version.P2P_NETWORK_VERSION);
|
||||
return builder.setPing(builder.getPingBuilder()
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPing(baseEnvelope.getPingBuilder()
|
||||
.setNonce(nonce)
|
||||
.setLastRoundTripTime(lastRoundTripTime)).build();
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.bitsquare.p2p.peers.keepalive.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
|
||||
public final class Pong extends KeepAliveMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -18,4 +20,10 @@ public final class Pong extends KeepAliveMessage {
|
||||
"requestNonce=" + requestNonce +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setPong(Messages.Pong.newBuilder().setRequestNonce(requestNonce)).build();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package io.bitsquare.p2p.peers.peerexchange;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.persistance.Persistable;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
|
||||
import java.util.Date;
|
||||
@ -53,4 +54,10 @@ public final class Peer implements Payload, Persistable {
|
||||
", date=" + date +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toProtoBuf() {
|
||||
return Messages.Peer.newBuilder().setNodeAddress(nodeAddress.toProtoBuf())
|
||||
.setDate(date.getTime()).build();
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package io.bitsquare.p2p.peers.peerexchange.messages;
|
||||
|
||||
import io.bitsquare.app.Capabilities;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.messaging.SupportedCapabilitiesMessage;
|
||||
import io.bitsquare.p2p.peers.peerexchange.Peer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GetPeersResponse extends PeerExchangeMessage implements SupportedCapabilitiesMessage {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
@ -39,4 +41,20 @@ public final class GetPeersResponse extends PeerExchangeMessage implements Supp
|
||||
", supportedCapabilities=" + supportedCapabilities +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder envelopeBuilder = Messages.Envelope.newBuilder().setP2PNetworkVersion(Version.P2P_NETWORK_VERSION);
|
||||
|
||||
Messages.GetPeersResponse.Builder msgBuilder = Messages.GetPeersResponse.newBuilder();
|
||||
msgBuilder.setRequestNonce(requestNonce);
|
||||
msgBuilder.addAllReportedPeers(reportedPeers.stream()
|
||||
.map(peer -> Messages.Peer.newBuilder()
|
||||
.setDate(peer.date.getTime())
|
||||
.setNodeAddress(Messages.NodeAddress.newBuilder()
|
||||
.setHostName(peer.nodeAddress.getHostName())
|
||||
.setPort(peer.nodeAddress.getPort())).build())
|
||||
.collect(Collectors.toList()));
|
||||
return envelopeBuilder.setGetPeersResponse(msgBuilder).build();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.bitsquare.p2p.storage.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
|
||||
public final class AddDataMessage extends BroadcastMessage {
|
||||
@ -34,4 +36,11 @@ public final class AddDataMessage extends BroadcastMessage {
|
||||
"protectedStorageEntry=" + protectedStorageEntry +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setAddDataMessage(Messages.AddDataMessage.newBuilder()
|
||||
.setProtectedStorageEntry(protectedStorageEntry.toProtoBuf())).build();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.bitsquare.p2p.storage.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
|
||||
public final class RemoveDataMessage extends BroadcastMessage {
|
||||
@ -35,4 +37,12 @@ public final class RemoveDataMessage extends BroadcastMessage {
|
||||
"protectedStorageEntry=" + protectedStorageEntry +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setRemoveDataMessage(Messages.RemoveDataMessage.newBuilder()
|
||||
.setProtectedStorageEntry(protectedStorageEntry.toProtoBuf())).build();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.bitsquare.p2p.storage.messages;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedMailboxStorageEntry;
|
||||
|
||||
public final class RemoveMailboxDataMessage extends BroadcastMessage {
|
||||
@ -34,4 +36,12 @@ public final class RemoveMailboxDataMessage extends BroadcastMessage {
|
||||
"data=" + protectedMailboxStorageEntry +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
Messages.Envelope.Builder baseEnvelope = ProtoBufferUtilities.getBaseEnvelope();
|
||||
return baseEnvelope.setRemoveMailboxDataMessage(Messages.RemoveMailboxDataMessage.newBuilder()
|
||||
.setProtectedStorageEntry(protectedMailboxStorageEntry.toProtoBuf())).build();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.bitsquare.p2p.storage.payload;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.messaging.PrefixedSealedAndSignedMessage;
|
||||
import io.bitsquare.p2p.peers.BroadcastHandler;
|
||||
@ -96,6 +98,15 @@ public final class MailboxStoragePayload implements StoragePayload {
|
||||
return receiverPubKeyForRemoveOperation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
return Messages.StoragePayload.newBuilder().setMailboxStoragePayload(Messages.MailboxStoragePayload.newBuilder()
|
||||
.setTTL(TTL)
|
||||
.setPrefixedSealedAndSignedMessage(prefixedSealedAndSignedMessage.toProtoBuf().getPrefixedSealedAndSignedMessage())
|
||||
.setSenderPubKeyForAddOperationBytes(ByteString.copyFrom(senderPubKeyForAddOperationBytes))).build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bitsquare.p2p.storage.payload;
|
||||
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.storageentry.ProtectedStorageEntry;
|
||||
|
||||
@ -25,4 +26,7 @@ public interface StoragePayload extends ExpirablePayload {
|
||||
* @see io.bitsquare.p2p.storage.P2PDataStorage#remove(ProtectedStorageEntry, NodeAddress)
|
||||
*/
|
||||
PublicKey getOwnerPubKey();
|
||||
|
||||
Messages.StoragePayload toProtoBuf();
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.bitsquare.p2p.storage.storageentry;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.Sig;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -100,6 +102,12 @@ public class ProtectedStorageEntry implements Payload {
|
||||
return (System.currentTimeMillis() - creationTimeStamp) > storagePayload.getTTL();
|
||||
}
|
||||
|
||||
public Messages.ProtectedStorageEntry toProtoBuf() {
|
||||
return Messages.ProtectedStorageEntry.newBuilder().setStoragePayload((Messages.StoragePayload) storagePayload.toProtoBuf())
|
||||
.setOwnerPubKeyBytes(ByteString.copyFrom(ownerPubKeyBytes)).setSequenceNumber(sequenceNumber)
|
||||
.setSignature(ByteString.copyFrom(signature)).setCreationTimeStamp(creationTimeStamp).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProtectedStorageEntry{" +
|
||||
|
@ -20,7 +20,9 @@ package io.bitsquare.crypto;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.crypto.*;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.ProtoBufferUtilities;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import io.bitsquare.p2p.messaging.PrefixedSealedAndSignedMessage;
|
||||
import io.bitsquare.storage.FileUtil;
|
||||
@ -32,6 +34,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -106,4 +109,9 @@ final class TestMessage implements MailboxMessage {
|
||||
public int getMessageVersion() {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package io.bitsquare.p2p.mocks;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.messaging.MailboxMessage;
|
||||
import io.bitsquare.p2p.storage.payload.ExpirablePayload;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -25,6 +27,11 @@ public final class MockMailboxPayload implements MailboxMessage, ExpirablePayloa
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return uid;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package io.bitsquare.p2p.mocks;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.Message;
|
||||
import io.bitsquare.p2p.storage.payload.ExpirablePayload;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
public final class MockPayload implements Message, ExpirablePayload {
|
||||
public final String msg;
|
||||
@ -18,6 +20,11 @@ public final class MockPayload implements Message, ExpirablePayload {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@ -45,4 +52,5 @@ public final class MockPayload implements Message, ExpirablePayload {
|
||||
public long getTTL() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.crypto.KeyStorage;
|
||||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.util.Tuple3;
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
|
||||
import io.bitsquare.crypto.EncryptionService;
|
||||
import io.bitsquare.p2p.*;
|
||||
@ -23,6 +24,7 @@ import org.junit.runner.JUnitCore;
|
||||
import org.junit.runner.Request;
|
||||
import org.junit.runner.Result;
|
||||
import org.junit.runner.notification.Failure;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -815,6 +817,11 @@ final class StressTestDirectMessage implements DirectMessage {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
String getData() {
|
||||
return data;
|
||||
}
|
||||
@ -838,6 +845,11 @@ final class StressTestMailboxMessage implements MailboxMessage {
|
||||
return messageVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.Envelope toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeAddress getSenderNodeAddress() {
|
||||
return senderNodeAddress;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.bitsquare.p2p.storage.mocks;
|
||||
|
||||
import io.bitsquare.common.wire.proto.Messages;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
@ -46,4 +48,9 @@ public class MockData implements StoragePayload {
|
||||
public PublicKey getOwnerPubKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages.StoragePayload toProtoBuf() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user