mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
getting the Trade serialized, wip
This commit is contained in:
parent
5498025a3a
commit
bf7c06e0e2
82 changed files with 500 additions and 395 deletions
|
@ -37,7 +37,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
|
@ -50,4 +50,4 @@
|
|||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -26,8 +26,6 @@ public interface Marshaller extends Serializable {
|
|||
default Message toProto() {
|
||||
throw new NotImplementedException("toProtobuf not yet implemented.");
|
||||
}
|
||||
default Object fromProto() {
|
||||
throw new NotImplementedException("toProtobuf not yet implemented.");
|
||||
}
|
||||
//Object fromProto();
|
||||
|
||||
}
|
||||
|
|
|
@ -121,6 +121,12 @@ public final class PubKeyRing implements Payload {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static PubKeyRing fromProto(PB.PubKeyRing pubKeyRing) {
|
||||
return new PubKeyRing(pubKeyRing.getSignaturePubKeyBytes().toByteArray(),
|
||||
pubKeyRing.getEncryptionPubKeyBytes().toByteArray(),
|
||||
pubKeyRing.getPgpPubKeyAsPem());
|
||||
}
|
||||
|
||||
// Hex
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -12,6 +12,6 @@ public interface Msg extends Marshaller {
|
|||
|
||||
int getMessageVersion();
|
||||
|
||||
@Override
|
||||
PB.Envelope toProto();
|
||||
PB.Envelope toEnvelopeProto();
|
||||
|
||||
}
|
||||
|
|
|
@ -771,6 +771,7 @@ message DiskEnvelope {
|
|||
LongPersistable bloom_filter_nonce = 10;
|
||||
TradeStatisticsList trade_statistics_list = 12;
|
||||
VoteItemsList vote_items_list = 13;
|
||||
TradableList tradable_list = 14;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -942,19 +943,17 @@ message Region {
|
|||
string name = 2;
|
||||
}
|
||||
message Tradable {
|
||||
|
||||
oneof message {
|
||||
OpenOffer open_offer = 1;
|
||||
//+OpenOffer (io.bisq.core.offer)
|
||||
//A Trade (io.bisq.core.trade)
|
||||
//A BuyerTrade (io.bisq.core.trade)
|
||||
//BuyerAsOffererTrade (io.bisq.core.trade)
|
||||
//BuyerAsTakerTrade (io.bisq.core.trade)
|
||||
//A SellerTrade (io.bisq.core.trade)
|
||||
//SellerAsOffererTrade (io.bisq.core.trade)
|
||||
//SellerAsTakerTrade (io.bisq.core.trade)
|
||||
BuyerAsMakerTrade buyer_as_maker_trade = 2;
|
||||
BuyerAsTakerTrade buyer_as_taker_trade= 3;
|
||||
SellerAsMakerTrade seller_as_maker_trade = 4;
|
||||
SellerAsTakerTrade seller_as_taker_trade = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message TradableList {
|
||||
repeated Tradable tradable = 1;
|
||||
}
|
||||
|
||||
message OpenOffer {
|
||||
|
@ -1021,7 +1020,7 @@ message Trade {
|
|||
}
|
||||
|
||||
|
||||
enum PeriodState {
|
||||
enum TradePeriodState {
|
||||
TRADE_PERIOD_STATE_UNKNOWN_FAILURE = 0;
|
||||
NORMAL = 1;
|
||||
HALF_REACHED = 2;
|
||||
|
@ -1030,45 +1029,46 @@ message Trade {
|
|||
|
||||
Offer offer = 1;
|
||||
ProcessModel process_model = 2;
|
||||
DecryptedMsgWithPubKey decrypted_msg_with_pub_key = 3;
|
||||
int64 take_offerint64 = 4;
|
||||
Coin trade_amount = 5;
|
||||
Coin tx_fee = 6;
|
||||
Coin take_offer_fee = 7;
|
||||
int64 trade_price = 8;
|
||||
NodeAddress trading_peer_node_address = 9;
|
||||
string take_offer_fee_tx_id = 10;
|
||||
State state = 11;
|
||||
DisputeState dispute_state = 12;
|
||||
PeriodState trade_period_state = 13;
|
||||
Transaction deposit_tx = 14;
|
||||
Contract contract = 15;
|
||||
string contract_as_json = 16;
|
||||
bytes contract_hash = 17;
|
||||
string taker_contract_signature = 18;
|
||||
string offerer_contract_signature = 19;
|
||||
Transaction payout_tx = 20;
|
||||
int64 lock_time_as_block_height = 21;
|
||||
string taker_fee_tx_id = 3;
|
||||
string deposit_tx_id = 4;
|
||||
string payout_tx_id = 5;
|
||||
int64 trade_amount_as_long = 6;
|
||||
int64 tx_fee_as_long = 7;
|
||||
int64 taker_fee_as_long = 8;
|
||||
DecryptedMsgWithPubKey decrypted_msg_with_pub_key = 9;
|
||||
int64 take_offer_date = 10;
|
||||
bool is_currency_for_taker_fee_btc = 11;
|
||||
int64 trade_price = 12;
|
||||
NodeAddress trading_peer_node_address = 13;
|
||||
State state = 14;
|
||||
DisputeState dispute_state = 15;
|
||||
TradePeriodState trade_period_state = 16;
|
||||
Contract contract = 17;
|
||||
string contract_as_json = 18;
|
||||
bytes contract_hash = 19;
|
||||
string taker_contract_signature = 20;
|
||||
string maker_contract_signature = 21;
|
||||
NodeAddress arbitrator_node_address = 22;
|
||||
bytes arbitrator_btc_pub_key = 23;
|
||||
string taker_payment_account_id = 24;
|
||||
string error_message = 25;
|
||||
NodeAddress mediator_node_address = 23;
|
||||
bytes arbitrator_btc_pub_key = 24;
|
||||
string taker_payment_account_id = 25;
|
||||
string error_message = 26;
|
||||
}
|
||||
|
||||
message BuyerTrade {
|
||||
}
|
||||
message BuyerAsOffererTrade {
|
||||
message BuyerAsMakerTrade {
|
||||
Trade trade = 1;
|
||||
}
|
||||
message BuyerAsTakerTrade {
|
||||
Trade trade = 1;
|
||||
}
|
||||
message SellerTrade {
|
||||
Trade trade = 1;
|
||||
}
|
||||
message SellerAsOffererTrade {
|
||||
message SellerAsMakerTrade {
|
||||
Trade trade = 1;
|
||||
}
|
||||
message SellerAsTakerTrade {
|
||||
}
|
||||
|
||||
message TradableList {
|
||||
Trade trade = 1;
|
||||
}
|
||||
|
||||
message TradeCurrency {
|
||||
|
@ -1193,7 +1193,16 @@ message ProcessModel {
|
|||
}
|
||||
|
||||
message Offer {
|
||||
enum State {
|
||||
UNDEFINED = 0;
|
||||
OFFER_FEE_PAID = 1;
|
||||
AVAILABLE = 2;
|
||||
NOT_AVAILABLE = 3;
|
||||
REMOVED = 4;
|
||||
MAKER_OFFLINE = 5;
|
||||
}
|
||||
|
||||
OfferPayload offer_payload = 1;
|
||||
}
|
||||
|
||||
message MockMailboxPayload {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PrivateNotificationMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPrivateNotificationMessage(baseEnvelope.getPrivateNotificationMessageBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
|
|
|
@ -124,7 +124,7 @@ public final class Arbitrator implements StoragePayload {
|
|||
return new Arbitrator(NodeAddress.fromProto(arbitrator.getNodeAddress()),
|
||||
arbitrator.getBtcPubKey().toByteArray(),
|
||||
arbitrator.getBtcAddress(),
|
||||
ProtoUtil.getPubKeyRing(arbitrator.getPubKeyRing()),
|
||||
PubKeyRing.fromProto(arbitrator.getPubKeyRing()),
|
||||
strings,
|
||||
date,
|
||||
arbitrator.getRegistrationPubKey().toByteArray(),
|
||||
|
|
|
@ -397,7 +397,7 @@ public final class Dispute implements Payload {
|
|||
.setArbitratorPubKeyRing(arbitratorPubKeyRing.toProto())
|
||||
.setIsSupportTicket(isSupportTicket)
|
||||
.addAllDisputeCommunicationMessages(disputeCommunicationMessages.stream().map(
|
||||
disputeCommunicationMessage -> disputeCommunicationMessage.toProto().getDisputeCommunicationMessage()).collect(Collectors.toList()))
|
||||
disputeCommunicationMessage -> disputeCommunicationMessage.toEnvelopeProto().getDisputeCommunicationMessage()).collect(Collectors.toList()))
|
||||
.setIsClosed(isClosed);
|
||||
|
||||
Optional.ofNullable(depositTxSerialized).ifPresent(tx -> builder.setDepositTxSerialized(ByteString.copyFrom(tx)));
|
||||
|
|
|
@ -246,7 +246,7 @@ public final class DisputeResult implements Payload {
|
|||
.setIdVerification(idVerification)
|
||||
.setScreenCast(screenCast)
|
||||
.setSummaryNotes(summaryNotes)
|
||||
.setDisputeCommunicationMessage(disputeCommunicationMessage.toProto().getDisputeCommunicationMessage())
|
||||
.setDisputeCommunicationMessage(disputeCommunicationMessage.toEnvelopeProto().getDisputeCommunicationMessage())
|
||||
.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature))
|
||||
.setBuyerPayoutAmount(buyerPayoutAmount)
|
||||
.setSellerPayoutAmount(sellerPayoutAmount)
|
||||
|
|
|
@ -118,7 +118,7 @@ public final class Mediator implements StoragePayload {
|
|||
Date date = new Date(mediator.getRegistrationDate());
|
||||
String emailAddress = mediator.getEmailAddress().isEmpty() ? null : mediator.getEmailAddress();
|
||||
return new Mediator(NodeAddress.fromProto(mediator.getNodeAddress()),
|
||||
ProtoUtil.getPubKeyRing(mediator.getPubKeyRing()),
|
||||
PubKeyRing.fromProto(mediator.getPubKeyRing()),
|
||||
langCodes,
|
||||
date,
|
||||
mediator.getRegistrationPubKey().toByteArray(),
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class DisputeCommunicationMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setDisputeCommunicationMessage(PB.DisputeCommunicationMessage.newBuilder()
|
||||
.setDate(date)
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class DisputeResultMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setDisputeResultMessage(PB.DisputeResultMessage.newBuilder()
|
||||
.setDisputeResult(disputeResult.toProto())
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class OpenNewDisputeMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setOpenNewDisputeMessage(PB.OpenNewDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProto()).setMyNodeAddress(myNodeAddress.toProto()).setUid(getUID())).build();
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class PeerOpenedDisputeMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPeerOpenedDisputeMessage(PB.PeerOpenedDisputeMessage.newBuilder()
|
||||
.setDispute(dispute.toProto())
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class PeerPublishedPayoutTxMsg extends DisputeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPeerPublishedPayoutTxMessage(PB.PeerPublishedPayoutTxMessage.newBuilder()
|
||||
.setTransaction(ByteString.copyFrom(transaction))
|
||||
|
|
|
@ -22,7 +22,7 @@ public final class GetBsqBlocksRequest implements DirectMsg {
|
|||
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
final PB.GetBsqBlocksRequest.Builder builder = PB.GetBsqBlocksRequest.newBuilder()
|
||||
.setFromBlockHeight(fromBlockHeight);
|
||||
return Msg.getEnv().setGetBsqBlocksRequest(builder).build();
|
||||
|
|
|
@ -19,7 +19,7 @@ public final class GetBsqBlocksResponse implements DirectMsg, ExtendedDataSizePe
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
final PB.GetBsqBlocksResponse.Builder builder = PB.GetBsqBlocksResponse.newBuilder()
|
||||
.setBsqBlocksBytes(ByteString.copyFrom(bsqBlocksBytes));
|
||||
return Msg.getEnv().setGetBsqBlocksResponse(builder).build();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.bisq.core.dao.blockchain.p2p;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -18,12 +19,17 @@ public final class NewBsqBlockBroadcastMsg extends BroadcastMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
final PB.NewBsqBlockBroadcastMsg.Builder builder = PB.NewBsqBlockBroadcastMsg.newBuilder()
|
||||
.setBsqBlockBytes(ByteString.copyFrom(bsqBlockBytes));
|
||||
return Msg.getEnv().setNewBsqBlockBroadcastMsg(builder).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return toEnvelopeProto().getNewBsqBlockBroadcastMsg();
|
||||
}
|
||||
|
||||
public static Msg fromProto(PB.Envelope envelope) {
|
||||
PB.NewBsqBlockBroadcastMsg msg = envelope.getNewBsqBlockBroadcastMsg();
|
||||
return new NewBsqBlockBroadcastMsg(msg.getBsqBlockBytes().toByteArray());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.bisq.core.offer;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.crypto.PubKeyRing;
|
||||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
|
@ -8,6 +9,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.monetary.Altcoin;
|
||||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.util.JsonExclude;
|
||||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.common.util.Utilities;
|
||||
|
@ -17,6 +19,7 @@ import io.bisq.core.offer.availability.OfferAvailabilityProtocol;
|
|||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.provider.price.MarketPrice;
|
||||
import io.bisq.core.provider.price.PriceFeedService;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import javafx.beans.property.*;
|
||||
import lombok.Getter;
|
||||
|
@ -37,13 +40,16 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
public class Offer implements Serializable {
|
||||
public class Offer implements Persistable, Serializable {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public enum Direction {BUY, SELL}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enums
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public enum State {
|
||||
UNDEFINED,
|
||||
|
@ -54,7 +60,6 @@ public class Offer implements Serializable {
|
|||
MAKER_OFFLINE
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -88,21 +93,6 @@ public class Offer implements Serializable {
|
|||
this.offerPayload = offerPayload;
|
||||
}
|
||||
|
||||
// TODO still needed as we get the offer from persistence serialized
|
||||
// can be removed once we have full PB support
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
in.defaultReadObject();
|
||||
stateProperty = new SimpleObjectProperty<>(Offer.State.UNDEFINED);
|
||||
|
||||
// we don't need to fill it as the error message is only relevant locally, so we don't store it in the transmitted object
|
||||
errorMessageProperty = new SimpleStringProperty();
|
||||
} catch (Throwable t) {
|
||||
log.warn("Cannot be deserialized." + t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Availability
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -138,10 +128,10 @@ public class Offer implements Serializable {
|
|||
double factor;
|
||||
double marketPriceMargin = offerPayload.getMarketPriceMargin();
|
||||
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||
factor = getDirection() == Offer.Direction.SELL ?
|
||||
factor = getDirection() == OfferPayload.Direction.SELL ?
|
||||
1 - marketPriceMargin : 1 + marketPriceMargin;
|
||||
} else {
|
||||
factor = getDirection() == Offer.Direction.BUY ?
|
||||
factor = getDirection() == OfferPayload.Direction.BUY ?
|
||||
1 - marketPriceMargin : 1 + marketPriceMargin;
|
||||
}
|
||||
double marketPriceAsDouble = marketPrice.getPrice();
|
||||
|
@ -296,11 +286,11 @@ public class Offer implements Serializable {
|
|||
}
|
||||
|
||||
public boolean isBuyOffer() {
|
||||
return getDirection() == Offer.Direction.BUY;
|
||||
return getDirection() == OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
public Offer.Direction getMirroredDirection() {
|
||||
return getDirection() == Offer.Direction.BUY ? Offer.Direction.SELL : Offer.Direction.BUY;
|
||||
public OfferPayload.Direction getMirroredDirection() {
|
||||
return getDirection() == OfferPayload.Direction.BUY ? OfferPayload.Direction.SELL : OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
public boolean isMyOffer(KeyRing keyRing) {
|
||||
|
@ -326,8 +316,8 @@ public class Offer implements Serializable {
|
|||
// Delegate Getter (boilerplate code generated via IntelliJ generate delegate feature)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Offer.Direction getDirection() {
|
||||
return Offer.Direction.valueOf(offerPayload.getDirection().name());
|
||||
public OfferPayload.Direction getDirection() {
|
||||
return OfferPayload.Direction.valueOf(offerPayload.getDirection().name());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -476,4 +466,13 @@ public class Offer implements Serializable {
|
|||
", offerPayload=" + offerPayload +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public PB.Offer toProto() {
|
||||
return PB.Offer.newBuilder().setOfferPayload(offerPayload.toProto().getOfferPayload()).build();
|
||||
}
|
||||
|
||||
public static Offer fromProto(PB.Offer proto) {
|
||||
return new Offer(OfferPayload.fromProto(proto.getOfferPayload()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Date;
|
|||
public class OfferForJson {
|
||||
private static final Logger log = LoggerFactory.getLogger(OfferForJson.class);
|
||||
|
||||
public final Offer.Direction direction;
|
||||
public final OfferPayload.Direction direction;
|
||||
public final String currencyCode;
|
||||
public final long minAmount;
|
||||
public final long amount;
|
||||
|
@ -29,7 +29,7 @@ public class OfferForJson {
|
|||
|
||||
// primaryMarket fields are based on industry standard where primaryMarket is always in the focus (in the app BTC is always in the focus - will be changed in a larger refactoring once)
|
||||
public String currencyPair;
|
||||
public Offer.Direction primaryMarketDirection;
|
||||
public OfferPayload.Direction primaryMarketDirection;
|
||||
|
||||
public String priceDisplayString;
|
||||
public String primaryMarketAmountDisplayString;
|
||||
|
@ -44,7 +44,7 @@ public class OfferForJson {
|
|||
public long primaryMarketMinVolume;
|
||||
|
||||
|
||||
public OfferForJson(Offer.Direction direction,
|
||||
public OfferForJson(OfferPayload.Direction direction,
|
||||
String currencyCode,
|
||||
Coin minAmount,
|
||||
Coin amount,
|
||||
|
@ -89,13 +89,13 @@ public class OfferForJson {
|
|||
try {
|
||||
final Price price = getPrice();
|
||||
if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||
primaryMarketDirection = direction == Offer.Direction.BUY ? Offer.Direction.SELL : Offer.Direction.BUY;
|
||||
primaryMarketDirection = direction == OfferPayload.Direction.BUY ? OfferPayload.Direction.SELL : OfferPayload.Direction.BUY;
|
||||
currencyPair = currencyCode + "/" + "BTC";
|
||||
|
||||
// int precision = 8;
|
||||
//decimalFormat.setMaximumFractionDigits(precision);
|
||||
|
||||
// amount and volume is inverted for json
|
||||
// amount and volume is inverted for json
|
||||
priceDisplayString = altcoinFormat.noCode().format(price.getMonetary()).toString();
|
||||
primaryMarketMinAmountDisplayString = altcoinFormat.noCode().format(getMinVolume().getMonetary()).toString();
|
||||
primaryMarketAmountDisplayString = altcoinFormat.noCode().format(getVolume().getMonetary()).toString();
|
||||
|
@ -116,7 +116,7 @@ public class OfferForJson {
|
|||
// primaryMarketMinVolumeDisplayString = coinFormat.noCode().format(getMinAmountAsCoin()).toString();
|
||||
// primaryMarketVolumeDisplayString = coinFormat.noCode().format(getAmountAsCoin()).toString();
|
||||
|
||||
|
||||
|
||||
/*primaryMarketPrice = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(value, precision));
|
||||
primaryMarketMinAmount = (long) MathUtils.scaleUpByPowerOf10(getMinVolume().longValue(), precision);
|
||||
primaryMarketAmount = (long) MathUtils.scaleUpByPowerOf10(getVolume().longValue(), precision);
|
||||
|
@ -138,8 +138,8 @@ public class OfferForJson {
|
|||
primaryMarketAmount = getAmountAsCoin().getValue();
|
||||
primaryMarketMinVolume = getMinVolume().getValue();
|
||||
primaryMarketVolume = getVolume().getValue();
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
priceDisplayString = fiatFormat.noCode().format(price.getMonetary()).toString();
|
||||
|
||||
primaryMarketMinAmountDisplayString = coinFormat.noCode().format(getMinAmountAsCoin()).toString();
|
||||
|
|
|
@ -31,7 +31,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.security.PublicKey;
|
||||
|
@ -72,7 +72,6 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -234,6 +233,8 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Overridden Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -253,6 +254,16 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
|||
return TTL;
|
||||
}
|
||||
|
||||
|
||||
//TODO remove
|
||||
public String getCurrencyCode() {
|
||||
if (CurrencyUtil.isCryptoCurrency(getBaseCurrencyCode()))
|
||||
return getBaseCurrencyCode();
|
||||
else
|
||||
return getCounterCurrencyCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PB.StoragePayload toProto() {
|
||||
List<PB.NodeAddress> arbitratorNodeAddresses = this.arbitratorNodeAddresses.stream()
|
||||
|
@ -310,11 +321,64 @@ public final class OfferPayload implements StoragePayload, RequiresOwnerIsOnline
|
|||
return PB.StoragePayload.newBuilder().setOfferPayload(offerBuilder).build();
|
||||
}
|
||||
|
||||
//TODO remove
|
||||
public String getCurrencyCode() {
|
||||
if (CurrencyUtil.isCryptoCurrency(getBaseCurrencyCode()))
|
||||
return getBaseCurrencyCode();
|
||||
else
|
||||
return getCounterCurrencyCode();
|
||||
public static OfferPayload fromProto(PB.OfferPayload proto) {
|
||||
List<NodeAddress> arbitratorNodeAddresses = proto.getArbitratorNodeAddressesList().stream()
|
||||
.map(NodeAddress::fromProto).collect(Collectors.toList());
|
||||
List<NodeAddress> mediatorNodeAddresses = proto.getMediatorNodeAddressesList().stream()
|
||||
.map(NodeAddress::fromProto).collect(Collectors.toList());
|
||||
|
||||
// Nullable object need to be checked against the default values in PB (not nice... ;-( )
|
||||
|
||||
// convert these lists because otherwise when they're empty they are lazyStringArrayList objects and NOT serializable,
|
||||
// which is needed for the P2PStorage getHash() operation
|
||||
List<String> acceptedCountryCodes = proto.getAcceptedCountryCodesList().isEmpty() ?
|
||||
null : proto.getAcceptedCountryCodesList().stream().collect(Collectors.toList());
|
||||
List<String> acceptedBankIds = proto.getAcceptedBankIdsList().isEmpty() ?
|
||||
null : proto.getAcceptedBankIdsList().stream().collect(Collectors.toList());
|
||||
Map<String, String> extraDataMapMap = CollectionUtils.isEmpty(proto.getExtraDataMapMap()) ?
|
||||
null : proto.getExtraDataMapMap();
|
||||
final String countryCode1 = proto.getCountryCode();
|
||||
String countryCode = countryCode1.isEmpty() ? null : countryCode1;
|
||||
String bankId = proto.getBankId().isEmpty() ? null : proto.getBankId();
|
||||
String offerFeePaymentTxId = proto.getOfferFeePaymentTxId().isEmpty() ? null : proto.getOfferFeePaymentTxId();
|
||||
String hashOfChallenge = proto.getHashOfChallenge().isEmpty() ? null : proto.getHashOfChallenge();
|
||||
|
||||
return new OfferPayload(proto.getId(),
|
||||
proto.getDate(),
|
||||
NodeAddress.fromProto(proto.getMakerNodeAddress()),
|
||||
PubKeyRing.fromProto(proto.getPubKeyRing()),
|
||||
OfferPayload.Direction.fromProto(proto.getDirection()),
|
||||
proto.getPrice(),
|
||||
proto.getMarketPriceMargin(),
|
||||
proto.getUseMarketBasedPrice(),
|
||||
proto.getAmount(),
|
||||
proto.getMinAmount(),
|
||||
proto.getBaseCurrencyCode(),
|
||||
proto.getCounterCurrencyCode(),
|
||||
arbitratorNodeAddresses,
|
||||
mediatorNodeAddresses,
|
||||
proto.getPaymentMethodId(),
|
||||
proto.getMakerPaymentAccountId(),
|
||||
offerFeePaymentTxId,
|
||||
countryCode,
|
||||
acceptedCountryCodes,
|
||||
bankId,
|
||||
acceptedBankIds,
|
||||
proto.getVersionNr(),
|
||||
proto.getBlockHeightAtOfferCreation(),
|
||||
proto.getTxFee(),
|
||||
proto.getMakerFee(),
|
||||
proto.getIsCurrencyForMakerFeeBtc(),
|
||||
proto.getBuyerSecurityDeposit(),
|
||||
proto.getSellerSecurityDeposit(),
|
||||
proto.getMaxTradeLimit(),
|
||||
proto.getMaxTradePeriod(),
|
||||
proto.getUseAutoClose(),
|
||||
proto.getUseReOpenAfterAutoClose(),
|
||||
proto.getLowerClosePrice(),
|
||||
proto.getUpperClosePrice(),
|
||||
proto.getIsPrivateOffer(),
|
||||
hashOfChallenge,
|
||||
extraDataMapMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,18 +17,22 @@
|
|||
|
||||
package io.bisq.core.offer;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Timer;
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.trade.Tradable;
|
||||
import io.bisq.core.trade.TradableList;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@EqualsAndHashCode
|
||||
@Slf4j
|
||||
public final class OpenOffer implements Tradable {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
|
@ -57,19 +61,6 @@ public final class OpenOffer implements Tradable {
|
|||
this.storage = storage;
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
in.defaultReadObject();
|
||||
|
||||
// If we have a reserved state from the local db we reset it
|
||||
if (state == State.RESERVED)
|
||||
setState(State.AVAILABLE);
|
||||
|
||||
} catch (Throwable t) {
|
||||
log.warn("Cannot be deserialized." + t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return offer.getDate();
|
||||
}
|
||||
|
@ -119,25 +110,6 @@ public final class OpenOffer implements Tradable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
OpenOffer openOffer = (OpenOffer) o;
|
||||
|
||||
if (offer != null ? !offer.equals(openOffer.offer) : openOffer.offer != null) return false;
|
||||
return state == openOffer.state;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = offer != null ? offer.hashCode() : 0;
|
||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OpenOffer{" +
|
||||
|
@ -145,6 +117,20 @@ public final class OpenOffer implements Tradable {
|
|||
"\n\tstate=" + state +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return PB.OpenOffer.newBuilder().setOffer(offer.toProto())
|
||||
.setState(PB.OpenOffer.State.valueOf(state.name())).build();
|
||||
}
|
||||
|
||||
// TODO set storage
|
||||
public static Tradable fromProto(PB.OpenOffer proto, Storage<TradableList<OpenOffer>> storage) {
|
||||
OpenOffer openOffer = new OpenOffer(Offer.fromProto(proto.getOffer()), storage);
|
||||
// If we have a reserved state from the local db we reset it
|
||||
if (openOffer.getState() == State.RESERVED)
|
||||
openOffer.setState(State.AVAILABLE);
|
||||
return openOffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
|
||||
private void republishOffers() {
|
||||
int size = openOffers.size();
|
||||
final ArrayList<OpenOffer> openOffersList = new ArrayList<>(openOffers);
|
||||
final ArrayList<OpenOffer> openOffersList = new ArrayList<>(openOffers.getList());
|
||||
Log.traceCall("Number of offer for republish: " + size);
|
||||
if (!stopped) {
|
||||
stopPeriodicRefreshOffersTimer();
|
||||
|
@ -531,7 +531,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
Log.traceCall("Number of offer for refresh: " + size);
|
||||
|
||||
//we clone our list as openOffers might change during our delayed call
|
||||
final ArrayList<OpenOffer> openOffersList = new ArrayList<>(openOffers);
|
||||
final ArrayList<OpenOffer> openOffersList = new ArrayList<>(openOffers.getList());
|
||||
for (int i = 0; i < size; i++) {
|
||||
// we delay to avoid reaching throttle limits
|
||||
// roughly 4 offers per second
|
||||
|
|
|
@ -27,7 +27,7 @@ import io.bisq.network.p2p.SupportedCapabilitiesMsg;
|
|||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// We add here the SupportedCapabilitiesMessage interface as that message always predates a direct connection
|
||||
// We add here the SupportedCapabilitiesMessage interface as that message always predates a direct connection
|
||||
// to the trading peer
|
||||
public final class OfferAvailabilityRequest extends OfferMsg implements SupportedCapabilitiesMsg {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
|
@ -62,7 +62,7 @@ public final class OfferAvailabilityRequest extends OfferMsg implements Supporte
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
return Msg.getEnv()
|
||||
.setOfferAvailabilityRequest(PB.OfferAvailabilityRequest.newBuilder()
|
||||
.setOfferId(offerId)
|
||||
|
|
|
@ -58,7 +58,7 @@ public final class OfferAvailabilityResponse extends OfferMsg implements Support
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setOfferAvailabilityResponse(PB.OfferAvailabilityResponse.newBuilder().setMessageVersion(getMessageVersion())
|
||||
.setOfferId(offerId)
|
||||
|
|
|
@ -200,7 +200,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
|
||||
private static Msg getOfferAvailabilityRequest(PB.Envelope envelope) {
|
||||
PB.OfferAvailabilityRequest msg = envelope.getOfferAvailabilityRequest();
|
||||
return new OfferAvailabilityRequest(msg.getOfferId(), ProtoUtil.getPubKeyRing(msg.getPubKeyRing()), msg.getTakersTradePrice());
|
||||
return new OfferAvailabilityRequest(msg.getOfferId(), PubKeyRing.fromProto(msg.getPubKeyRing()), msg.getTakersTradePrice());
|
||||
}
|
||||
|
||||
private static Msg getPrivateNotificationMessage(PB.PrivateNotificationMessage privateNotificationMessage) {
|
||||
|
@ -277,7 +277,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
payDepositRequest.getChangeOutputAddress(),
|
||||
payDepositRequest.getTakerMultiSigPubKey().toByteArray(),
|
||||
payDepositRequest.getTakerPayoutAddressString(),
|
||||
ProtoUtil.getPubKeyRing(payDepositRequest.getTakerPubKeyRing()),
|
||||
PubKeyRing.fromProto(payDepositRequest.getTakerPubKeyRing()),
|
||||
PaymentAccountPayload.fromProto(payDepositRequest.getTakerPaymentAccountPayload()),
|
||||
payDepositRequest.getTakerAccountId(),
|
||||
payDepositRequest.getTakerFeeTxId(),
|
||||
|
@ -517,7 +517,7 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
extraDataMapMap);
|
||||
break;
|
||||
case OFFER_PAYLOAD:
|
||||
storagePayload = getOfferPayload(protoEntry.getOfferPayload());
|
||||
storagePayload = OfferPayload.fromProto(protoEntry.getOfferPayload());
|
||||
break;
|
||||
default:
|
||||
log.error("Unknown storagepayload:{}", protoEntry.getMessageCase());
|
||||
|
@ -536,69 +536,6 @@ public class CoreNetworkProtoResolver implements NetworkProtoResolver {
|
|||
return new PrivateNotificationPayload(privateNotification.getMessage());
|
||||
}
|
||||
|
||||
public static OfferPayload getOfferPayload(PB.OfferPayload pbOffer) {
|
||||
List<NodeAddress> arbitratorNodeAddresses = pbOffer.getArbitratorNodeAddressesList().stream()
|
||||
.map(NodeAddress::fromProto).collect(Collectors.toList());
|
||||
List<NodeAddress> mediatorNodeAddresses = pbOffer.getMediatorNodeAddressesList().stream()
|
||||
.map(NodeAddress::fromProto).collect(Collectors.toList());
|
||||
|
||||
// Nullable object need to be checked against the default values in PB (not nice... ;-( )
|
||||
|
||||
// convert these lists because otherwise when they're empty they are lazyStringArrayList objects and NOT serializable,
|
||||
// which is needed for the P2PStorage getHash() operation
|
||||
List<String> acceptedCountryCodes = pbOffer.getAcceptedCountryCodesList().isEmpty() ?
|
||||
null : pbOffer.getAcceptedCountryCodesList().stream().collect(Collectors.toList());
|
||||
List<String> acceptedBankIds = pbOffer.getAcceptedBankIdsList().isEmpty() ?
|
||||
null : pbOffer.getAcceptedBankIdsList().stream().collect(Collectors.toList());
|
||||
Map<String, String> extraDataMapMap = CollectionUtils.isEmpty(pbOffer.getExtraDataMapMap()) ?
|
||||
null : pbOffer.getExtraDataMapMap();
|
||||
final String countryCode1 = pbOffer.getCountryCode();
|
||||
String countryCode = countryCode1.isEmpty() ? null : countryCode1;
|
||||
String bankId = pbOffer.getBankId().isEmpty() ? null : pbOffer.getBankId();
|
||||
String offerFeePaymentTxId = pbOffer.getOfferFeePaymentTxId().isEmpty() ? null : pbOffer.getOfferFeePaymentTxId();
|
||||
String hashOfChallenge = pbOffer.getHashOfChallenge().isEmpty() ? null : pbOffer.getHashOfChallenge();
|
||||
|
||||
return new OfferPayload(pbOffer.getId(),
|
||||
pbOffer.getDate(),
|
||||
NodeAddress.fromProto(pbOffer.getMakerNodeAddress()),
|
||||
ProtoUtil.getPubKeyRing(pbOffer.getPubKeyRing()),
|
||||
OfferPayload.Direction.fromProto(pbOffer.getDirection()),
|
||||
pbOffer.getPrice(),
|
||||
pbOffer.getMarketPriceMargin(),
|
||||
pbOffer.getUseMarketBasedPrice(),
|
||||
pbOffer.getAmount(),
|
||||
pbOffer.getMinAmount(),
|
||||
pbOffer.getBaseCurrencyCode(),
|
||||
pbOffer.getCounterCurrencyCode(),
|
||||
arbitratorNodeAddresses,
|
||||
mediatorNodeAddresses,
|
||||
pbOffer.getPaymentMethodId(),
|
||||
pbOffer.getMakerPaymentAccountId(),
|
||||
offerFeePaymentTxId,
|
||||
countryCode,
|
||||
acceptedCountryCodes,
|
||||
bankId,
|
||||
acceptedBankIds,
|
||||
pbOffer.getVersionNr(),
|
||||
pbOffer.getBlockHeightAtOfferCreation(),
|
||||
pbOffer.getTxFee(),
|
||||
pbOffer.getMakerFee(),
|
||||
pbOffer.getIsCurrencyForMakerFeeBtc(),
|
||||
pbOffer.getBuyerSecurityDeposit(),
|
||||
pbOffer.getSellerSecurityDeposit(),
|
||||
pbOffer.getMaxTradeLimit(),
|
||||
pbOffer.getMaxTradePeriod(),
|
||||
pbOffer.getUseAutoClose(),
|
||||
pbOffer.getUseReOpenAfterAutoClose(),
|
||||
pbOffer.getLowerClosePrice(),
|
||||
pbOffer.getUpperClosePrice(),
|
||||
pbOffer.getIsPrivateOffer(),
|
||||
hashOfChallenge,
|
||||
extraDataMapMap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Handle by PaymentAccountPayload.MessageCase
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -23,17 +23,14 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.core.arbitration.Dispute;
|
||||
import io.bisq.core.filter.PaymentAccountFilter;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.PaymentAccountFactory;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.payload.BankAccountPayload;
|
||||
import io.bisq.core.payment.payload.CountryBasedPaymentAccountPayload;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.trade.Contract;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
|
@ -50,15 +47,15 @@ public class ProtoUtil {
|
|||
static Dispute getDispute(PB.Dispute dispute) {
|
||||
return new Dispute(dispute.getTradeId(), dispute.getTraderId(),
|
||||
dispute.getDisputeOpenerIsBuyer(), dispute.getDisputeOpenerIsMaker(),
|
||||
getPubKeyRing(dispute.getTraderPubKeyRing()), new Date(dispute.getTradeDate()), getContract(dispute.getContract()),
|
||||
PubKeyRing.fromProto(dispute.getTraderPubKeyRing()), new Date(dispute.getTradeDate()), getContract(dispute.getContract()),
|
||||
dispute.getContractHash().toByteArray(), dispute.getDepositTxSerialized().toByteArray(),
|
||||
dispute.getPayoutTxSerialized().toByteArray(),
|
||||
dispute.getDepositTxId(), dispute.getPayoutTxId(), dispute.getContractAsJson(), dispute.getMakerContractSignature(),
|
||||
dispute.getTakerContractSignature(), getPubKeyRing(dispute.getArbitratorPubKeyRing()), dispute.getIsSupportTicket());
|
||||
dispute.getTakerContractSignature(), PubKeyRing.fromProto(dispute.getArbitratorPubKeyRing()), dispute.getIsSupportTicket());
|
||||
}
|
||||
|
||||
private static Contract getContract(PB.Contract contract) {
|
||||
return new Contract(CoreNetworkProtoResolver.getOfferPayload(contract.getOfferPayload()),
|
||||
return new Contract(OfferPayload.fromProto(contract.getOfferPayload()),
|
||||
Coin.valueOf(contract.getTradeAmount()),
|
||||
Price.valueOf(getCurrencyCode(contract.getOfferPayload()), contract.getTradePrice()),
|
||||
contract.getTakerFeeTxId(),
|
||||
|
@ -71,20 +68,14 @@ public class ProtoUtil {
|
|||
contract.getTakerAccountId(),
|
||||
PaymentAccountPayload.fromProto(contract.getMakerPaymentAccountPayload()),
|
||||
PaymentAccountPayload.fromProto(contract.getTakerPaymentAccountPayload()),
|
||||
getPubKeyRing(contract.getMakerPubKeyRing()),
|
||||
getPubKeyRing(contract.getTakerPubKeyRing()),
|
||||
PubKeyRing.fromProto(contract.getMakerPubKeyRing()),
|
||||
PubKeyRing.fromProto(contract.getTakerPubKeyRing()),
|
||||
contract.getMakerPayoutAddressString(),
|
||||
contract.getTakerPayoutAddressString(),
|
||||
contract.getMakerBtcPubKey().toByteArray(),
|
||||
contract.getTakerBtcPubKey().toByteArray());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PubKeyRing getPubKeyRing(PB.PubKeyRing pubKeyRing) {
|
||||
return new PubKeyRing(pubKeyRing.getSignaturePubKeyBytes().toByteArray(),
|
||||
pubKeyRing.getEncryptionPubKeyBytes().toByteArray(),
|
||||
pubKeyRing.getPgpPubKeyAsPem());
|
||||
}
|
||||
|
||||
public static PaymentAccountFilter getPaymentAccountFilter(PB.PaymentAccountFilter accountFilter) {
|
||||
return new PaymentAccountFilter(accountFilter.getPaymentMethodId(), accountFilter.getGetMethodName(),
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bisq.core.trade;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
|
@ -24,6 +25,7 @@ import io.bisq.core.offer.Offer;
|
|||
import io.bisq.core.trade.messages.TradeMsg;
|
||||
import io.bisq.core.trade.protocol.BuyerAsMakerProtocol;
|
||||
import io.bisq.core.trade.protocol.MakerProtocol;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -62,4 +64,19 @@ public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade {
|
|||
public void handleTakeOfferRequest(TradeMsg message, NodeAddress taker) {
|
||||
((MakerProtocol) tradeProtocol).handleTakeOfferRequest(message, taker);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public PB.Tradable toProto() {
|
||||
return PB.Tradable.newBuilder().setBuyerAsMakerTrade(PB.BuyerAsMakerTrade.newBuilder().setTrade(super.toProto())).build();
|
||||
}
|
||||
|
||||
public static Tradable fromProto(PB.BuyerAsMakerTrade proto, Storage<? extends TradableList> storage) {
|
||||
return new BuyerAsMakerTrade(Offer.fromProto(proto.getTrade().getOffer()),
|
||||
Coin.valueOf(proto.getTrade().getTxFee().getValue()),
|
||||
Coin.valueOf(proto.getTrade().getTakeOffer().getValue()),
|
||||
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bisq.core.trade;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
|
@ -67,4 +68,14 @@ public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade {
|
|||
checkArgument(tradeProtocol instanceof TakerProtocol, "tradeProtocol NOT instanceof TakerProtocol");
|
||||
((TakerProtocol) tradeProtocol).takeAvailableOffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Tradable fromProto() {
|
||||
// reset State (see readObject)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,19 +17,23 @@
|
|||
|
||||
package io.bisq.core.trade;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.common.storage.Storage;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import lombok.Getter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class TradableList<T extends Tradable> extends ArrayList<T> implements Persistable {
|
||||
public final class TradableList<T extends Tradable> implements Persistable {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -39,6 +43,9 @@ public final class TradableList<T extends Tradable> extends ArrayList<T> impleme
|
|||
// Use getObservableList() also class locally, to be sure that object exists in case we use the object as deserialized form
|
||||
transient private ObservableList<T> observableList;
|
||||
|
||||
@Getter
|
||||
private List<T> list = new ArrayList<>();
|
||||
|
||||
// Superclass is ArrayList, which will be persisted
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -50,41 +57,48 @@ public final class TradableList<T extends Tradable> extends ArrayList<T> impleme
|
|||
|
||||
TradableList<T> persisted = storage.initAndGetPersisted(this, fileName);
|
||||
if (persisted != null) {
|
||||
this.addAll(persisted);
|
||||
list.addAll(persisted.getList());
|
||||
}
|
||||
observableList = FXCollections.observableArrayList(this);
|
||||
observableList = FXCollections.observableArrayList(list);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
in.defaultReadObject();
|
||||
} catch (Throwable t) {
|
||||
log.warn("Cannot be deserialized." + t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T tradable) {
|
||||
boolean changed = super.add(tradable);
|
||||
boolean changed = list.add(tradable);
|
||||
getObservableList().add(tradable);
|
||||
if (changed)
|
||||
storage.queueUpForSave();
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object tradable) {
|
||||
boolean changed = super.remove(tradable);
|
||||
boolean changed = list.remove(tradable);
|
||||
getObservableList().remove(tradable);
|
||||
if (changed)
|
||||
storage.queueUpForSave();
|
||||
return changed;
|
||||
}
|
||||
|
||||
public Stream<T> stream() {
|
||||
return list.stream();
|
||||
}
|
||||
|
||||
public void forEach(Consumer<? super T> action) {
|
||||
list.forEach(action);
|
||||
}
|
||||
|
||||
|
||||
public ObservableList<T> getObservableList() {
|
||||
if (observableList == null)
|
||||
observableList = FXCollections.observableArrayList(this);
|
||||
observableList = FXCollections.observableArrayList(list);
|
||||
return observableList;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public boolean contains(T thing) {
|
||||
return list.contains(thing);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.app.Log;
|
||||
import io.bisq.common.app.Version;
|
||||
|
@ -40,6 +41,7 @@ import io.bisq.core.offer.OpenOfferManager;
|
|||
import io.bisq.core.trade.protocol.ProcessModel;
|
||||
import io.bisq.core.trade.protocol.TradeProtocol;
|
||||
import io.bisq.core.user.User;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.DecryptedMsgWithPubKey;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import io.bisq.network.p2p.P2PService;
|
||||
|
@ -70,13 +72,13 @@ public abstract class Trade implements Tradable, Model {
|
|||
private static final Logger log = LoggerFactory.getLogger(Trade.class);
|
||||
|
||||
public enum State {
|
||||
// #################### Phase PREPARATION
|
||||
// #################### Phase PREPARATION
|
||||
// When trade protocol starts no funds are on stake
|
||||
PREPARATION(Phase.PREPARATION),
|
||||
|
||||
// At first part maker/taker have different roles
|
||||
// taker perspective
|
||||
// #################### Phase TAKER_FEE_PAID
|
||||
// #################### Phase TAKER_FEE_PAID
|
||||
TAKER_PUBLISHED_TAKER_FEE_TX(Phase.TAKER_FEE_PUBLISHED),
|
||||
|
||||
// PUBLISH_DEPOSIT_TX_REQUEST
|
||||
|
@ -90,7 +92,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
TAKER_RECEIVED_PUBLISH_DEPOSIT_TX_REQUEST(Phase.TAKER_FEE_PUBLISHED),
|
||||
|
||||
|
||||
// #################### Phase DEPOSIT_PAID
|
||||
// #################### Phase DEPOSIT_PAID
|
||||
TAKER_PUBLISHED_DEPOSIT_TX(Phase.DEPOSIT_PUBLISHED),
|
||||
|
||||
|
||||
|
@ -488,7 +490,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
public void setTakeOfferDate(Date takeOfferDate) {
|
||||
this.takeOfferDate = takeOfferDate.getTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Model implementation
|
||||
|
@ -828,6 +830,22 @@ public abstract class Trade implements Tradable, Model {
|
|||
setState(State.DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return PB.Trade.newBuilder()
|
||||
.setOffer(offer.toProto())
|
||||
.setProcessModel(processModel.toproto())
|
||||
.setTakerFeeTxId(takerFeeTxId)
|
||||
.setDepositTxId(depositTxId)
|
||||
.setPayoutTxId(payoutTxId)
|
||||
.setTradeAmountAsLong(tradeAmountAsLong)
|
||||
.setTxFeeAsLong(txFeeAsLong)
|
||||
.setTakerFeeAsLong(takerFeeAsLong)
|
||||
.setDecryptedMsgWithPubKey((PB.DecryptedMsgWithPubKey) decryptedMsgWithPubKey.toProto())
|
||||
;
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Trade{" +
|
||||
|
@ -857,4 +875,4 @@ public abstract class Trade implements Tradable, Model {
|
|||
"\n\terrorMessage='" + errorMessage + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import io.bisq.core.btc.wallet.BtcWalletService;
|
|||
import io.bisq.core.btc.wallet.TradeWalletService;
|
||||
import io.bisq.core.filter.FilterManager;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.offer.OpenOffer;
|
||||
import io.bisq.core.offer.OpenOfferManager;
|
||||
import io.bisq.core.offer.availability.OfferAvailabilityModel;
|
||||
|
@ -133,7 +134,7 @@ public class TradeManager {
|
|||
trade.setTransientFields(tradableListStorage, btcWalletService);
|
||||
trade.getOffer().setPriceFeedService(priceFeedService);
|
||||
});
|
||||
|
||||
|
||||
p2PService.addDecryptedDirectMessageListener(new DecryptedDirectMessageListener() {
|
||||
@Override
|
||||
public void onDirectMessage(DecryptedMsgWithPubKey decryptedMsgWithPubKey, NodeAddress peerNodeAddress) {
|
||||
|
@ -194,19 +195,20 @@ public class TradeManager {
|
|||
List<Trade> addTradeToFailedTradesList = new ArrayList<>();
|
||||
List<Trade> removePreparedTradeList = new ArrayList<>();
|
||||
tradesForStatistics = new ArrayList<>();
|
||||
for (Trade trade : trades) {
|
||||
if (trade.isDepositPublished() ||
|
||||
(trade.isTakerFeePublished() && !trade.hasFailed())) {
|
||||
initTrade(trade, trade.getProcessModel().isUseSavingsWallet(),
|
||||
trade.getProcessModel().getFundsNeededForTradeAsLong());
|
||||
trade.updateDepositTxFromWallet();
|
||||
tradesForStatistics.add(trade);
|
||||
} else if (trade.isTakerFeePublished()) {
|
||||
addTradeToFailedTradesList.add(trade);
|
||||
} else {
|
||||
removePreparedTradeList.add(trade);
|
||||
}
|
||||
}
|
||||
trades.forEach(trade -> {
|
||||
if (trade.isDepositPublished() ||
|
||||
(trade.isTakerFeePublished() && !trade.hasFailed())) {
|
||||
initTrade(trade, trade.getProcessModel().isUseSavingsWallet(),
|
||||
trade.getProcessModel().getFundsNeededForTradeAsLong());
|
||||
trade.updateDepositTxFromWallet();
|
||||
tradesForStatistics.add(trade);
|
||||
} else if (trade.isTakerFeePublished()) {
|
||||
addTradeToFailedTradesList.add(trade);
|
||||
} else {
|
||||
removePreparedTradeList.add(trade);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
for (Trade trade : addTradeToFailedTradesList)
|
||||
addTradeToFailedTrades(trade);
|
||||
|
@ -507,11 +509,11 @@ public class TradeManager {
|
|||
}
|
||||
|
||||
public boolean isBuyer(Offer offer) {
|
||||
// If I am the maker, we use the offer direction, otherwise the mirrored direction
|
||||
// If I am the maker, we use the OfferPayload.Direction, otherwise the mirrored direction
|
||||
if (isMyOffer(offer))
|
||||
return offer.isBuyOffer();
|
||||
else
|
||||
return offer.getDirection() == Offer.Direction.SELL;
|
||||
return offer.getDirection() == OfferPayload.Direction.SELL;
|
||||
}
|
||||
|
||||
public Optional<Trade> getTradeById(String tradeId) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class DepositTxPublishedMsg extends TradeMsg implements MailboxMsg
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setDepositTxPublishedMessage(PB.DepositTxPublishedMessage.newBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class FiatTransferStartedMsg extends TradeMsg implements MailboxMsg
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setFiatTransferStartedMessage(baseEnvelope.getFiatTransferStartedMessageBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class FinalizePayoutTxRequest extends TradeMsg implements MailboxMs
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setFinalizePayoutTxRequest(PB.FinalizePayoutTxRequest.newBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
|
|
|
@ -105,7 +105,7 @@ public final class PayDepositRequest extends TradeMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
PB.PayDepositRequest.Builder builderForValue = PB.PayDepositRequest.newBuilder()
|
||||
.setTradeId(tradeId)
|
||||
|
|
|
@ -55,7 +55,7 @@ public final class PayoutTxPublishedMsg extends TradeMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPayoutTxPublishedMessage(baseEnvelope.getPayoutTxPublishedMessageBuilder()
|
||||
.setUid(uid)
|
||||
|
|
|
@ -38,8 +38,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Immutable
|
||||
// We use a MailboxMessage here because the taker has paid already the trade fee and it could be that
|
||||
// we lost connection to him but we are complete on our side. So even if the peer is offline he can
|
||||
// We use a MailboxMessage here because the taker has paid already the trade fee and it could be that
|
||||
// we lost connection to him but we are complete on our side. So even if the peer is offline he can
|
||||
// continue later to complete the deposit tx.
|
||||
public final class PublishDepositTxRequest extends TradeMsg implements MailboxMsg {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
|
@ -88,7 +88,7 @@ public final class PublishDepositTxRequest extends TradeMsg implements MailboxMs
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPublishDepositTxRequest(baseEnvelope.getPublishDepositTxRequestBuilder()
|
||||
.setMessageVersion(getMessageVersion())
|
||||
|
|
|
@ -4,7 +4,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -16,7 +16,7 @@ public final class TradeStatisticsForJson {
|
|||
private static final Logger log = LoggerFactory.getLogger(TradeStatisticsForJson.class);
|
||||
|
||||
public final String currency;
|
||||
public final Offer.Direction direction;
|
||||
public final OfferPayload.Direction direction;
|
||||
public final long tradePrice;
|
||||
public final long tradeAmount;
|
||||
public final long tradeDate;
|
||||
|
@ -31,7 +31,7 @@ public final class TradeStatisticsForJson {
|
|||
|
||||
// primaryMarket fields are based on industry standard where primaryMarket is always in the focus (in the app BTC is always in the focus - will be changed in a larger refactoring once)
|
||||
public String currencyPair;
|
||||
public Offer.Direction primaryMarketDirection;
|
||||
public OfferPayload.Direction primaryMarketDirection;
|
||||
|
||||
public long primaryMarketTradePrice;
|
||||
public long primaryMarketTradeAmount;
|
||||
|
@ -39,7 +39,7 @@ public final class TradeStatisticsForJson {
|
|||
|
||||
|
||||
public TradeStatisticsForJson(TradeStatistics tradeStatistics) {
|
||||
this.direction = Offer.Direction.valueOf(tradeStatistics.direction.name());
|
||||
this.direction = OfferPayload.Direction.valueOf(tradeStatistics.direction.name());
|
||||
this.currency = tradeStatistics.getCurrencyCode();
|
||||
this.paymentMethod = tradeStatistics.paymentMethodId;
|
||||
this.offerDate = tradeStatistics.offerDate;
|
||||
|
@ -57,7 +57,7 @@ public final class TradeStatisticsForJson {
|
|||
try {
|
||||
final Price tradePrice = getTradePrice();
|
||||
if (CurrencyUtil.isCryptoCurrency(currency)) {
|
||||
primaryMarketDirection = direction == Offer.Direction.BUY ? Offer.Direction.SELL : Offer.Direction.BUY;
|
||||
primaryMarketDirection = direction == OfferPayload.Direction.BUY ? OfferPayload.Direction.SELL : OfferPayload.Direction.BUY;
|
||||
currencyPair = currency + "/" + "BTC";
|
||||
|
||||
primaryMarketTradePrice = tradePrice.getValue();
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.util.Tuple4;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.gui.Navigation;
|
||||
import io.bisq.gui.common.view.ActivatableViewAndModel;
|
||||
import io.bisq.gui.common.view.FxmlView;
|
||||
|
@ -120,8 +121,8 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
|
||||
createChart();
|
||||
|
||||
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(Offer.Direction.BUY);
|
||||
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(Offer.Direction.SELL);
|
||||
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferPayload.Direction.BUY);
|
||||
Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferPayload.Direction.SELL);
|
||||
buyOfferTableView = tupleBuy.first;
|
||||
sellOfferTableView = tupleSell.first;
|
||||
|
||||
|
@ -136,8 +137,8 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
bottomHBox.setAlignment(Pos.CENTER);
|
||||
HBox.setHgrow(tupleBuy.second, Priority.ALWAYS);
|
||||
HBox.setHgrow(tupleSell.second, Priority.ALWAYS);
|
||||
tupleBuy.second.setUserData(Offer.Direction.BUY.name());
|
||||
tupleSell.second.setUserData(Offer.Direction.SELL.name());
|
||||
tupleBuy.second.setUserData(OfferPayload.Direction.BUY.name());
|
||||
tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
|
||||
bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);
|
||||
|
||||
root.getChildren().addAll(currencyHBox, areaChart, bottomHBox);
|
||||
|
@ -196,7 +197,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
});
|
||||
|
||||
if (CurrencyUtil.isCryptoCurrency(code)) {
|
||||
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(Offer.Direction.BUY.name())) {
|
||||
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferPayload.Direction.BUY.name())) {
|
||||
bottomHBox.getChildren().get(0).toFront();
|
||||
reverseTableColumns();
|
||||
}
|
||||
|
@ -209,7 +210,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
|
||||
priceColumnLabel.set(Res.get("shared.priceWithCur", "BTC"));
|
||||
} else {
|
||||
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(Offer.Direction.SELL.name())) {
|
||||
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals(OfferPayload.Direction.SELL.name())) {
|
||||
bottomHBox.getChildren().get(0).toFront();
|
||||
reverseTableColumns();
|
||||
}
|
||||
|
@ -219,7 +220,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
|
||||
rightHeaderLabel.setText(Res.get("market.offerBook.leftHeaderLabel", "BTC", code));
|
||||
rightButton.setText(Res.get("market.offerBook.leftButtonFiat", "BTC", code));
|
||||
|
||||
|
||||
priceColumnLabel.set(Res.get("shared.priceWithCur", code));
|
||||
}
|
||||
xAxis.setLabel(formatter.getPriceWithCurrencyCode(code));
|
||||
|
@ -287,7 +288,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
seriesSell.getData().addAll(model.getSellData());
|
||||
}
|
||||
|
||||
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(Offer.Direction direction) {
|
||||
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) {
|
||||
TableView<OfferListItem> tableView = new TableView<>();
|
||||
tableView.setMinHeight(109);
|
||||
tableView.setPrefHeight(121);
|
||||
|
@ -427,7 +428,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
}
|
||||
});
|
||||
|
||||
if (direction == Offer.Direction.BUY) {
|
||||
if (direction == OfferPayload.Direction.BUY) {
|
||||
tableView.getColumns().add(accumulatedColumn);
|
||||
tableView.getColumns().add(volumeColumn);
|
||||
tableView.getColumns().add(amountColumn);
|
||||
|
@ -448,7 +449,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
|||
titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
|
||||
UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
|
||||
|
||||
boolean isSellOffer = direction == Offer.Direction.SELL;
|
||||
boolean isSellOffer = direction == OfferPayload.Direction.SELL;
|
||||
Button button = new Button();
|
||||
ImageView iconView = new ImageView();
|
||||
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.locale.TradeCurrency;
|
||||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.provider.price.PriceFeedService;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.gui.Navigation;
|
||||
|
@ -240,7 +241,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
List<Offer> allBuyOffers = offerBookListItems.stream()
|
||||
.map(OfferBookListItem::getOffer)
|
||||
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
|
||||
&& e.getDirection().equals(Offer.Direction.BUY))
|
||||
&& e.getDirection().equals(OfferPayload.Direction.BUY))
|
||||
.sorted((o1, o2) -> {
|
||||
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
|
||||
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;
|
||||
|
@ -251,12 +252,12 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
.collect(Collectors.toList());
|
||||
|
||||
allBuyOffers = filterOffersWithRelevantPrices(allBuyOffers);
|
||||
buildChartAndTableEntries(allBuyOffers, Offer.Direction.BUY, buyData, topBuyOfferList);
|
||||
buildChartAndTableEntries(allBuyOffers, OfferPayload.Direction.BUY, buyData, topBuyOfferList);
|
||||
|
||||
List<Offer> allSellOffers = offerBookListItems.stream()
|
||||
.map(OfferBookListItem::getOffer)
|
||||
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
|
||||
&& e.getDirection().equals(Offer.Direction.SELL))
|
||||
&& e.getDirection().equals(OfferPayload.Direction.SELL))
|
||||
.sorted((o1, o2) -> {
|
||||
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
|
||||
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;
|
||||
|
@ -267,7 +268,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
.collect(Collectors.toList());
|
||||
|
||||
allSellOffers = filterOffersWithRelevantPrices(allSellOffers);
|
||||
buildChartAndTableEntries(allSellOffers, Offer.Direction.SELL, sellData, topSellOfferList);
|
||||
buildChartAndTableEntries(allSellOffers, OfferPayload.Direction.SELL, sellData, topSellOfferList);
|
||||
}
|
||||
|
||||
// If there are more then 3 offers we ignore the offers which are further than 30% from the best price
|
||||
|
@ -290,7 +291,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
return offers;
|
||||
}
|
||||
|
||||
private void buildChartAndTableEntries(List<Offer> sortedList, Offer.Direction direction, List<XYChart.Data> data, ObservableList<OfferListItem> offerTableList) {
|
||||
private void buildChartAndTableEntries(List<Offer> sortedList, OfferPayload.Direction direction, List<XYChart.Data> data, ObservableList<OfferListItem> offerTableList) {
|
||||
data.clear();
|
||||
double accumulatedAmount = 0;
|
||||
List<OfferListItem> offerTableListTemp = new ArrayList<>();
|
||||
|
@ -303,12 +304,12 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
|
||||
double priceAsDouble = (double) price.getValue() / LongMath.pow(10, price.smallestUnitExponent());
|
||||
if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) {
|
||||
if (direction.equals(Offer.Direction.SELL))
|
||||
if (direction.equals(OfferPayload.Direction.SELL))
|
||||
data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount));
|
||||
else
|
||||
data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount));
|
||||
} else {
|
||||
if (direction.equals(Offer.Direction.BUY))
|
||||
if (direction.equals(OfferPayload.Direction.BUY))
|
||||
data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount));
|
||||
else
|
||||
data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount));
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.monetary.Altcoin;
|
||||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.provider.price.MarketPrice;
|
||||
import io.bisq.core.provider.price.PriceFeedService;
|
||||
import io.bisq.gui.common.model.ActivatableViewModel;
|
||||
|
@ -94,7 +95,7 @@ class SpreadViewModel extends ActivatableViewModel {
|
|||
final boolean isFiatCurrency = CurrencyUtil.isFiatCurrency(currencyCode);
|
||||
List<Offer> buyOffers = offers
|
||||
.stream()
|
||||
.filter(e -> e.getDirection().equals(Offer.Direction.BUY))
|
||||
.filter(e -> e.getDirection().equals(OfferPayload.Direction.BUY))
|
||||
.sorted((o1, o2) -> {
|
||||
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
|
||||
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;
|
||||
|
@ -111,7 +112,7 @@ class SpreadViewModel extends ActivatableViewModel {
|
|||
|
||||
List<Offer> sellOffers = offers
|
||||
.stream()
|
||||
.filter(e -> e.getDirection().equals(Offer.Direction.SELL))
|
||||
.filter(e -> e.getDirection().equals(OfferPayload.Direction.SELL))
|
||||
.sorted((o1, o2) -> {
|
||||
long a = o1.getPrice() != null ? o1.getPrice().getValue() : 0;
|
||||
long b = o2.getPrice() != null ? o2.getPrice().getValue() : 0;
|
||||
|
|
|
@ -23,7 +23,7 @@ import io.bisq.common.locale.Res;
|
|||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.trade.statistics.TradeStatistics;
|
||||
import io.bisq.gui.common.view.ActivatableViewAndModel;
|
||||
import io.bisq.gui.common.view.FxmlView;
|
||||
|
@ -358,7 +358,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
private void updateChartData() {
|
||||
volumeSeries.getData().setAll(model.volumeItems);
|
||||
|
||||
// At price chart we need to set the priceSeries new otherwise the lines are not rendered correctly
|
||||
// At price chart we need to set the priceSeries new otherwise the lines are not rendered correctly
|
||||
// TODO should be fixed in candle chart
|
||||
priceSeries.getData().clear();
|
||||
priceSeries = new XYChart.Series<>();
|
||||
|
@ -648,7 +648,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
|
||||
@NotNull
|
||||
private String getDirectionLabel(TradeStatistics item) {
|
||||
return formatter.getDirectionWithCode(Offer.Direction.valueOf(item.direction.name()), item.getCurrencyCode());
|
||||
return formatter.getDirectionWithCode(OfferPayload.Direction.valueOf(item.direction.name()), item.getCurrencyCode());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.bisq.common.locale.CurrencyUtil;
|
|||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.common.locale.TradeCurrency;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.user.Preferences;
|
||||
import io.bisq.gui.Navigation;
|
||||
import io.bisq.gui.common.view.ActivatableView;
|
||||
|
@ -54,7 +55,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
private final ViewLoader viewLoader;
|
||||
private final Navigation navigation;
|
||||
private final Preferences preferences;
|
||||
private final Offer.Direction direction;
|
||||
private final OfferPayload.Direction direction;
|
||||
|
||||
private Offer offer;
|
||||
private TradeCurrency tradeCurrency;
|
||||
|
@ -67,7 +68,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
this.viewLoader = viewLoader;
|
||||
this.navigation = navigation;
|
||||
this.preferences = preferences;
|
||||
this.direction = (this instanceof BuyOfferView) ? Offer.Direction.BUY : Offer.Direction.SELL;
|
||||
this.direction = (this instanceof BuyOfferView) ? OfferPayload.Direction.BUY : OfferPayload.Direction.SELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -144,7 +145,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
private void loadView(Class<? extends View> viewClass) {
|
||||
TabPane tabPane = root;
|
||||
View view;
|
||||
boolean isBuy = direction == Offer.Direction.BUY;
|
||||
boolean isBuy = direction == OfferPayload.Direction.BUY;
|
||||
|
||||
if (viewClass == OfferBookView.class && offerBookView == null) {
|
||||
view = viewLoader.load(viewClass);
|
||||
|
|
|
@ -88,7 +88,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
private final BsqBalanceListener bsqBalanceListener;
|
||||
private final SetChangeListener<PaymentAccount> paymentAccountsChangeListener;
|
||||
|
||||
private Offer.Direction direction;
|
||||
private OfferPayload.Direction direction;
|
||||
|
||||
private TradeCurrency tradeCurrency;
|
||||
|
||||
|
@ -235,7 +235,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// called before activate()
|
||||
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
|
||||
this.direction = direction;
|
||||
|
||||
fillPaymentAccounts();
|
||||
|
@ -493,7 +493,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
return true;
|
||||
}
|
||||
|
||||
Offer.Direction getDirection() {
|
||||
OfferPayload.Direction getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
boolean isBuyOffer() {
|
||||
return direction == Offer.Direction.BUY;
|
||||
return direction == OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
private void updateBalance() {
|
||||
|
@ -731,7 +731,7 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
|||
this.minAmount.set(minAmount);
|
||||
}
|
||||
|
||||
void setDirection(Offer.Direction direction) {
|
||||
void setDirection(OfferPayload.Direction direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.bisq.common.util.Tuple2;
|
|||
import io.bisq.common.util.Tuple3;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.user.DontShowAgainLookup;
|
||||
|
@ -238,7 +239,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
|||
model.dataModel.onTabSelected(isSelected);
|
||||
}
|
||||
|
||||
public void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
public void initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean result = model.initWithData(direction, tradeCurrency);
|
||||
|
||||
if (!result) {
|
||||
|
@ -251,7 +252,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
|||
}).show();
|
||||
}
|
||||
|
||||
if (direction == Offer.Direction.BUY) {
|
||||
if (direction == OfferPayload.Direction.BUY) {
|
||||
imageView.setId("image-buy-large");
|
||||
|
||||
placeOfferButton.setId("buy-button-big");
|
||||
|
|
|
@ -29,6 +29,7 @@ import io.bisq.common.monetary.Volume;
|
|||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.core.btc.Restrictions;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.provider.price.MarketPrice;
|
||||
import io.bisq.core.provider.price.PriceFeedService;
|
||||
|
@ -225,7 +226,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
}
|
||||
|
||||
private void addBindings() {
|
||||
if (dataModel.getDirection() == Offer.Direction.BUY) {
|
||||
if (dataModel.getDirection() == OfferPayload.Direction.BUY) {
|
||||
volumeDescriptionLabel.bind(createStringBinding(
|
||||
() -> Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getTradeCurrencyCode().get()),
|
||||
dataModel.getTradeCurrencyCode()));
|
||||
|
@ -290,9 +291,9 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
try {
|
||||
double priceAsDouble = btcFormatter.parseNumberStringToDouble(price.get());
|
||||
double relation = priceAsDouble / marketPriceAsDouble;
|
||||
final Offer.Direction compareDirection = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
Offer.Direction.SELL :
|
||||
Offer.Direction.BUY;
|
||||
final OfferPayload.Direction compareDirection = CurrencyUtil.isCryptoCurrency(currencyCode) ?
|
||||
OfferPayload.Direction.SELL :
|
||||
OfferPayload.Direction.BUY;
|
||||
double percentage = dataModel.getDirection() == compareDirection ? 1 - relation : relation - 1;
|
||||
percentage = MathUtils.roundDouble(percentage, 4);
|
||||
dataModel.setMarketPriceMargin(percentage);
|
||||
|
@ -328,9 +329,9 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
dataModel.updateTradeFee();
|
||||
double marketPriceAsDouble = marketPrice.getPrice();
|
||||
final boolean isCryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
|
||||
final Offer.Direction compareDirection = isCryptoCurrency ?
|
||||
Offer.Direction.SELL :
|
||||
Offer.Direction.BUY;
|
||||
final OfferPayload.Direction compareDirection = isCryptoCurrency ?
|
||||
OfferPayload.Direction.SELL :
|
||||
OfferPayload.Direction.BUY;
|
||||
double factor = dataModel.getDirection() == compareDirection ?
|
||||
1 - percentage :
|
||||
1 + percentage;
|
||||
|
@ -504,12 +505,12 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean initWithData(OfferPayload.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean result = dataModel.initWithData(direction, tradeCurrency);
|
||||
if (dataModel.paymentAccount != null)
|
||||
btcValidator.setMaxValue(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimitAsCoin());
|
||||
|
||||
final boolean isBuy = dataModel.getDirection() == Offer.Direction.BUY;
|
||||
final boolean isBuy = dataModel.getDirection() == OfferPayload.Direction.BUY;
|
||||
directionLabel = isBuy ? Res.get("shared.buyBitcoin") : Res.get("shared.sellBitcoin");
|
||||
amountDescription = Res.get("createOffer.amountPriceBox.amountDescription",
|
||||
isBuy ? Res.get("shared.buy") : Res.get("shared.sell"));
|
||||
|
@ -782,7 +783,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
|||
}
|
||||
|
||||
boolean isSellOffer() {
|
||||
return dataModel.getDirection() == Offer.Direction.SELL;
|
||||
return dataModel.getDirection() == OfferPayload.Direction.SELL;
|
||||
}
|
||||
|
||||
public TradeCurrency getTradeCurrency() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import io.bisq.common.monetary.Price;
|
|||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.core.alert.PrivateNotificationManager;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.user.DontShowAgainLookup;
|
||||
import io.bisq.gui.Navigation;
|
||||
|
@ -281,13 +282,13 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
createOfferButton.setDisable(false);
|
||||
}
|
||||
|
||||
public void setDirection(Offer.Direction direction) {
|
||||
public void setDirection(OfferPayload.Direction direction) {
|
||||
model.initWithDirection(direction);
|
||||
ImageView iconView = new ImageView();
|
||||
|
||||
createOfferButton.setGraphic(iconView);
|
||||
iconView.setId(direction == Offer.Direction.SELL ? "image-sell-white" : "image-buy-white");
|
||||
createOfferButton.setId(direction == Offer.Direction.SELL ? "sell-button-big" : "buy-button-big");
|
||||
iconView.setId(direction == OfferPayload.Direction.SELL ? "image-sell-white" : "image-buy-white");
|
||||
createOfferButton.setId(direction == OfferPayload.Direction.SELL ? "sell-button-big" : "buy-button-big");
|
||||
|
||||
setDirectionTitles();
|
||||
}
|
||||
|
@ -295,15 +296,15 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
private void setDirectionTitles() {
|
||||
TradeCurrency selectedTradeCurrency = model.getSelectedTradeCurrency();
|
||||
if (selectedTradeCurrency != null) {
|
||||
Offer.Direction direction = model.getDirection();
|
||||
String directionText = direction == Offer.Direction.BUY ? Res.get("shared.buy") : Res.get("shared.sell");
|
||||
String mirroredDirectionText = direction == Offer.Direction.SELL ? Res.get("shared.buy") : Res.get("shared.sell");
|
||||
OfferPayload.Direction direction = model.getDirection();
|
||||
String directionText = direction == OfferPayload.Direction.BUY ? Res.get("shared.buy") : Res.get("shared.sell");
|
||||
String mirroredDirectionText = direction == OfferPayload.Direction.SELL ? Res.get("shared.buy") : Res.get("shared.sell");
|
||||
String code = selectedTradeCurrency.getCode();
|
||||
if (model.showAllTradeCurrenciesProperty.get())
|
||||
createOfferButton.setText(Res.get("offerbook.createOfferTo", directionText, "BTC"));
|
||||
else if (selectedTradeCurrency instanceof FiatCurrency)
|
||||
createOfferButton.setText(Res.get("offerbook.createOfferTo", directionText, "BTC") + " " +
|
||||
(direction == Offer.Direction.BUY ?
|
||||
(direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("offerbook.buyWithOtherCurrency", code) :
|
||||
Res.get("offerbook.sellForOtherCurrency", code)));
|
||||
else
|
||||
|
@ -704,7 +705,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
button.setStyle("-fx-text-fill: #444;"); // does not take the font colors sometimes from the style
|
||||
button.setOnAction(e -> onRemoveOpenOffer(offer));
|
||||
} else {
|
||||
boolean isSellOffer = offer.getDirection() == Offer.Direction.SELL;
|
||||
boolean isSellOffer = offer.getDirection() == OfferPayload.Direction.SELL;
|
||||
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
|
||||
button.setId(isSellOffer ? "buy-button" : "sell-button");
|
||||
button.setStyle("-fx-text-fill: white;"); // does not take the font colors sometimes from the style
|
||||
|
|
|
@ -28,6 +28,7 @@ import io.bisq.common.monetary.Price;
|
|||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.core.filter.FilterManager;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.offer.OpenOfferManager;
|
||||
import io.bisq.core.payment.PaymentAccountUtil;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
|
@ -84,7 +85,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
private TradeCurrency selectedTradeCurrency;
|
||||
private final ObservableList<TradeCurrency> allTradeCurrencies = FXCollections.observableArrayList();
|
||||
|
||||
private Offer.Direction direction;
|
||||
private OfferPayload.Direction direction;
|
||||
|
||||
private final StringProperty btcCode = new SimpleStringProperty();
|
||||
final StringProperty tradeCurrencyCode = new SimpleStringProperty();
|
||||
|
@ -137,7 +138,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
tradeCurrencyCodes = preferences.getTradeCurrenciesAsObservable().stream()
|
||||
.map(TradeCurrency::getCode).collect(Collectors.toSet());
|
||||
|
||||
String code = direction == Offer.Direction.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
|
||||
String code = direction == OfferPayload.Direction.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
|
||||
if (code != null && !code.equals(GUIUtil.SHOW_ALL_FLAG) && !code.isEmpty() &&
|
||||
CurrencyUtil.getTradeCurrency(code).isPresent()) {
|
||||
showAllTradeCurrenciesProperty.set(false);
|
||||
|
@ -169,7 +170,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void initWithDirection(Offer.Direction direction) {
|
||||
void initWithDirection(OfferPayload.Direction direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
|
@ -199,7 +200,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
setMarketPriceFeedCurrency();
|
||||
applyFilterPredicate();
|
||||
|
||||
if (direction == Offer.Direction.BUY)
|
||||
if (direction == OfferPayload.Direction.BUY)
|
||||
preferences.setBuyScreenCurrencyCode(code);
|
||||
else
|
||||
preferences.setSellScreenCurrencyCode(code);
|
||||
|
@ -207,9 +208,9 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
}
|
||||
|
||||
private void applyPriceSortTypeProperty(String code) {
|
||||
final Offer.Direction compareDirection = CurrencyUtil.isCryptoCurrency(code) ?
|
||||
Offer.Direction.SELL :
|
||||
Offer.Direction.BUY;
|
||||
final OfferPayload.Direction compareDirection = CurrencyUtil.isCryptoCurrency(code) ?
|
||||
OfferPayload.Direction.SELL :
|
||||
OfferPayload.Direction.BUY;
|
||||
priceSortTypeProperty.set(getDirection() == compareDirection ?
|
||||
TableColumn.SortType.ASCENDING :
|
||||
TableColumn.SortType.DESCENDING);
|
||||
|
@ -240,7 +241,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
return openOfferManager.isMyOffer(offer);
|
||||
}
|
||||
|
||||
Offer.Direction getDirection() {
|
||||
OfferPayload.Direction getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.bisq.core.btc.AddressEntry;
|
|||
import io.bisq.core.btc.listeners.BalanceListener;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.PaymentAccountUtil;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
|
@ -167,7 +168,7 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
if (DevEnv.DEV_MODE)
|
||||
amount.set(offer.getAmount());
|
||||
|
||||
securityDeposit = offer.getDirection() == Offer.Direction.SELL ?
|
||||
securityDeposit = offer.getDirection() == OfferPayload.Direction.SELL ?
|
||||
getBuyerSecurityDeposit() :
|
||||
getSellerSecurityDeposit();
|
||||
|
||||
|
@ -307,7 +308,7 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Offer.Direction getDirection() {
|
||||
OfferPayload.Direction getDirection() {
|
||||
return offer.getDirection();
|
||||
}
|
||||
|
||||
|
@ -389,7 +390,7 @@ class TakeOfferDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
private boolean isBuyOffer() {
|
||||
return getDirection() == Offer.Direction.BUY;
|
||||
return getDirection() == OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
void updateTradeFee() {
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.bisq.common.util.Tuple2;
|
|||
import io.bisq.common.util.Tuple3;
|
||||
import io.bisq.common.util.Utilities;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.user.DontShowAgainLookup;
|
||||
|
@ -234,7 +235,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
|
|||
model.initWithData(offer);
|
||||
priceAsPercentageInputBox.setVisible(offer.isUseMarketBasedPrice());
|
||||
|
||||
if (model.getOffer().getDirection() == Offer.Direction.SELL) {
|
||||
if (model.getOffer().getDirection() == OfferPayload.Direction.SELL) {
|
||||
imageView.setId("image-buy-large");
|
||||
directionLabel.setId("direction-icon-label-buy");
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package io.bisq.gui.main.offer.takeoffer;
|
|||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.trade.Trade;
|
||||
|
@ -401,7 +402,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
private void addBindings() {
|
||||
volume.bind(createStringBinding(() -> btcFormatter.formatVolume(dataModel.volume.get()), dataModel.volume));
|
||||
|
||||
if (dataModel.getDirection() == Offer.Direction.SELL) {
|
||||
if (dataModel.getDirection() == OfferPayload.Direction.SELL) {
|
||||
volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getCurrencyCode()));
|
||||
} else {
|
||||
volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.sell.volumeDescription", dataModel.getCurrencyCode()));
|
||||
|
@ -537,7 +538,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
}
|
||||
|
||||
boolean isSeller() {
|
||||
return dataModel.getDirection() == Offer.Direction.BUY;
|
||||
return dataModel.getDirection() == OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
private InputValidator.ValidationResult isBtcInputValid(String input) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import io.bisq.common.locale.Res;
|
|||
import io.bisq.common.monetary.Price;
|
||||
import io.bisq.common.util.Tuple3;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.PaymentAccount;
|
||||
import io.bisq.core.payment.payload.PaymentMethod;
|
||||
import io.bisq.core.user.User;
|
||||
|
@ -155,7 +156,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
|
||||
String fiatDirectionInfo = ":";
|
||||
String btcDirectionInfo = ":";
|
||||
Offer.Direction direction = offer.getDirection();
|
||||
OfferPayload.Direction direction = offer.getDirection();
|
||||
String currencyCode = offer.getCurrencyCode();
|
||||
String offerTypeLabel = Res.getWithCol("shared.offerType");
|
||||
String toReceive = " " + Res.get("shared.toReceive");
|
||||
|
@ -164,13 +165,13 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
if (takeOfferHandlerOptional.isPresent()) {
|
||||
addLabelTextField(gridPane, rowIndex, offerTypeLabel,
|
||||
formatter.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
|
||||
fiatDirectionInfo = direction == Offer.Direction.BUY ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == Offer.Direction.SELL ? toReceive : toSpend;
|
||||
fiatDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
|
||||
} else if (placeOfferHandlerOptional.isPresent()) {
|
||||
addLabelTextField(gridPane, rowIndex, offerTypeLabel,
|
||||
formatter.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
|
||||
fiatDirectionInfo = direction == Offer.Direction.SELL ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == Offer.Direction.BUY ? toReceive : toSpend;
|
||||
fiatDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
|
||||
} else {
|
||||
addLabelTextField(gridPane, rowIndex, offerTypeLabel,
|
||||
formatter.getDirectionBothSides(direction, currencyCode), firstRowDistance);
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.bisq.gui.main.portfolio.closedtrades;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.trade.Tradable;
|
||||
import io.bisq.core.trade.closed.ClosedTradableManager;
|
||||
import io.bisq.gui.common.model.ActivatableDataModel;
|
||||
|
@ -56,7 +57,7 @@ class ClosedTradesDataModel extends ActivatableDataModel {
|
|||
return list;
|
||||
}
|
||||
|
||||
public Offer.Direction getDirection(Offer offer) {
|
||||
public OfferPayload.Direction getDirection(Offer offer) {
|
||||
return closedTradableManager.wasMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.bisq.gui.main.portfolio.failedtrades;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.trade.Trade;
|
||||
import io.bisq.core.trade.failed.FailedTradesManager;
|
||||
import io.bisq.gui.common.model.ActivatableDataModel;
|
||||
|
@ -57,7 +58,7 @@ class FailedTradesDataModel extends ActivatableDataModel {
|
|||
return list;
|
||||
}
|
||||
|
||||
public Offer.Direction getDirection(Offer offer) {
|
||||
public OfferPayload.Direction getDirection(Offer offer) {
|
||||
return failedTradesManager.wasMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.inject.Inject;
|
|||
import io.bisq.common.handlers.ErrorMessageHandler;
|
||||
import io.bisq.common.handlers.ResultHandler;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.offer.OpenOffer;
|
||||
import io.bisq.core.offer.OpenOfferManager;
|
||||
import io.bisq.core.provider.price.PriceFeedService;
|
||||
|
@ -71,7 +72,7 @@ class OpenOffersDataModel extends ActivatableDataModel {
|
|||
return list;
|
||||
}
|
||||
|
||||
public Offer.Direction getDirection(Offer offer) {
|
||||
public OfferPayload.Direction getDirection(Offer offer) {
|
||||
return openOfferManager.isMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import io.bisq.core.arbitration.DisputeAlreadyOpenException;
|
|||
import io.bisq.core.arbitration.DisputeManager;
|
||||
import io.bisq.core.btc.wallet.BtcWalletService;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import io.bisq.core.trade.BuyerTrade;
|
||||
import io.bisq.core.trade.SellerTrade;
|
||||
|
@ -206,7 +207,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
}
|
||||
|
||||
boolean isBuyOffer() {
|
||||
return getOffer() != null && getOffer().getDirection() == Offer.Direction.BUY;
|
||||
return getOffer() != null && getOffer().getDirection() == OfferPayload.Direction.BUY;
|
||||
}
|
||||
|
||||
boolean isBuyer() {
|
||||
|
@ -268,7 +269,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
return getOffer() != null ? getOffer().getCurrencyCode() : "";
|
||||
}
|
||||
|
||||
public Offer.Direction getDirection(Offer offer) {
|
||||
public OfferPayload.Direction getDirection(Offer offer) {
|
||||
isMaker = tradeManager.isMyOffer(offer);
|
||||
return isMaker ? offer.getDirection() : offer.getMirroredDirection();
|
||||
}
|
||||
|
@ -407,7 +408,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
|||
Dispute dispute = new Dispute(disputeManager.getDisputeStorage(),
|
||||
trade.getId(),
|
||||
keyRing.getPubKeyRing().hashCode(), // traderId
|
||||
trade.getOffer().getDirection() == Offer.Direction.BUY ? isMaker : !isMaker,
|
||||
trade.getOffer().getDirection() == OfferPayload.Direction.BUY ? isMaker : !isMaker,
|
||||
isMaker,
|
||||
keyRing.getPubKeyRing(),
|
||||
trade.getDate(),
|
||||
|
|
|
@ -26,6 +26,7 @@ import io.bisq.common.monetary.Price;
|
|||
import io.bisq.common.monetary.Volume;
|
||||
import io.bisq.common.util.MathUtils;
|
||||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.offer.OfferPayload;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
@ -427,18 +428,18 @@ public class BSFormatter {
|
|||
return decimalFormat.format(MathUtils.roundDouble(value, precision)).replace(",", ".");
|
||||
}
|
||||
|
||||
public String getDirectionWithCode(Offer.Direction direction, String currencyCode) {
|
||||
public String getDirectionWithCode(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return (direction == Offer.Direction.BUY) ? Res.get("shared.buyCurrency", "BTC") : Res.get("shared.sellCurrency", "BTC");
|
||||
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyCurrency", "BTC") : Res.get("shared.sellCurrency", "BTC");
|
||||
else
|
||||
return (direction == Offer.Direction.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
|
||||
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
|
||||
}
|
||||
|
||||
public String getDirectionWithCodeDetailed(Offer.Direction direction, String currencyCode) {
|
||||
public String getDirectionWithCodeDetailed(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return (direction == Offer.Direction.BUY) ? Res.get("shared.buyingBTCWith", currencyCode) : Res.get("shared.sellingBTCFor", currencyCode);
|
||||
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyingBTCWith", currencyCode) : Res.get("shared.sellingBTCFor", currencyCode);
|
||||
else
|
||||
return (direction == Offer.Direction.SELL) ? Res.get("shared.buyingCurrency", currencyCode) : Res.get("shared.sellingCurrency", currencyCode);
|
||||
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyingCurrency", currencyCode) : Res.get("shared.sellingCurrency", currencyCode);
|
||||
}
|
||||
|
||||
public String arbitratorAddressesToString(List<NodeAddress> nodeAddresses) {
|
||||
|
@ -600,14 +601,14 @@ public class BSFormatter {
|
|||
return value ? Res.get("shared.yes") : Res.get("shared.no");
|
||||
}
|
||||
|
||||
public String getDirectionBothSides(Offer.Direction direction, String currencyCode) {
|
||||
public String getDirectionBothSides(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
currencyCode = "BTC";
|
||||
return direction == Offer.Direction.BUY ?
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
} else {
|
||||
return direction == Offer.Direction.SELL ?
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
}
|
||||
|
@ -639,29 +640,29 @@ public class BSFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
public String getDirectionForTakeOffer(Offer.Direction direction, String currencyCode) {
|
||||
public String getDirectionForTakeOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String btc = "BTC";
|
||||
return direction == Offer.Direction.BUY ?
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), btc, Res.get("shared.buying"), currencyCode) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), btc, Res.get("shared.selling"), currencyCode);
|
||||
} else {
|
||||
String btc = "BTC";
|
||||
return direction == Offer.Direction.SELL ?
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), btc) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), btc);
|
||||
}
|
||||
}
|
||||
|
||||
public String getOfferDirectionForCreateOffer(Offer.Direction direction, String currencyCode) {
|
||||
public String getOfferDirectionForCreateOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String btc = "BTC";
|
||||
return direction == Offer.Direction.BUY ?
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.buy"), btc) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.sell"), btc);
|
||||
} else {
|
||||
String btc = "BTC";
|
||||
return direction == Offer.Direction.SELL ?
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.buy"), currencyCode, Res.get("shared.selling"), btc) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.sell"), currencyCode, Res.get("shared.buying"), btc);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class EncryptionService {
|
|||
}
|
||||
|
||||
private static byte[] encryptPayloadWithHmac(Msg msg, SecretKey secretKey) throws CryptoException {
|
||||
return Encryption.encryptPayloadWithHmac(msg.toProto().toByteArray(), secretKey);
|
||||
return Encryption.encryptPayloadWithHmac(msg.toEnvelopeProto().toByteArray(), secretKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +98,7 @@ public class EncryptionService {
|
|||
// Create a symmetric key
|
||||
SecretKey secretKey = Encryption.generateSecretKey();
|
||||
|
||||
// Encrypt secretKey with receiver's publicKey
|
||||
// Encrypt secretKey with receiver's publicKey
|
||||
byte[] encryptedSecretKey = Encryption.encryptSecretKey(secretKey, encryptionPublicKey);
|
||||
|
||||
// Encrypt with sym key payload with appended hmac
|
||||
|
|
|
@ -31,7 +31,7 @@ public final class CloseConnectionMsg implements Msg {
|
|||
}
|
||||
|
||||
//@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
|
||||
return envelopeBuilder.setCloseConnectionMessage(envelopeBuilder.getCloseConnectionMessageBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
|
||||
package io.bisq.network.p2p;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.common.persistence.Persistable;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
@ -37,6 +39,14 @@ public final class DecryptedMsgWithPubKey implements Persistable {
|
|||
this.signaturePubKey = signaturePubKey;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return PB.DecryptedMsgWithPubKey.newBuilder()
|
||||
// TODO .setMessage(msg.toEnvelopeProto())
|
||||
.setSignaturePubKey(signaturePubKey.toProto());
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DecryptedMsgWithPubKey{" +
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class PrefixedSealedAndSignedMsg implements MailboxMsg, SendersNode
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
return Msg.getEnv().setPrefixedSealedAndSignedMessage(
|
||||
PB.PrefixedSealedAndSignedMessage.newBuilder()
|
||||
.setMessageVersion(messageVersion).setNodeAddress(senderNodeAddress.toProto())
|
||||
|
|
|
@ -198,7 +198,7 @@ public class Connection implements MessageListener {
|
|||
lastSendTimeStamp = now;
|
||||
String peersNodeAddress = peersNodeAddressOptional.isPresent() ? peersNodeAddressOptional.get().toString() : "null";
|
||||
|
||||
envelope = msg.toProto();
|
||||
envelope = msg.toEnvelopeProto();
|
||||
log.debug("Sending message: {}", Utilities.toTruncatedString(envelope.toString(), 10000));
|
||||
|
||||
if (msg instanceof Ping | msg instanceof RefreshTTLMsg) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class GetDataResponse implements SupportedCapabilitiesMsg, Extended
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.GetDataResponse.Builder builder = PB.GetDataResponse.newBuilder();
|
||||
builder.addAllDataSet(
|
||||
dataSet.stream()
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class GetUpdatedDataRequest implements SendersNodeAddressMsg, GetDa
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
return Msg.getEnv().setGetUpdatedDataRequest(
|
||||
PB.GetUpdatedDataRequest.newBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.bisq.network.p2p.peers.getdata.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Marshaller;
|
||||
import io.bisq.common.app.Capabilities;
|
||||
import io.bisq.common.app.Version;
|
||||
|
@ -60,7 +61,7 @@ public final class PreliminaryGetDataRequest implements AnonymousMsg, GetDataReq
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
|
||||
PB.PreliminaryGetDataRequest.Builder msgBuilder = envelopeBuilder.getPreliminaryGetDataRequestBuilder()
|
||||
.setMessageVersion(messageVersion)
|
||||
|
@ -70,4 +71,8 @@ public final class PreliminaryGetDataRequest implements AnonymousMsg, GetDataReq
|
|||
return envelopeBuilder.setPreliminaryGetDataRequest(msgBuilder).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return toEnvelopeProto().getPreliminaryGetDataRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public final class Ping extends KeepAliveMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPing(baseEnvelope.getPingBuilder()
|
||||
.setNonce(nonce)
|
||||
|
|
|
@ -22,7 +22,7 @@ public final class Pong extends KeepAliveMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setPong(PB.Pong.newBuilder().setRequestNonce(requestNonce)).build();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class GetPeersRequest extends PeerExchangeMsg implements SendersNod
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
|
||||
PB.GetPeersRequest.Builder msgBuilder = envelopeBuilder.getGetPeersRequestBuilder();
|
||||
msgBuilder
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class GetPeersResponse extends PeerExchangeMsg implements Supported
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder envelopeBuilder = Msg.getEnv();
|
||||
|
||||
PB.GetPeersResponse.Builder msgBuilder = PB.GetPeersResponse.newBuilder();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.bisq.network.p2p.storage.messages;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
|
@ -39,7 +40,7 @@ public final class AddDataMsg extends BroadcastMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
PB.AddDataMessage.Builder builder;
|
||||
PB.ProtectedStorageEntryOrProtectedMailboxStorageEntry.Builder choiceBuilder;
|
||||
|
@ -54,4 +55,9 @@ public final class AddDataMsg extends BroadcastMsg {
|
|||
}
|
||||
return baseEnvelope.setAddDataMessage(builder).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return toEnvelopeProto().getAddDataMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.bisq.network.p2p.storage.messages;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.Marshaller;
|
||||
import io.bisq.common.app.Version;
|
||||
import io.bisq.common.network.Msg;
|
||||
|
@ -40,7 +41,7 @@ public final class RefreshTTLMsg extends BroadcastMsg implements Marshaller {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder builder = Msg.getEnv();
|
||||
return builder.setRefreshTtlMessage(builder.getRefreshTtlMessageBuilder()
|
||||
.setHashOfDataAndSeqNr(ByteString.copyFrom(hashOfDataAndSeqNr))
|
||||
|
@ -48,4 +49,9 @@ public final class RefreshTTLMsg extends BroadcastMsg implements Marshaller {
|
|||
.setSequenceNumber(sequenceNumber)
|
||||
.setSignature(ByteString.copyFrom(signature))).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return toEnvelopeProto().getPreliminaryGetDataRequest();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class RemoveDataMsg extends BroadcastMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setRemoveDataMessage(PB.RemoveDataMessage.newBuilder()
|
||||
.setProtectedStorageEntry((PB.ProtectedStorageEntry) protectedStorageEntry.toProto())).build();
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class RemoveMailboxDataMsg extends BroadcastMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
PB.Envelope.Builder baseEnvelope = Msg.getEnv();
|
||||
return baseEnvelope.setRemoveMailboxDataMessage(PB.RemoveMailboxDataMessage.newBuilder()
|
||||
.setProtectedStorageEntry(protectedMailboxStorageEntry.toProto())).build();
|
||||
|
|
|
@ -55,8 +55,8 @@ public final class MailboxStoragePayload implements StoragePayload {
|
|||
*/
|
||||
public transient PublicKey receiverPubKeyForRemoveOperation;
|
||||
private final byte[] receiverPubKeyForRemoveOperationBytes;
|
||||
// Should be only used in emergency case if we need to add data but do not want to break backward compatibility
|
||||
// at the P2P network storage checks. The hash of the object will be used to verify if the data is valid. Any new
|
||||
// Should be only used in emergency case if we need to add data but do not want to break backward compatibility
|
||||
// at the P2P network storage checks. The hash of the object will be used to verify if the data is valid. Any new
|
||||
// field in a class would break that hash and therefore break the storage mechanism.
|
||||
@Getter
|
||||
@Nullable
|
||||
|
@ -116,7 +116,7 @@ public final class MailboxStoragePayload implements StoragePayload {
|
|||
@Override
|
||||
public PB.StoragePayload toProto() {
|
||||
final PB.MailboxStoragePayload.Builder builder = PB.MailboxStoragePayload.newBuilder()
|
||||
.setPrefixedSealedAndSignedMessage(prefixedSealedAndSignedMessage.toProto().getPrefixedSealedAndSignedMessage())
|
||||
.setPrefixedSealedAndSignedMessage(prefixedSealedAndSignedMessage.toEnvelopeProto().getPrefixedSealedAndSignedMessage())
|
||||
.setSenderPubKeyForAddOperationBytes(ByteString.copyFrom(senderPubKeyForAddOperationBytes))
|
||||
.setReceiverPubKeyForRemoveOperationBytes(ByteString.copyFrom(receiverPubKeyForRemoveOperationBytes));
|
||||
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraDataMap);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class EncryptionServiceTests {
|
|||
}
|
||||
|
||||
//TODO CoreProtobufferResolver is not accessible here
|
||||
// We should refactor it so that the classes themselves know how to deserialize
|
||||
// We should refactor it so that the classes themselves know how to deserialize
|
||||
// so we don't get dependencies from core objects here
|
||||
/*
|
||||
@Test
|
||||
|
@ -135,7 +135,7 @@ public class EncryptionServiceTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
return PB.Envelope.newBuilder().setPing(PB.Ping.newBuilder().setNonce(nonce)).build();
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ final class TestMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public final class MockMailboxPayload implements MailboxMsg, ExpirablePayload {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public final class MockPayload implements Msg, ExpirablePayload {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -823,7 +823,7 @@ final class StressTestDirectMsg implements DirectMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@ -851,7 +851,7 @@ final class StressTestMailboxMsg implements MailboxMsg {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PB.Envelope toProto() {
|
||||
public PB.Envelope toEnvelopeProto() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class P2PDataStorageTest {
|
|||
assertTrue(checkSignature(data));
|
||||
|
||||
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
|
||||
data.toProto().writeTo(byteOutputStream);
|
||||
data.toEnvelopeProto().writeTo(byteOutputStream);
|
||||
|
||||
//TODO CoreProtobufferResolver is not accessible here
|
||||
// We should refactor it so that the classes themselves know how to deserialize
|
||||
|
@ -134,7 +134,7 @@ public class P2PDataStorageTest {
|
|||
public void testOfferRoundtrip() throws InvalidProtocolBufferException {
|
||||
OfferPayload offer = getDummyOffer();
|
||||
try {
|
||||
String buffer = JsonFormat.printer().print(offer.toProto().getOfferPayload());
|
||||
String buffer = JsonFormat.printer().print(offer.toEnvelopeProto().getOfferPayload());
|
||||
JsonFormat.Parser parser = JsonFormat.parser();
|
||||
PB.OfferPayload.Builder builder = PB.OfferPayload.newBuilder();
|
||||
parser.merge(buffer, builder);
|
||||
|
|
|
@ -47,10 +47,10 @@ public class AddDataMsgTest {
|
|||
ProtectedStorageEntry protectedStorageEntry = new ProtectedMailboxStorageEntry(mailboxStoragePayload,
|
||||
keyRing1.getSignatureKeyPair().getPublic(), 1, RandomUtils.nextBytes(10), keyRing1.getPubKeyRing().getSignaturePubKey());
|
||||
AddDataMsg dataMessage1 = new AddDataMsg(protectedStorageEntry);
|
||||
PB.Envelope envelope = dataMessage1.toProto();
|
||||
PB.Envelope envelope = dataMessage1.toEnvelopeProto();
|
||||
|
||||
//TODO CoreProtobufferResolver is not accessible here
|
||||
// We should refactor it so that the classes themselves know how to deserialize
|
||||
// We should refactor it so that the classes themselves know how to deserialize
|
||||
// so we don't get dependencies from core objects here
|
||||
/* AddDataMessage dataMessage2 = (AddDataMessage) ProtoBufferUtilities.getAddDataMessage(envelope);
|
||||
|
||||
|
@ -59,4 +59,4 @@ public class AddDataMsgTest {
|
|||
assertTrue(dataMessage1.equals(dataMessage2));*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -62,6 +62,7 @@
|
|||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.xolstice.maven.plugins</groupId>
|
||||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
|
@ -78,6 +79,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -186,12 +188,13 @@
|
|||
<version>1.16.16</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
|
||||
-->
|
||||
<!--logging-->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -231,7 +234,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
|
Loading…
Add table
Reference in a new issue