mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-09 16:29:27 -04:00
provide trade start time, duration, and deadline in grpc api
This commit is contained in:
parent
384e771712
commit
75b8eb1dc9
4 changed files with 45 additions and 2 deletions
|
@ -99,6 +99,9 @@ public class TradeInfo implements Payload {
|
|||
private final boolean isCompleted;
|
||||
private final String contractAsJson;
|
||||
private final ContractInfo contract;
|
||||
private final long startTime;
|
||||
private final long maxDurationMs;
|
||||
private final long deadlineTime;
|
||||
|
||||
public TradeInfo(TradeInfoV1Builder builder) {
|
||||
this.offer = builder.getOffer();
|
||||
|
@ -140,6 +143,9 @@ public class TradeInfo implements Payload {
|
|||
this.isCompleted = builder.isCompleted();
|
||||
this.contractAsJson = builder.getContractAsJson();
|
||||
this.contract = builder.getContract();
|
||||
this.startTime = builder.getStartTime();
|
||||
this.maxDurationMs = builder.getMaxDurationMs();
|
||||
this.deadlineTime = builder.getDeadlineTime();
|
||||
}
|
||||
|
||||
public static TradeInfo toTradeInfo(Trade trade) {
|
||||
|
@ -202,6 +208,9 @@ public class TradeInfo implements Payload {
|
|||
.withContractAsJson(trade.getContractAsJson())
|
||||
.withContract(contractInfo)
|
||||
.withOffer(toOfferInfo(trade.getOffer()))
|
||||
.withStartTime(trade.getStartDate().getTime())
|
||||
.withMaxDurationMs(trade.getMaxTradePeriod())
|
||||
.withDeadlineTime(trade.getMaxTradePeriodDate().getTime())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -251,6 +260,9 @@ public class TradeInfo implements Payload {
|
|||
.setIsPayoutUnlocked(isPayoutUnlocked)
|
||||
.setContractAsJson(contractAsJson == null ? "" : contractAsJson)
|
||||
.setContract(contract.toProtoMessage())
|
||||
.setStartTime(startTime)
|
||||
.setMaxDurationMs(maxDurationMs)
|
||||
.setDeadlineTime(deadlineTime)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -295,6 +307,9 @@ public class TradeInfo implements Payload {
|
|||
.withIsPayoutUnlocked(proto.getIsPayoutUnlocked())
|
||||
.withContractAsJson(proto.getContractAsJson())
|
||||
.withContract((ContractInfo.fromProto(proto.getContract())))
|
||||
.withStartTime(proto.getStartTime())
|
||||
.withMaxDurationMs(proto.getMaxDurationMs())
|
||||
.withDeadlineTime(proto.getDeadlineTime())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -339,6 +354,9 @@ public class TradeInfo implements Payload {
|
|||
", offer=" + offer + "\n" +
|
||||
", contractAsJson=" + contractAsJson + "\n" +
|
||||
", contract=" + contract + "\n" +
|
||||
", startTime=" + startTime + "\n" +
|
||||
", maxDurationMs=" + maxDurationMs + "\n" +
|
||||
", deadlineTime=" + deadlineTime + "\n" +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ public final class TradeInfoV1Builder {
|
|||
private String contractAsJson;
|
||||
private ContractInfo contract;
|
||||
private String closingStatus;
|
||||
private long startTime;
|
||||
private long maxDurationMs;
|
||||
private long deadlineTime;
|
||||
|
||||
public TradeInfoV1Builder withOffer(OfferInfo offer) {
|
||||
this.offer = offer;
|
||||
|
@ -284,6 +287,21 @@ public final class TradeInfoV1Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public TradeInfoV1Builder withStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TradeInfoV1Builder withMaxDurationMs(long maxDurationMs) {
|
||||
this.maxDurationMs = maxDurationMs;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TradeInfoV1Builder withDeadlineTime(long deadlineTime) {
|
||||
this.deadlineTime = deadlineTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TradeInfo build() {
|
||||
return new TradeInfo(this);
|
||||
}
|
||||
|
|
|
@ -2153,6 +2153,10 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
}
|
||||
}
|
||||
|
||||
public long getMaxTradePeriod() {
|
||||
return getOffer().getPaymentMethod().getMaxTradePeriod();
|
||||
}
|
||||
|
||||
public Date getHalfTradePeriodDate() {
|
||||
return new Date(getStartTime() + getMaxTradePeriod() / 2);
|
||||
}
|
||||
|
@ -2161,8 +2165,8 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
|
|||
return new Date(getStartTime() + getMaxTradePeriod());
|
||||
}
|
||||
|
||||
private long getMaxTradePeriod() {
|
||||
return getOffer().getPaymentMethod().getMaxTradePeriod();
|
||||
public Date getStartDate() {
|
||||
return new Date(getStartTime());
|
||||
}
|
||||
|
||||
private long getStartTime() {
|
||||
|
|
|
@ -908,6 +908,9 @@ message TradeInfo {
|
|||
string maker_deposit_tx_id = 37;
|
||||
string taker_deposit_tx_id = 38;
|
||||
string payout_tx_id = 39;
|
||||
uint64 start_time = 40;
|
||||
uint64 max_duration_ms = 41;
|
||||
uint64 deadline_time = 42;
|
||||
}
|
||||
|
||||
message ContractInfo {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue