provide trade start time, duration, and deadline in grpc api

This commit is contained in:
woodser 2025-07-08 07:08:30 -04:00 committed by GitHub
parent 384e771712
commit 75b8eb1dc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 2 deletions

View file

@ -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" +
'}';
}
}

View file

@ -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);
}

View file

@ -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() {

View file

@ -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 {