Rename API method keepfunds -> closetrade

Trade proceeds and deposits have already been transfered to Bisq wallets
before the `keepfunds` command is (was) executed;  `keepfunds` merely moves
open trades to closed trades lists and persistence files.  Renaming `keepfunds`
as `closetrade` makes its purpose clear to API users.

The commit modifies only method names and comments in api server+cli classes,
apitest cases, and api trade simulation scripts.

Based on `master`
This commit is contained in:
ghubstan 2022-01-05 12:10:46 -03:00
parent ce76389402
commit a9aaba87fa
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
25 changed files with 102 additions and 102 deletions

View File

@ -536,22 +536,22 @@ executetrade() {
printbreak
# Complete the trade on both sides
printdate "BOB $BOB_ROLE: Closing trade by keeping funds in Bisq wallet."
CMD="$CLI_BASE --port=$BOB_PORT keepfunds --trade-id=$OFFER_ID"
printdate "BOB $BOB_ROLE: Closing trade and keeping funds in Bisq wallet."
CMD="$CLI_BASE --port=$BOB_PORT closetrade --trade-id=$OFFER_ID"
printdate "BOB CLI: $CMD"
KEEP_FUNDS_MSG=$($CMD)
commandalert $? "Could close trade with keepfunds command."
# Print the keepfunds command's console output.
commandalert $? "Closed trade with closetrade command."
# Print the closetrade command's console output.
printdate "$KEEP_FUNDS_MSG"
sleeptraced 3
printbreak
printdate "ALICE (taker): Closing trade by keeping funds in Bisq wallet."
CMD="$CLI_BASE --port=$ALICE_PORT keepfunds --trade-id=$OFFER_ID"
printdate "ALICE (taker): Closing trade and keeping funds in Bisq wallet."
CMD="$CLI_BASE --port=$ALICE_PORT closetrade --trade-id=$OFFER_ID"
printdate "ALICE CLI: $CMD"
KEEP_FUNDS_MSG=$($CMD)
commandalert $? "Could close trade with keepfunds command."
# Print the keepfunds command's console output.
commandalert $? "Closed trade with closetrade command."
# Print the closetrade command's console output.
printdate "$KEEP_FUNDS_MSG"
sleeptraced 3
printbreak

View File

@ -162,10 +162,10 @@ public class TakeBuyBSQOfferTest extends AbstractTradeTest {
genBtcBlocksThenWait(1, 1_000);
var trade = bobClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before keeping funds", trade);
logTrade(log, testInfo, "Alice's view before closing trade", trade);
aliceClient.keepFunds(tradeId);
bobClient.keepFunds(tradeId);
aliceClient.closeTrade(tradeId);
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = bobClient.getTrade(tradeId);

View File

@ -137,9 +137,9 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
try {
genBtcBlocksThenWait(1, 1_000);
var trade = aliceClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before keeping funds", trade);
aliceClient.keepFunds(tradeId);
bobClient.keepFunds(tradeId);
logTrade(log, testInfo, "Alice's view before closing trade and keeping funds", trade);
aliceClient.closeTrade(tradeId);
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = aliceClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG).setPhase(PAYOUT_PUBLISHED);

View File

@ -213,9 +213,9 @@ public class TakeBuyBTCOfferWithNationalBankAcctTest extends AbstractTradeTest {
genBtcBlocksThenWait(1, 1_000);
var trade = aliceClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before keeping funds", trade);
aliceClient.keepFunds(tradeId);
bobClient.keepFunds(tradeId);
logTrade(log, testInfo, "Alice's view before closing trade and keeping funds", trade);
aliceClient.closeTrade(tradeId);
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = aliceClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG)

View File

@ -156,9 +156,9 @@ public class TakeBuyXMROfferTest extends AbstractTradeTest {
try {
genBtcBlocksThenWait(1, 1_000);
var trade = bobClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before keeping funds", trade);
aliceClient.keepFunds(tradeId);
bobClient.keepFunds(tradeId);
logTrade(log, testInfo, "Alice's view before closing trade and keeping funds", trade);
aliceClient.closeTrade(tradeId);
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = bobClient.getTrade(tradeId);

View File

@ -155,11 +155,14 @@ public class TakeSellBSQOfferTest extends AbstractTradeTest {
genBtcBlocksThenWait(1, 1_000);
var trade = aliceClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before withdrawing BTC funds to external wallet", trade);
logTrade(log,
testInfo,
"Alice's view before closing trade and withdrawing BTC funds to external wallet",
trade);
String toAddress = bitcoinCli.getNewBtcAddress();
aliceClient.withdrawFunds(tradeId, toAddress, WITHDRAWAL_TX_MEMO);
// Bob keeps funds.
bobClient.keepFunds(tradeId);
// Bob closes trade and keeps funds.
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = aliceClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(WITHDRAW_COMPLETED)

View File

@ -144,7 +144,7 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
logTrade(log, testInfo, "Bob's view before withdrawing funds to external wallet", trade);
String toAddress = bitcoinCli.getNewBtcAddress();
bobClient.withdrawFunds(tradeId, toAddress, WITHDRAWAL_TX_MEMO);
aliceClient.keepFunds(tradeId);
aliceClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = bobClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(WITHDRAW_COMPLETED)

View File

@ -165,7 +165,7 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {
String toAddress = bitcoinCli.getNewBtcAddress();
aliceClient.withdrawFunds(tradeId, toAddress, WITHDRAWAL_TX_MEMO);
bobClient.keepFunds(tradeId);
bobClient.closeTrade(tradeId);
genBtcBlocksThenWait(1, 1_000);
trade = aliceClient.getTrade(tradeId);

View File

@ -282,12 +282,12 @@ public class BotClient {
}
/**
* Sends a 'keep funds in wallet message' for a trade with the given tradeId,
* Sends a 'closetrade' for a trade with the given tradeId,
* or throws an exception.
* @param tradeId
*/
public void sendKeepFundsMessage(String tradeId) {
grpcClient.keepFunds(tradeId);
public void sendCloseTradeMessage(String tradeId) {
grpcClient.closeTrade(tradeId);
}
/**

View File

@ -219,8 +219,8 @@ public abstract class BotProtocol {
}
};
protected final Function<TradeInfo, TradeInfo> keepFundsFromTrade = (trade) -> {
initProtocolStep.accept(KEEP_FUNDS);
protected final Function<TradeInfo, TradeInfo> closeTrade = (trade) -> {
initProtocolStep.accept(CLOSE_TRADE);
var isBuy = trade.getOffer().getDirection().equalsIgnoreCase(BUY);
var isSell = trade.getOffer().getDirection().equalsIgnoreCase(SELL);
var cliUserIsSeller = (this instanceof MakerBotProtocol && isBuy) || (this instanceof TakerBotProtocol && isSell);
@ -229,8 +229,8 @@ public abstract class BotProtocol {
} else {
createGetBalanceScript();
}
checkIfShutdownCalled("Interrupted before closing trade with 'keep funds' command.");
this.getBotClient().sendKeepFundsMessage(trade.getTradeId());
checkIfShutdownCalled("Interrupted before closing trade with 'closetrade' command.");
this.getBotClient().sendCloseTradeMessage(trade.getTradeId());
return trade;
};

View File

@ -56,7 +56,7 @@ public class MakerBotProtocol extends BotProtocol {
: waitForPaymentStartedMessage.andThen(sendPaymentReceivedMessage);
completeFiatTransaction.apply(trade);
Function<TradeInfo, TradeInfo> closeTrade = waitForPayoutTx.andThen(keepFundsFromTrade);
Function<TradeInfo, TradeInfo> closeTrade = waitForPayoutTx.andThen(this.closeTrade);
closeTrade.apply(trade);
currentProtocolStep = DONE;

View File

@ -12,6 +12,6 @@ public enum ProtocolStep {
SEND_PAYMENT_RECEIVED_CONFIRMATION_MESSAGE,
WAIT_FOR_PAYMENT_RECEIVED_CONFIRMATION_MESSAGE,
WAIT_FOR_PAYOUT_TX,
KEEP_FUNDS,
CLOSE_TRADE,
DONE
}

View File

@ -55,7 +55,7 @@ public class TakerBotProtocol extends BotProtocol {
: sendPaymentStartedMessage.andThen(waitForPaymentReceivedConfirmation);
completeFiatTransaction.apply(trade);
Function<TradeInfo, TradeInfo> closeTrade = waitForPayoutTx.andThen(keepFundsFromTrade);
Function<TradeInfo, TradeInfo> closeTrade = waitForPayoutTx.andThen(this.closeTrade);
closeTrade.apply(trade);
currentProtocolStep = DONE;

View File

@ -167,10 +167,10 @@ public class BashScriptGenerator {
}
public File createKeepFundsScript(TradeInfo trade) {
String paymentStartedCmd = format("%s keepfunds --trade-id=%s", cliBase, trade.getTradeId());
String paymentStartedCmd = format("%s closetrade --trade-id=%s", cliBase, trade.getTradeId());
String getTradeCmd = format("%s gettrade --trade-id=%s", cliBase, trade.getTradeId());
String getBalanceCmd = format("%s getbalance", cliBase);
return createCliScript("keepfunds.sh",
return createCliScript("closetrade.sh",
paymentStartedCmd,
"sleep 2",
getTradeCmd,

View File

@ -525,15 +525,15 @@ public class CliMain {
out.printf("trade %s payment received message sent%n", tradeId);
return;
}
case keepfunds: {
case closetrade: {
var opts = new GetTradeOptionParser(args).parse();
if (opts.isForHelp()) {
out.println(client.getMethodHelp(method));
return;
}
var tradeId = opts.getTradeId();
client.keepFunds(tradeId);
out.printf("funds from trade %s saved in bisq wallet%n", tradeId);
client.closeTrade(tradeId);
out.printf("trade %s is closed%n", tradeId);
return;
}
case withdrawfunds: {
@ -864,10 +864,10 @@ public class CliMain {
stream.println();
stream.format(rowFormat, confirmpaymentreceived.name(), "--trade-id=<trade-id>", "Confirm payment received");
stream.println();
stream.format(rowFormat, keepfunds.name(), "--trade-id=<trade-id>", "Keep received funds in Bisq wallet");
stream.format(rowFormat, closetrade.name(), "--trade-id=<trade-id>", "Close completed trade");
stream.println();
stream.format(rowFormat, withdrawfunds.name(), "--trade-id=<trade-id> --address=<btc-address> \\",
"Withdraw received funds to external wallet address");
"Withdraw received trade funds to external wallet address");
stream.format(rowFormat, "", "[--memo=<\"memo\">]", "");
stream.println();
stream.format(rowFormat, getpaymentmethods.name(), "", "Get list of supported payment account method ids");

View File

@ -372,8 +372,8 @@ public final class GrpcClient {
tradesServiceRequest.confirmPaymentReceived(tradeId);
}
public void keepFunds(String tradeId) {
tradesServiceRequest.keepFunds(tradeId);
public void closeTrade(String tradeId) {
tradesServiceRequest.closeTrade(tradeId);
}
public void withdrawFunds(String tradeId, String address, String memo) {

View File

@ -22,6 +22,7 @@ package bisq.cli;
*/
public enum Method {
canceloffer,
closetrade,
confirmpaymentreceived,
confirmpaymentstarted,
createoffer,
@ -45,7 +46,6 @@ public enum Method {
gettxfeerate,
getunusedbsqaddress,
getversion,
keepfunds,
lockwallet,
registerdisputeagent,
removewalletpassword,

View File

@ -17,10 +17,10 @@
package bisq.cli.request;
import bisq.proto.grpc.CloseTradeRequest;
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
import bisq.proto.grpc.GetTradeRequest;
import bisq.proto.grpc.KeepFundsRequest;
import bisq.proto.grpc.TakeOfferReply;
import bisq.proto.grpc.TakeOfferRequest;
import bisq.proto.grpc.TradeInfo;
@ -86,12 +86,12 @@ public class TradesServiceRequest {
grpcStubs.tradesService.confirmPaymentReceived(request);
}
public void keepFunds(String tradeId) {
var request = KeepFundsRequest.newBuilder()
public void closeTrade(String tradeId) {
var request = CloseTradeRequest.newBuilder()
.setTradeId(tradeId)
.build();
//noinspection ResultOfMethodCallIgnored
grpcStubs.tradesService.keepFunds(request);
grpcStubs.tradesService.closeTrade(request);
}
public void withdrawFunds(String tradeId, String address, String memo) {

View File

@ -315,8 +315,8 @@ public class CoreApi {
coreTradesService.confirmPaymentReceived(tradeId);
}
public void keepFunds(String tradeId) {
coreTradesService.keepFunds(tradeId);
public void closeTrade(String tradeId) {
coreTradesService.closeTrade(tradeId);
}
public void withdrawFunds(String tradeId, String address, String memo) {

View File

@ -180,14 +180,14 @@ class CoreTradesService {
}
}
void keepFunds(String tradeId) {
void closeTrade(String tradeId) {
coreWalletsService.verifyWalletsAreAvailable();
coreWalletsService.verifyEncryptedWalletIsUnlocked();
verifyTradeIsNotClosed(tradeId);
var trade = getOpenTrade(tradeId).orElseThrow(() ->
new IllegalArgumentException(format("trade with id '%s' not found", tradeId)));
log.info("Keeping funds received from trade {}", tradeId);
log.info("Closing trade {}", tradeId);
tradeManager.onTradeCompleted(trade);
}

View File

@ -0,0 +1,29 @@
closetrade
NAME
----
closetrade - close open trade
SYNOPSIS
--------
closetrade
--trade-id=<trade-id>
DESCRIPTION
-----------
This final step in the trade protocol moves a completed trade from the open trades list
to the closed trade list, where it becomes part of the user's trade history.
The step is necessary for correct transition of a trade's state to CLOSED.
The alternative way to close a trade is to send the received BTC to an external
BTC wallet, using the withdrawfunds command.
OPTIONS
-------
--trade-id
The ID of the completed trade (the full offer-id).
EXAMPLES
--------
The BTC buyer or seller closes out trade 83e8b2e2-51b6-4f39-a748-3ebd29c22aea:
$ ./bisq-cli --password=xyz --port=9998 closetrade --trade-id=83e8b2e2-51b6-4f39-a748-3ebd29c22aea

View File

@ -1,31 +0,0 @@
keepfunds
NAME
----
keepfunds - keep BTC received during a trade in Bisq wallet
SYNOPSIS
--------
keepfunds
--trade-id=<trade-id>
DESCRIPTION
-----------
A BTC buyer completes the final step in the trade protocol by keeping received BTC in his
Bisq wallet. This step may not seem necessary from the buyer's perspective, but it is
necessary for correct transition of a trade's state to CLOSED, within the Bisq server.
The alternative way to close out the trade is to send the received BTC to an external
BTC wallet, using the withdrawfunds command.
OPTIONS
-------
--trade-id
The ID of the trade (the full offer-id).
EXAMPLES
--------
A BTC seller has informed the buyer that fiat payment has been received for trade with ID
83e8b2e2-51b6-4f39-a748-3ebd29c22aea, and locked BTC has been released to the buyer.
The BTC buyer closes out the trade by keeping the received BTC in her Bisq wallet:
$ ./bisq-cli --password=xyz --port=9998 keepfunds --trade-id=83e8b2e2-51b6-4f39-a748-3ebd29c22aea

View File

@ -2,7 +2,7 @@ withdrawfunds
NAME
----
withdrawfunds - send BTC received during a trade to an external BTC wallet
withdrawfunds - send BTC received during a trade to an external BTC wallet and close trade
SYNOPSIS
--------
@ -16,10 +16,10 @@ DESCRIPTION
A BTC buyer completes the final step in the trade protocol by sending received BTC to
an external BTC wallet.
The alternative way to close out the trade is to keep the received BTC in the Bisq wallet,
using the keepfunds command.
The alternative way to close out the trade is to keep the received BTC in the Bisq wallet
with the closetrade command.
The buyer needs to complete the trade protocol using the keepfunds or withdrawfunds or command.
The buyer needs to complete the trade protocol using the closetrade or withdrawfunds command.
This step may not seem necessary from the buyer's perspective, but it is necessary for correct
transition of a trade's state to CLOSED, within the Bisq server.
@ -29,11 +29,11 @@ OPTIONS
The ID of the trade (the full offer-id).
--address
The destination btc address for the send btc transaction.
The destination btc address for the btc transaction.
--memo
An optional memo to be saved with the send btc transaction.
A multi word memo must be enclosed in double quotes.
An optional memo to be saved with the btc transaction.
A multi-word memo must be enclosed in double quotes.
EXAMPLES
--------

View File

@ -23,14 +23,14 @@ import bisq.core.trade.model.TradeModel;
import bisq.core.trade.model.bisq_v1.Trade;
import bisq.core.trade.model.bsq_swap.BsqSwapTrade;
import bisq.proto.grpc.CloseTradeReply;
import bisq.proto.grpc.CloseTradeRequest;
import bisq.proto.grpc.ConfirmPaymentReceivedReply;
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
import bisq.proto.grpc.ConfirmPaymentStartedReply;
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
import bisq.proto.grpc.GetTradeReply;
import bisq.proto.grpc.GetTradeRequest;
import bisq.proto.grpc.KeepFundsReply;
import bisq.proto.grpc.KeepFundsRequest;
import bisq.proto.grpc.TakeOfferReply;
import bisq.proto.grpc.TakeOfferRequest;
import bisq.proto.grpc.WithdrawFundsReply;
@ -152,11 +152,11 @@ class GrpcTradesService extends TradesImplBase {
}
@Override
public void keepFunds(KeepFundsRequest req,
StreamObserver<KeepFundsReply> responseObserver) {
public void closeTrade(CloseTradeRequest req,
StreamObserver<CloseTradeReply> responseObserver) {
try {
coreApi.keepFunds(req.getTradeId());
var reply = KeepFundsReply.newBuilder().build();
coreApi.closeTrade(req.getTradeId());
var reply = CloseTradeReply.newBuilder().build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
} catch (Throwable cause) {
@ -189,10 +189,9 @@ class GrpcTradesService extends TradesImplBase {
new HashMap<>() {{
put(getGetTradeMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
put(getTakeOfferMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
// put(getTakeBsqSwapOfferMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
put(getConfirmPaymentStartedMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
put(getConfirmPaymentReceivedMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
put(getKeepFundsMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
put(getCloseTradeMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
put(getWithdrawFundsMethod().getFullMethodName(), new GrpcCallRateMeter(1, MINUTES));
}}
)));

View File

@ -394,7 +394,7 @@ service Trades {
}
rpc ConfirmPaymentReceived (ConfirmPaymentReceivedRequest) returns (ConfirmPaymentReceivedReply) {
}
rpc KeepFunds (KeepFundsRequest) returns (KeepFundsReply) {
rpc CloseTrade (CloseTradeRequest) returns (CloseTradeReply) {
}
rpc WithdrawFunds (WithdrawFundsRequest) returns (WithdrawFundsReply) {
}
@ -433,11 +433,11 @@ message GetTradeReply {
TradeInfo trade = 1;
}
message KeepFundsRequest {
message CloseTradeRequest {
string tradeId = 1;
}
message KeepFundsReply {
message CloseTradeReply {
}
message WithdrawFundsRequest {