Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI bug fix: show trade's contract volume, not moving offer volume #5704

Merged
merged 4 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/main/java/bisq/cli/CliMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ private static void printHelp(OptionParser parser, @SuppressWarnings("SameParame
stream.println();
stream.format(rowFormat, editoffer.name(), "--offer-id=<offer-id> \\", "Edit offer with id");
stream.format(rowFormat, "", "[--fixed-price=<price>] \\", "");
stream.format(rowFormat, "", "[--market-price=margin=<percent>] \\", "");
stream.format(rowFormat, "", "[--market-price-margin=<percent>] \\", "");
stream.format(rowFormat, "", "[--trigger-price=<price>] \\", "");
stream.format(rowFormat, "", "[--enabled=<true|false>]", "");
stream.println();
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main/java/bisq/cli/TradeFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ private static String formatTradeData(String format,
private static final Function<TradeInfo, String> priceFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatPrice(t.getTradePrice())
: formatCryptoCurrencyPrice(t.getOffer().getPrice());
: formatCryptoCurrencyPrice(t.getTradePrice());

private static final Function<TradeInfo, String> amountFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatSatoshis(t.getTradeAmountAsLong())
: formatCryptoCurrencyOfferVolume(t.getOffer().getVolume());
: formatCryptoCurrencyOfferVolume(t.getTradeVolume());

private static final BiFunction<TradeInfo, Boolean, String> makerTakerMinerTxFeeFormat = (t, isTaker) -> {
if (isTaker) {
Expand All @@ -188,7 +188,7 @@ private static String formatTradeData(String format,

private static final Function<TradeInfo, String> tradeCostFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatOfferVolume(t.getOffer().getVolume())
? formatOfferVolume(t.getTradeVolume())
: formatSatoshis(t.getTradeAmountAsLong());

private static final BiFunction<TradeInfo, Boolean, String> bsqReceiveAddress = (t, showBsqBuyerAddress) -> {
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/bisq/core/api/model/TradeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class TradeInfo implements Payload {
private final String payoutTxId;
private final long tradeAmountAsLong;
private final long tradePrice;
private final long tradeVolume;
private final String tradingPeerNodeAddress;
private final String state;
private final String phase;
Expand Down Expand Up @@ -78,6 +79,7 @@ public TradeInfo(TradeInfoBuilder builder) {
this.payoutTxId = builder.payoutTxId;
this.tradeAmountAsLong = builder.tradeAmountAsLong;
this.tradePrice = builder.tradePrice;
this.tradeVolume = builder.tradeVolume;
this.tradingPeerNodeAddress = builder.tradingPeerNodeAddress;
this.state = builder.state;
this.phase = builder.phase;
Expand Down Expand Up @@ -133,6 +135,7 @@ public static TradeInfo toTradeInfo(Trade trade, String role, boolean isMyOffer)
.withPayoutTxId(trade.getPayoutTxId())
.withTradeAmountAsLong(trade.getTradeAmountAsLong())
.withTradePrice(trade.getTradePrice().getValue())
.withTradeVolume(trade.getTradeVolume() == null ? 0 : trade.getTradeVolume().getValue())
.withTradingPeerNodeAddress(Objects.requireNonNull(
trade.getTradingPeerNodeAddress()).getHostNameWithoutPostFix())
.withState(trade.getState().name())
Expand Down Expand Up @@ -169,6 +172,7 @@ public bisq.proto.grpc.TradeInfo toProtoMessage() {
.setPayoutTxId(payoutTxId == null ? "" : payoutTxId)
.setTradeAmountAsLong(tradeAmountAsLong)
.setTradePrice(tradePrice)
.setTradeVolume(tradeVolume)
.setTradingPeerNodeAddress(tradingPeerNodeAddress)
.setState(state)
.setPhase(phase)
Expand Down Expand Up @@ -199,6 +203,7 @@ public static TradeInfo fromProto(bisq.proto.grpc.TradeInfo proto) {
.withPayoutTxId(proto.getPayoutTxId())
.withTradeAmountAsLong(proto.getTradeAmountAsLong())
.withTradePrice(proto.getTradePrice())
.withTradeVolume(proto.getTradeVolume())
.withTradePeriodState(proto.getTradePeriodState())
.withState(proto.getState())
.withPhase(proto.getPhase())
Expand Down Expand Up @@ -234,6 +239,7 @@ public static class TradeInfoBuilder {
private String payoutTxId;
private long tradeAmountAsLong;
private long tradePrice;
private long tradeVolume;
private String tradingPeerNodeAddress;
private String state;
private String phase;
Expand Down Expand Up @@ -312,6 +318,11 @@ public TradeInfoBuilder withTradePrice(long tradePrice) {
return this;
}

public TradeInfoBuilder withTradeVolume(long tradeVolume) {
this.tradeVolume = tradeVolume;
return this;
}

public TradeInfoBuilder withTradePeriodState(String tradePeriodState) {
this.tradePeriodState = tradePeriodState;
return this;
Expand Down Expand Up @@ -392,6 +403,7 @@ public String toString() {
", payoutTxId='" + payoutTxId + '\'' + "\n" +
", tradeAmountAsLong='" + tradeAmountAsLong + '\'' + "\n" +
", tradePrice='" + tradePrice + '\'' + "\n" +
", tradeVolume='" + tradeVolume + '\'' + "\n" +
", tradingPeerNodeAddress='" + tradingPeerNodeAddress + '\'' + "\n" +
", state='" + state + '\'' + "\n" +
", phase='" + phase + '\'' + "\n" +
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ message TradeInfo {
bool isWithdrawn = 23;
string contractAsJson = 24;
ContractInfo contract = 25;
uint64 tradeVolume = 26;
}

message ContractInfo {
Expand Down