Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not commit delayedPayoutTx to avoid publishing at restart #3464

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ message Trade {
repeated ChatMessage chat_message = 29;
MediationResultState mediation_result_state = 30;
int64 lock_time = 31;
string delayed_payout_tx_id = 32;
bytes delayed_payout_tx_bytes = 32;
NodeAddress refund_agent_node_address = 33;
PubKeyRing refund_agent_pub_key_ring = 34;
RefundResultState refund_result_state = 35;
Expand Down
20 changes: 12 additions & 8 deletions core/src/main/java/bisq/core/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public static protobuf.Trade.TradePeriodState toProtoMessage(Trade.TradePeriodSt
@Nullable
@Getter
@Setter
private String delayedPayoutTxId;
private byte[] delayedPayoutTxBytes;
@Nullable
@Getter
@Setter
Expand Down Expand Up @@ -525,7 +525,7 @@ public Message toProtoMessage() {
Optional.ofNullable(counterCurrencyTxId).ifPresent(e -> builder.setCounterCurrencyTxId(counterCurrencyTxId));
Optional.ofNullable(mediationResultState).ifPresent(e -> builder.setMediationResultState(MediationResultState.toProtoMessage(mediationResultState)));
Optional.ofNullable(refundResultState).ifPresent(e -> builder.setRefundResultState(RefundResultState.toProtoMessage(refundResultState)));
Optional.ofNullable(delayedPayoutTxId).ifPresent(e -> builder.setDelayedPayoutTxId(delayedPayoutTxId));
Optional.ofNullable(delayedPayoutTxBytes).ifPresent(e -> builder.setDelayedPayoutTxBytes(ByteString.copyFrom(delayedPayoutTxBytes)));
return builder.build();
}

Expand Down Expand Up @@ -555,8 +555,7 @@ public static Trade fromProto(Trade trade, protobuf.Trade proto, CoreProtoResolv
trade.setCounterCurrencyTxId(proto.getCounterCurrencyTxId().isEmpty() ? null : proto.getCounterCurrencyTxId());
trade.setMediationResultState(MediationResultState.fromProto(proto.getMediationResultState()));
trade.setRefundResultState(RefundResultState.fromProto(proto.getRefundResultState()));
String delayedPayoutTxId = proto.getDelayedPayoutTxId();
trade.setDelayedPayoutTxId(delayedPayoutTxId.isEmpty() ? null : delayedPayoutTxId);
trade.setDelayedPayoutTxBytes(ProtoUtil.byteArrayOrNullFromProto(proto.getDelayedPayoutTxBytes()));
trade.setLockTime(proto.getLockTime());

trade.chatMessages.addAll(proto.getChatMessageList().stream()
Expand Down Expand Up @@ -667,14 +666,19 @@ public Transaction getDepositTx() {

public void applyDelayedPayoutTx(Transaction delayedPayoutTx) {
this.delayedPayoutTx = delayedPayoutTx;
delayedPayoutTxId = delayedPayoutTx.getHashAsString();
persist();
}

public void applyDelayedPayoutTxBytes(byte[] delayedPayoutTxBytes) {
this.delayedPayoutTxBytes = delayedPayoutTxBytes;
persist();
}

@Nullable
public Transaction getDelayedPayoutTx() {
if (delayedPayoutTx == null)
delayedPayoutTx = delayedPayoutTxId != null ? btcWalletService.getTransaction(delayedPayoutTxId) : null;
if (delayedPayoutTx == null) {
delayedPayoutTx = delayedPayoutTxBytes != null ? processModel.getBtcWalletService().getTxFromSerializedTx(delayedPayoutTxBytes) : null;
}
return delayedPayoutTx;
}

Expand Down Expand Up @@ -1118,7 +1122,7 @@ public String toString() {
",\n mediationResultState=" + mediationResultState +
",\n mediationResultStateProperty=" + mediationResultStateProperty +
",\n lockTime=" + lockTime +
",\n delayedPayoutTxId='" + delayedPayoutTxId + '\'' +
",\n delayedPayoutTxBytes=" + Utilities.bytesAsHexString(delayedPayoutTxBytes) +
",\n refundAgentNodeAddress=" + refundAgentNodeAddress +
",\n refundAgentPubKeyRing=" + refundAgentPubKeyRing +
",\n refundResultState=" + refundResultState +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ protected void run() {
BtcWalletService.printTx("depositTx received from peer", committedDepositTx);

// To access tx confidence we need to add that tx into our wallet.
Transaction delayedPayoutTx = processModel.getBtcWalletService().getTxFromSerializedTx(message.getDelayedPayoutTx());
trade.applyDelayedPayoutTx(delayedPayoutTx);
BtcWalletService.printTx("delayedPayoutTx received from peer", delayedPayoutTx);

WalletService.maybeAddSelfTxToWallet(delayedPayoutTx, processModel.getBtcWalletService().getWallet());
byte[] delayedPayoutTxBytes = message.getDelayedPayoutTx();
trade.applyDelayedPayoutTxBytes(delayedPayoutTxBytes);
BtcWalletService.printTx("delayedPayoutTx received from peer", trade.getDelayedPayoutTx());

// update to the latest peer address of our peer if the message is correct
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import bisq.core.btc.model.AddressEntry;
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.WalletService;
import bisq.core.trade.Trade;
import bisq.core.trade.protocol.tasks.TradeTask;

Expand Down Expand Up @@ -66,7 +65,6 @@ protected void run() {
sellerSignature);

trade.applyDelayedPayoutTx(signedDelayedPayoutTx);
WalletService.maybeAddSelfTxToWallet(signedDelayedPayoutTx, processModel.getBtcWalletService().getWallet());

complete();
} catch (Throwable t) {
Expand Down