Skip to content

Commit

Permalink
Append nullable withdrawalTxId field to Trade proto message
Browse files Browse the repository at this point in the history
The withdrawalTxId field will be set in TradeManager#onWithdrawRequest
upon successful trade completion and withdrawal of funds.

Persisting withdrawalTxId will allow the api and ui to find the withdrawalTxId
for a completed trade after the seller withdraws funds to an external wallet.
In turn, the withdrawal tx's memo field will be accessible in a new (todo)
api getTx(txID) api method.

Changed:

- Appended field 'string withdrawal_tx_id = 40' to pb.proto's Trade message.

- Added nullable 'String withdrawalTxId' to Trade entity class.

- Added trade.setWithdrawalTxId(transaction.getTxId().toString()) in
  TradeManager#onWithdrawRequest's callback.
  • Loading branch information
ghubstan committed Dec 12, 2020
1 parent 150e2f6 commit 6aa385e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/main/java/bisq/core/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ public static protobuf.Trade.TradePeriodState toProtoMessage(Trade.TradePeriodSt
@Getter
@Setter
private String payoutTxId;
@Nullable
@Getter
@Setter
private String withdrawalTxId;
@Getter
@Setter
private long tradeAmountAsLong;
Expand Down Expand Up @@ -554,6 +558,7 @@ public Message toProtoMessage() {
Optional.ofNullable(takerFeeTxId).ifPresent(builder::setTakerFeeTxId);
Optional.ofNullable(depositTxId).ifPresent(builder::setDepositTxId);
Optional.ofNullable(payoutTxId).ifPresent(builder::setPayoutTxId);
Optional.ofNullable(withdrawalTxId).ifPresent(builder::setWithdrawalTxId);
Optional.ofNullable(tradingPeerNodeAddress).ifPresent(e -> builder.setTradingPeerNodeAddress(tradingPeerNodeAddress.toProtoMessage()));
Optional.ofNullable(contract).ifPresent(e -> builder.setContract(contract.toProtoMessage()));
Optional.ofNullable(contractAsJson).ifPresent(builder::setContractAsJson);
Expand Down Expand Up @@ -587,6 +592,7 @@ public static Trade fromProto(Trade trade, protobuf.Trade proto, CoreProtoResolv
trade.setTakerFeeTxId(ProtoUtil.stringOrNullFromProto(proto.getTakerFeeTxId()));
trade.setDepositTxId(ProtoUtil.stringOrNullFromProto(proto.getDepositTxId()));
trade.setPayoutTxId(ProtoUtil.stringOrNullFromProto(proto.getPayoutTxId()));
trade.setWithdrawalTxId(ProtoUtil.stringOrNullFromProto(proto.getWithdrawalTxId()));
trade.setContract(proto.hasContract() ? Contract.fromProto(proto.getContract(), coreProtoResolver) : null);
trade.setContractAsJson(ProtoUtil.stringOrNullFromProto(proto.getContractAsJson()));
trade.setContractHash(ProtoUtil.byteArrayOrNullFromProto(proto.getContractHash()));
Expand Down Expand Up @@ -1124,6 +1130,7 @@ public String toString() {
",\n takerFeeTxId='" + takerFeeTxId + '\'' +
",\n depositTxId='" + depositTxId + '\'' +
",\n payoutTxId='" + payoutTxId + '\'' +
",\n withdrawalTxId='" + withdrawalTxId + '\'' +
",\n tradeAmountAsLong=" + tradeAmountAsLong +
",\n tradePrice=" + tradePrice +
",\n tradingPeerNodeAddress=" + tradingPeerNodeAddress +
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/bisq/core/trade/TradeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ public void onSuccess(@javax.annotation.Nullable Transaction transaction) {
onTradeCompleted(trade);
trade.setState(Trade.State.WITHDRAW_COMPLETED);
getTradeProtocol(trade).onWithdrawCompleted();
trade.setWithdrawalTxId(transaction.getTxId().toString());
requestPersistence();
resultHandler.handleResult();
}
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ message Trade {
string counter_currency_extra_data = 37;
string asset_tx_proof_result = 38; // name of AssetTxProofResult enum
string uid = 39;
string withdrawal_tx_id = 40;
}

message BuyerAsMakerTrade {
Expand Down

0 comments on commit 6aa385e

Please sign in to comment.