add trader id to SignedOffer

This commit is contained in:
woodser 2023-03-11 16:10:57 -05:00
parent 19d83749eb
commit ead70751dc
4 changed files with 24 additions and 9 deletions

View File

@ -236,7 +236,7 @@ public class CoreDisputesService {
.add(buyerSecurityDeposit));
} else if (payout == DisputePayout.CUSTOM) {
if (customWinnerAmount > trade.getWallet().getBalance().longValueExact()) {
throw new RuntimeException("The custom winner payout amount is more than the trade wallet's balance");
throw new RuntimeException("Winner payout is more than the trade wallet's balance");
}
long loserAmount = tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit).subtract(BigInteger.valueOf(customWinnerAmount)).longValueExact();
disputeResult.setBuyerPayoutAmount(BigInteger.valueOf(disputeResult.getWinner() == DisputeResult.Winner.BUYER ? customWinnerAmount : loserAmount));

View File

@ -1007,6 +1007,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
// create record of signed offer
SignedOffer signedOffer = new SignedOffer(
System.currentTimeMillis(),
signedOfferPayload.getPubKeyRing().hashCode(), // trader id
signedOfferPayload.getId(),
offer.getAmount().longValueExact(),
txResult.second.longValueExact(),

View File

@ -18,6 +18,8 @@
package haveno.core.offer;
import haveno.common.proto.persistable.PersistablePayload;
import haveno.core.util.JsonUtil;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@ -30,6 +32,8 @@ public final class SignedOffer implements PersistablePayload {
@Getter
private final long timeStamp;
@Getter
private int traderId;
@Getter
private final String offerId;
@Getter
private final long tradeAmount;
@ -47,6 +51,7 @@ public final class SignedOffer implements PersistablePayload {
private final String arbitratorSignature;
public SignedOffer(long timeStamp,
int traderId,
String offerId,
long tradeAmount,
long penaltyAmount,
@ -56,6 +61,7 @@ public final class SignedOffer implements PersistablePayload {
long reserveTxMinerFee,
String arbitratorSignature) {
this.timeStamp = timeStamp;
this.traderId = traderId;
this.offerId = offerId;
this.tradeAmount = tradeAmount;
this.penaltyAmount = penaltyAmount;
@ -74,6 +80,7 @@ public final class SignedOffer implements PersistablePayload {
public protobuf.SignedOffer toProtoMessage() {
protobuf.SignedOffer.Builder builder = protobuf.SignedOffer.newBuilder()
.setTimeStamp(timeStamp)
.setTraderId(traderId)
.setOfferId(offerId)
.setTradeAmount(tradeAmount)
.setPenaltyAmount(penaltyAmount)
@ -87,6 +94,7 @@ public final class SignedOffer implements PersistablePayload {
public static SignedOffer fromProto(protobuf.SignedOffer proto) {
return new SignedOffer(proto.getTimeStamp(),
proto.getTraderId(),
proto.getOfferId(),
proto.getTradeAmount(),
proto.getPenaltyAmount(),
@ -102,10 +110,15 @@ public final class SignedOffer implements PersistablePayload {
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public String toJson() {
return JsonUtil.objectToJson(this);
}
@Override
public String toString() {
return "SignedOffer{" +
",\n timeStamp=" + timeStamp +
",\n traderId=" + traderId +
",\n offerId=" + offerId +
",\n tradeAmount=" + tradeAmount +
",\n penaltyAmount=" + penaltyAmount +

View File

@ -1348,14 +1348,15 @@ message SignedOfferList {
message SignedOffer {
int64 time_stamp = 1;
string offer_id = 2;
uint64 trade_amount = 3;
uint64 penalty_amount = 4;
string reserve_tx_hash = 5;
string reserve_tx_hex = 6;
repeated string reserve_tx_key_images = 7;
uint64 reserve_tx_miner_fee = 8;
string arbitrator_signature = 9;
int32 trader_id = 2;
string offer_id = 3;
uint64 trade_amount = 4;
uint64 penalty_amount = 5;
string reserve_tx_hash = 6;
string reserve_tx_hex = 7;
repeated string reserve_tx_key_images = 8;
uint64 reserve_tx_miner_fee = 9;
string arbitrator_signature = 10;
}
message OpenOffer {