From cb65de6d2e1497eb8eaf86404fc3285729aba87c Mon Sep 17 00:00:00 2001
From: ghubstan <36207203+ghubstan@users.noreply.github.com>
Date: Fri, 23 Oct 2020 12:47:06 -0300
Subject: [PATCH 1/3] Block on tx-fee-request in core TakeOfferModel init
Added license comment too.
---
.../core/offer/takeoffer/TakeOfferModel.java | 38 ++++++++++++++++---
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java b/core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java
index efd0523ec19..c48b3c8ad4c 100644
--- a/core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java
+++ b/core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java
@@ -1,3 +1,20 @@
+/*
+ * This file is part of Bisq.
+ *
+ * Bisq is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bisq is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bisq. If not, see .
+ */
+
package bisq.core.offer.takeoffer;
import bisq.core.account.witness.AccountAgeWitnessService;
@@ -20,6 +37,8 @@
import javax.inject.Inject;
import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -141,12 +160,19 @@ private void calculateTxFees() {
// Payout tx: 371 bytes
// Disputed payout tx: 408 bytes
- // Request actual fees:
- log.info("Start requestTxFee: txFeeFromFeeService={}", txFeeFromFeeService);
- feeService.requestFees(() -> {
- txFeePerByteFromFeeService = feeService.getTxFeePerByte();
- txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
- });
+ txFeePerByteFromFeeService = getTxFeePerByte();
+ txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
+ log.info("{} txFeePerByte = {}", feeService.getClass().getSimpleName(), txFeePerByteFromFeeService);
+ }
+
+ private Coin getTxFeePerByte() {
+ try {
+ CompletableFuture feeRequestFuture = CompletableFuture.runAsync(feeService::requestFees);
+ feeRequestFuture.get(); // Block until async fee request is complete.
+ return feeService.getTxFeePerByte();
+ } catch (InterruptedException | ExecutionException e) {
+ throw new IllegalStateException("Could not request fees from fee service.", e);
+ }
}
private void calculateTotalToPay() {
From ab20225cd2d50003a8f7f45feca6227a2370a9fb Mon Sep 17 00:00:00 2001
From: ghubstan <36207203+ghubstan@users.noreply.github.com>
Date: Sat, 24 Oct 2020 16:25:20 -0300
Subject: [PATCH 2/3] Add compiler warning suppression, remove comment
---
core/src/main/java/bisq/core/api/model/OfferInfo.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/core/src/main/java/bisq/core/api/model/OfferInfo.java b/core/src/main/java/bisq/core/api/model/OfferInfo.java
index ad2389e438a..219045b2762 100644
--- a/core/src/main/java/bisq/core/api/model/OfferInfo.java
+++ b/core/src/main/java/bisq/core/api/model/OfferInfo.java
@@ -125,13 +125,9 @@ public bisq.proto.grpc.OfferInfo toProtoMessage() {
.build();
}
+ @SuppressWarnings({"unused", "SameReturnValue"})
public static OfferInfo fromProto(bisq.proto.grpc.OfferInfo proto) {
- /*
- TODO?
- return new OfferInfo(proto.getOfferPayload().getId(),
- proto.getOfferPayload().getDate());
- */
- return null;
+ return null; // TODO
}
/*
From 63cf4369904855013ac5b8e37de43462c02e1551 Mon Sep 17 00:00:00 2001
From: ghubstan <36207203+ghubstan@users.noreply.github.com>
Date: Sat, 24 Oct 2020 16:27:03 -0300
Subject: [PATCH 3/3] Add fields to grpc TradeInfo proto & wrapper
---
.../java/bisq/core/api/model/TradeInfo.java | 133 +++++++++++++++++-
proto/src/main/proto/grpc.proto | 29 ++--
2 files changed, 149 insertions(+), 13 deletions(-)
diff --git a/core/src/main/java/bisq/core/api/model/TradeInfo.java b/core/src/main/java/bisq/core/api/model/TradeInfo.java
index 33b8059f9b5..6e4adeca4ae 100644
--- a/core/src/main/java/bisq/core/api/model/TradeInfo.java
+++ b/core/src/main/java/bisq/core/api/model/TradeInfo.java
@@ -21,6 +21,8 @@
import bisq.common.Payload;
+import java.util.Objects;
+
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -37,6 +39,16 @@ public class TradeInfo implements Payload {
private final OfferInfo offer;
private final String tradeId;
private final String shortId;
+ private final long date;
+ private final boolean isCurrencyForTakerFeeBtc;
+ private final long txFeeAsLong;
+ private final long takerFeeAsLong;
+ private final String takerFeeTxId;
+ private final String depositTxId;
+ private final String payoutTxId;
+ private final long tradeAmountAsLong;
+ private final long tradePrice;
+ private final String tradingPeerNodeAddress;
private final String state;
private final String phase;
private final String tradePeriodState;
@@ -46,11 +58,22 @@ public class TradeInfo implements Payload {
private final boolean isFiatReceived;
private final boolean isPayoutPublished;
private final boolean isWithdrawn;
+ private final String contractAsJson;
public TradeInfo(TradeInfoBuilder builder) {
this.offer = builder.offer;
this.tradeId = builder.tradeId;
this.shortId = builder.shortId;
+ this.date = builder.date;
+ this.isCurrencyForTakerFeeBtc = builder.isCurrencyForTakerFeeBtc;
+ this.txFeeAsLong = builder.txFeeAsLong;
+ this.takerFeeAsLong = builder.takerFeeAsLong;
+ this.takerFeeTxId = builder.takerFeeTxId;
+ this.depositTxId = builder.depositTxId;
+ this.payoutTxId = builder.payoutTxId;
+ this.tradeAmountAsLong = builder.tradeAmountAsLong;
+ this.tradePrice = builder.tradePrice;
+ this.tradingPeerNodeAddress = builder.tradingPeerNodeAddress;
this.state = builder.state;
this.phase = builder.phase;
this.tradePeriodState = builder.tradePeriodState;
@@ -60,6 +83,7 @@ public TradeInfo(TradeInfoBuilder builder) {
this.isFiatReceived = builder.isFiatReceived;
this.isPayoutPublished = builder.isPayoutPublished;
this.isWithdrawn = builder.isWithdrawn;
+ this.contractAsJson = builder.contractAsJson;
}
public static TradeInfo toTradeInfo(Trade trade) {
@@ -67,6 +91,18 @@ public static TradeInfo toTradeInfo(Trade trade) {
.withOffer(toOfferInfo(trade.getOffer()))
.withTradeId(trade.getId())
.withShortId(trade.getShortId())
+ .withDate(trade.getDate().getTime())
+ .withIsCurrencyForTakerFeeBtc(trade.isCurrencyForTakerFeeBtc())
+ .withTxFeeAsLong(trade.getTxFeeAsLong())
+ .withTakerFeeAsLong(trade.getTakerFeeAsLong())
+ .withTakerFeeAsLong(trade.getTakerFeeAsLong())
+ .withTakerFeeTxId(trade.getTakerFeeTxId())
+ .withDepositTxId(trade.getDepositTxId())
+ .withPayoutTxId(trade.getPayoutTxId())
+ .withTradeAmountAsLong(trade.getTradeAmountAsLong())
+ .withTradePrice(trade.getTradePrice().getValue())
+ .withTradingPeerNodeAddress(Objects.requireNonNull(
+ trade.getTradingPeerNodeAddress()).getHostNameWithoutPostFix())
.withState(trade.getState().name())
.withPhase(trade.getPhase().name())
.withTradePeriodState(trade.getTradePeriodState().name())
@@ -76,6 +112,7 @@ public static TradeInfo toTradeInfo(Trade trade) {
.withIsFiatReceived(trade.isFiatReceived())
.withIsPayoutPublished(trade.isPayoutPublished())
.withIsWithdrawn(trade.isWithdrawn())
+ .withContractAsJson(trade.getContractAsJson())
.build();
}
@@ -89,6 +126,16 @@ public bisq.proto.grpc.TradeInfo toProtoMessage() {
.setOffer(offer.toProtoMessage())
.setTradeId(tradeId)
.setShortId(shortId)
+ .setDate(date)
+ .setIsCurrencyForTakerFeeBtc(isCurrencyForTakerFeeBtc)
+ .setTxFeeAsLong(txFeeAsLong)
+ .setTakerFeeAsLong(takerFeeAsLong)
+ .setTakerFeeTxId(takerFeeTxId == null ? "" : takerFeeTxId)
+ .setDepositTxId(depositTxId == null ? "" : depositTxId)
+ .setPayoutTxId(payoutTxId == null ? "" : payoutTxId)
+ .setTradeAmountAsLong(tradeAmountAsLong)
+ .setTradePrice(tradePrice)
+ .setTradingPeerNodeAddress(tradingPeerNodeAddress)
.setState(state)
.setPhase(phase)
.setTradePeriodState(tradePeriodState)
@@ -98,12 +145,13 @@ public bisq.proto.grpc.TradeInfo toProtoMessage() {
.setIsFiatReceived(isFiatReceived)
.setIsPayoutPublished(isPayoutPublished)
.setIsWithdrawn(isWithdrawn)
+ .setContractAsJson(contractAsJson == null ? "" : contractAsJson)
.build();
}
+ @SuppressWarnings({"unused", "SameReturnValue"})
public static TradeInfo fromProto(bisq.proto.grpc.TradeInfo proto) {
- // TODO
- return null;
+ return null; // TODO
}
/*
@@ -116,6 +164,16 @@ public static class TradeInfoBuilder {
private OfferInfo offer;
private String tradeId;
private String shortId;
+ private long date;
+ private boolean isCurrencyForTakerFeeBtc;
+ private long txFeeAsLong;
+ private long takerFeeAsLong;
+ private String takerFeeTxId;
+ private String depositTxId;
+ private String payoutTxId;
+ private long tradeAmountAsLong;
+ private long tradePrice;
+ private String tradingPeerNodeAddress;
private String state;
private String phase;
private String tradePeriodState;
@@ -125,6 +183,7 @@ public static class TradeInfoBuilder {
private boolean isFiatReceived;
private boolean isPayoutPublished;
private boolean isWithdrawn;
+ private String contractAsJson;
public TradeInfoBuilder withOffer(OfferInfo offer) {
this.offer = offer;
@@ -141,6 +200,56 @@ public TradeInfoBuilder withShortId(String shortId) {
return this;
}
+ public TradeInfoBuilder withDate(long date) {
+ this.date = date;
+ return this;
+ }
+
+ public TradeInfoBuilder withIsCurrencyForTakerFeeBtc(boolean isCurrencyForTakerFeeBtc) {
+ this.isCurrencyForTakerFeeBtc = isCurrencyForTakerFeeBtc;
+ return this;
+ }
+
+ public TradeInfoBuilder withTxFeeAsLong(long txFeeAsLong) {
+ this.txFeeAsLong = txFeeAsLong;
+ return this;
+ }
+
+ public TradeInfoBuilder withTakerFeeAsLong(long takerFeeAsLong) {
+ this.takerFeeAsLong = takerFeeAsLong;
+ return this;
+ }
+
+ public TradeInfoBuilder withTakerFeeTxId(String takerFeeTxId) {
+ this.takerFeeTxId = takerFeeTxId;
+ return this;
+ }
+
+ public TradeInfoBuilder withDepositTxId(String depositTxId) {
+ this.depositTxId = depositTxId;
+ return this;
+ }
+
+ public TradeInfoBuilder withPayoutTxId(String payoutTxId) {
+ this.payoutTxId = payoutTxId;
+ return this;
+ }
+
+ public TradeInfoBuilder withTradeAmountAsLong(long tradeAmountAsLong) {
+ this.tradeAmountAsLong = tradeAmountAsLong;
+ return this;
+ }
+
+ public TradeInfoBuilder withTradePrice(long tradePrice) {
+ this.tradePrice = tradePrice;
+ return this;
+ }
+
+ public TradeInfoBuilder withTradePeriodState(String tradePeriodState) {
+ this.tradePeriodState = tradePeriodState;
+ return this;
+ }
+
public TradeInfoBuilder withState(String state) {
this.state = state;
return this;
@@ -151,8 +260,8 @@ public TradeInfoBuilder withPhase(String phase) {
return this;
}
- public TradeInfoBuilder withTradePeriodState(String tradePeriodState) {
- this.tradePeriodState = tradePeriodState;
+ public TradeInfoBuilder withTradingPeerNodeAddress(String tradingPeerNodeAddress) {
+ this.tradingPeerNodeAddress = tradingPeerNodeAddress;
return this;
}
@@ -186,6 +295,11 @@ public TradeInfoBuilder withIsWithdrawn(boolean isWithdrawn) {
return this;
}
+ public TradeInfoBuilder withContractAsJson(String contractAsJson) {
+ this.contractAsJson = contractAsJson;
+ return this;
+ }
+
public TradeInfo build() {
return new TradeInfo(this);
}
@@ -196,6 +310,16 @@ public String toString() {
return "TradeInfo{" +
" tradeId='" + tradeId + '\'' + "\n" +
", shortId='" + shortId + '\'' + "\n" +
+ ", date='" + date + '\'' + "\n" +
+ ", isCurrencyForTakerFeeBtc='" + isCurrencyForTakerFeeBtc + '\'' + "\n" +
+ ", txFeeAsLong='" + txFeeAsLong + '\'' + "\n" +
+ ", takerFeeAsLong='" + takerFeeAsLong + '\'' + "\n" +
+ ", takerFeeTxId='" + takerFeeTxId + '\'' + "\n" +
+ ", depositTxId='" + depositTxId + '\'' + "\n" +
+ ", payoutTxId='" + payoutTxId + '\'' + "\n" +
+ ", tradeAmountAsLong='" + tradeAmountAsLong + '\'' + "\n" +
+ ", tradePrice='" + tradePrice + '\'' + "\n" +
+ ", tradingPeerNodeAddress='" + tradingPeerNodeAddress + '\'' + "\n" +
", state='" + state + '\'' + "\n" +
", phase='" + phase + '\'' + "\n" +
", tradePeriodState='" + tradePeriodState + '\'' + "\n" +
@@ -206,6 +330,7 @@ public String toString() {
", isPayoutPublished=" + isPayoutPublished + "\n" +
", isWithdrawn=" + isWithdrawn + "\n" +
", offer=" + offer + "\n" +
+ ", contractAsJson=" + contractAsJson + "\n" +
'}';
}
}
diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto
index 38ddd4a9dbb..68121d00596 100644
--- a/proto/src/main/proto/grpc.proto
+++ b/proto/src/main/proto/grpc.proto
@@ -217,15 +217,26 @@ message TradeInfo {
OfferInfo offer = 1;
string tradeId = 2;
string shortId = 3;
- string state = 4;
- string phase = 5;
- string tradePeriodState = 6;
- bool isDepositPublished = 7;
- bool isDepositConfirmed = 8;
- bool isFiatSent = 9;
- bool isFiatReceived = 10;
- bool isPayoutPublished = 11;
- bool isWithdrawn = 12;
+ uint64 date = 4;
+ bool isCurrencyForTakerFeeBtc = 5;
+ uint64 txFeeAsLong = 6;
+ uint64 takerFeeAsLong = 7;
+ string takerFeeTxId = 8;
+ string depositTxId = 9;
+ string payoutTxId = 10;
+ uint64 tradeAmountAsLong = 11;
+ uint64 tradePrice = 12;
+ string tradingPeerNodeAddress = 13;
+ string state = 14;
+ string phase = 15;
+ string tradePeriodState = 16;
+ bool isDepositPublished = 17;
+ bool isDepositConfirmed = 18;
+ bool isFiatSent = 19;
+ bool isFiatReceived = 20;
+ bool isPayoutPublished = 21;
+ bool isWithdrawn = 22;
+ string contractAsJson = 23;
}
///////////////////////////////////////////////////////////////////////////////////////////