mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
getting the Trade serialized, missing processmodel and decryptmsgwithpubkey
This commit is contained in:
parent
bf7c06e0e2
commit
7f56d01cee
6 changed files with 85 additions and 28 deletions
|
@ -65,18 +65,17 @@ public final class BuyerAsMakerTrade extends BuyerTrade implements MakerTrade {
|
|||
((MakerProtocol) tradeProtocol).handleTakeOfferRequest(message, taker);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public PB.Tradable toProto() {
|
||||
return PB.Tradable.newBuilder().setBuyerAsMakerTrade(PB.BuyerAsMakerTrade.newBuilder().setTrade(super.toProto())).build();
|
||||
return PB.Tradable.newBuilder()
|
||||
.setBuyerAsMakerTrade(PB.BuyerAsMakerTrade.newBuilder().setTrade((PB.Trade) super.toProto())).build();
|
||||
}
|
||||
|
||||
public static Tradable fromProto(PB.BuyerAsMakerTrade proto, Storage<? extends TradableList> storage) {
|
||||
public static Tradable fromProto(PB.BuyerAsMakerTrade proto, Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
return new BuyerAsMakerTrade(Offer.fromProto(proto.getTrade().getOffer()),
|
||||
Coin.valueOf(proto.getTrade().getTxFee().getValue()),
|
||||
Coin.valueOf(proto.getTrade().getTakeOffer().getValue()),
|
||||
|
||||
);
|
||||
Coin.valueOf(proto.getTrade().getTxFeeAsLong()),
|
||||
Coin.valueOf(proto.getTrade().getTakerFeeAsLong()),
|
||||
proto.getTrade().getIsCurrencyForTakerFeeBtc(), storage, btcWalletService);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.bisq.core.btc.wallet.BtcWalletService;
|
|||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.trade.protocol.BuyerAsTakerProtocol;
|
||||
import io.bisq.core.trade.protocol.TakerProtocol;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -43,13 +44,13 @@ public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade {
|
|||
public BuyerAsTakerTrade(Offer offer,
|
||||
Coin tradeAmount,
|
||||
Coin txFee,
|
||||
Coin takeOfferFee,
|
||||
Coin takerFee,
|
||||
boolean isCurrencyForTakerFeeBtc,
|
||||
long tradePrice,
|
||||
NodeAddress tradingPeerNodeAddress,
|
||||
Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
super(offer, tradeAmount, txFee, takeOfferFee, isCurrencyForTakerFeeBtc, tradePrice,
|
||||
super(offer, tradeAmount, txFee, takerFee, isCurrencyForTakerFeeBtc, tradePrice,
|
||||
tradingPeerNodeAddress, storage, btcWalletService);
|
||||
}
|
||||
|
||||
|
@ -70,12 +71,19 @@ public final class BuyerAsTakerTrade extends BuyerTrade implements TakerTrade {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return null;
|
||||
public PB.Tradable toProto() {
|
||||
return PB.Tradable.newBuilder()
|
||||
.setBuyerAsTakerTrade(PB.BuyerAsTakerTrade.newBuilder().setTrade((PB.Trade) super.toProto())).build();
|
||||
}
|
||||
|
||||
public static Tradable fromProto() {
|
||||
// reset State (see readObject)
|
||||
return null;
|
||||
public static Tradable fromProto(PB.BuyerAsTakerTrade proto, Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
PB.Trade trade = proto.getTrade();
|
||||
return new BuyerAsTakerTrade(Offer.fromProto(trade.getOffer()),
|
||||
Coin.valueOf(trade.getTxFeeAsLong()), Coin.valueOf(trade.getTakerFeeAsLong()),
|
||||
Coin.valueOf(trade.getTakerFeeAsLong()),
|
||||
trade.getIsCurrencyForTakerFeeBtc(), trade.getTradePrice(),
|
||||
NodeAddress.fromProto(trade.getTradingPeerNodeAddress()), storage,
|
||||
btcWalletService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,23 +39,23 @@ public abstract class BuyerTrade extends Trade {
|
|||
BuyerTrade(Offer offer,
|
||||
Coin tradeAmount,
|
||||
Coin txFee,
|
||||
Coin takeOfferFee,
|
||||
Coin takerFee,
|
||||
boolean isCurrencyForTakerFeeBtc,
|
||||
long tradePrice,
|
||||
NodeAddress tradingPeerNodeAddress,
|
||||
Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
super(offer, tradeAmount, txFee, takeOfferFee, isCurrencyForTakerFeeBtc, tradePrice,
|
||||
super(offer, tradeAmount, txFee, takerFee, isCurrencyForTakerFeeBtc, tradePrice,
|
||||
tradingPeerNodeAddress, storage, btcWalletService);
|
||||
}
|
||||
|
||||
BuyerTrade(Offer offer,
|
||||
Coin txFee,
|
||||
Coin takeOfferFee,
|
||||
Coin takerFee,
|
||||
boolean isCurrencyForTakerFeeBtc,
|
||||
Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
super(offer, txFee, takeOfferFee, isCurrencyForTakerFeeBtc, storage, btcWalletService);
|
||||
super(offer, txFee, takerFee, isCurrencyForTakerFeeBtc, storage, btcWalletService);
|
||||
}
|
||||
|
||||
public void onFiatPaymentStarted(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.bisq.core.offer.Offer;
|
|||
import io.bisq.core.trade.messages.TradeMsg;
|
||||
import io.bisq.core.trade.protocol.MakerProtocol;
|
||||
import io.bisq.core.trade.protocol.SellerAsMakerProtocol;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -40,11 +41,11 @@ public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade
|
|||
|
||||
public SellerAsMakerTrade(Offer offer,
|
||||
Coin txFee,
|
||||
Coin takeOfferFee,
|
||||
Coin takerFee,
|
||||
boolean isCurrencyForTakerFeeBtc,
|
||||
Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
super(offer, txFee, takeOfferFee, isCurrencyForTakerFeeBtc, storage, btcWalletService);
|
||||
super(offer, txFee, takerFee, isCurrencyForTakerFeeBtc, storage, btcWalletService);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,4 +62,18 @@ public final class SellerAsMakerTrade extends SellerTrade implements MakerTrade
|
|||
public void handleTakeOfferRequest(TradeMsg message, NodeAddress taker) {
|
||||
((MakerProtocol) tradeProtocol).handleTakeOfferRequest(message, taker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PB.Tradable toProto() {
|
||||
return PB.Tradable.newBuilder()
|
||||
.setSellerAsMakerTrade(PB.SellerAsMakerTrade.newBuilder().setTrade((PB.Trade) super.toProto())).build();
|
||||
}
|
||||
|
||||
public static Tradable fromProto(PB.BuyerAsTakerTrade proto, Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
PB.Trade trade = proto.getTrade();
|
||||
return new SellerAsMakerTrade(Offer.fromProto(trade.getOffer()),
|
||||
Coin.valueOf(trade.getTxFeeAsLong()), Coin.valueOf(trade.getTakerFeeAsLong()),
|
||||
trade.getIsCurrencyForTakerFeeBtc(), storage, btcWalletService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.bisq.core.btc.wallet.BtcWalletService;
|
|||
import io.bisq.core.offer.Offer;
|
||||
import io.bisq.core.trade.protocol.SellerAsTakerProtocol;
|
||||
import io.bisq.core.trade.protocol.TakerProtocol;
|
||||
import io.bisq.generated.protobuffer.PB;
|
||||
import io.bisq.network.p2p.NodeAddress;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -67,4 +68,20 @@ public final class SellerAsTakerTrade extends SellerTrade implements TakerTrade
|
|||
checkArgument(tradeProtocol instanceof TakerProtocol, "tradeProtocol NOT instanceof TakerProtocol");
|
||||
((TakerProtocol) tradeProtocol).takeAvailableOffer();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PB.Tradable toProto() {
|
||||
return PB.Tradable.newBuilder()
|
||||
.setSellerAsTakerTrade(PB.SellerAsTakerTrade.newBuilder().setTrade((PB.Trade) super.toProto())).build();
|
||||
}
|
||||
|
||||
public static Tradable fromProto(PB.BuyerAsTakerTrade proto, Storage<? extends TradableList> storage,
|
||||
BtcWalletService btcWalletService) {
|
||||
PB.Trade trade = proto.getTrade();
|
||||
return new SellerAsTakerTrade(Offer.fromProto(trade.getOffer()), Coin.valueOf(trade.getTradeAmountAsLong()),
|
||||
Coin.valueOf(trade.getTxFeeAsLong()), Coin.valueOf(trade.getTakerFeeAsLong()),
|
||||
trade.getIsCurrencyForTakerFeeBtc(), trade.getTradePrice(),
|
||||
NodeAddress.fromProto(trade.getTradingPeerNodeAddress()), storage, btcWalletService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.google.common.base.Throwables;
|
|||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Message;
|
||||
import io.bisq.common.app.DevEnv;
|
||||
import io.bisq.common.app.Log;
|
||||
|
@ -267,7 +268,8 @@ public abstract class Trade implements Tradable, Model {
|
|||
}
|
||||
|
||||
// taker
|
||||
protected Trade(Offer offer, Coin tradeAmount,
|
||||
protected Trade(Offer offer,
|
||||
Coin tradeAmount,
|
||||
Coin txFee,
|
||||
Coin takerFee,
|
||||
boolean isCurrencyForTakerFeeBtc,
|
||||
|
@ -830,22 +832,38 @@ public abstract class Trade implements Tradable, Model {
|
|||
setState(State.DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Message toProto() {
|
||||
return PB.Trade.newBuilder()
|
||||
.setOffer(offer.toProto())
|
||||
.setProcessModel(processModel.toproto())
|
||||
// TODO .setProcessModel(processModel.toproto())
|
||||
.setTakerFeeTxId(takerFeeTxId)
|
||||
.setDepositTxId(depositTxId)
|
||||
.setPayoutTxId(payoutTxId)
|
||||
.setTradeAmountAsLong(tradeAmountAsLong)
|
||||
.setTxFeeAsLong(txFeeAsLong)
|
||||
.setTakerFeeAsLong(takerFeeAsLong)
|
||||
.setDecryptedMsgWithPubKey((PB.DecryptedMsgWithPubKey) decryptedMsgWithPubKey.toProto())
|
||||
;
|
||||
// TODO .setDecryptedMsgWithPubKey((PB.DecryptedMsgWithPubKey) decryptedMsgWithPubKey.toProto())
|
||||
.setTakeOfferDate(takeOfferDate)
|
||||
.setIsCurrencyForTakerFeeBtc(isCurrencyForTakerFeeBtc)
|
||||
.setTradePrice(tradePrice)
|
||||
.setTradingPeerNodeAddress(tradingPeerNodeAddress.toProto())
|
||||
.setState(PB.Trade.State.valueOf(state.name()))
|
||||
.setDisputeState(PB.Trade.DisputeState.valueOf(disputeState.name()))
|
||||
.setTradePeriodState(PB.Trade.TradePeriodState.valueOf(tradePeriodState.name()))
|
||||
.setContract(contract.toProto())
|
||||
.setContractAsJson(contractAsJson)
|
||||
.setContractHash(ByteString.copyFrom(contractHash))
|
||||
.setTakerContractSignature(takerContractSignature)
|
||||
.setMakerContractSignature(makerContractSignature)
|
||||
.setArbitratorNodeAddress(arbitratorNodeAddress.toProto())
|
||||
.setMediatorNodeAddress(mediatorNodeAddress.toProto())
|
||||
.setArbitratorBtcPubKey(ByteString.copyFrom(arbitratorBtcPubKey))
|
||||
.setTakerPaymentAccountId(takerPaymentAccountId)
|
||||
.setErrorMessage(errorMessage)
|
||||
.build();
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Trade{" +
|
||||
|
|
Loading…
Add table
Reference in a new issue