From 5f571cccca5e1b3edf260e0f13a0cdc3fa2306ea Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 27 Dec 2021 12:05:17 -0300 Subject: [PATCH 1/3] Deprecate API 'getmyoffer' The method 'getoffer' should support looking up a user's open-offers, and other users' available offers. - Adjust api-beta-test-guide.md to use only 'getoffer'. - Adjust trade simulation scripts to use only 'getoffer'. - Adjust api testcases to use 'getoffer' in place of 'getmyoffer'. - Mark appropriate methods and protobuf msgs as deprecated. --- apitest/docs/api-beta-test-guide.md | 2 +- apitest/scripts/bsqswap-simulation.sh | 2 +- apitest/scripts/limit-order-simulation.sh | 2 +- apitest/scripts/rolling-offer-simulation.sh | 2 +- apitest/scripts/trade-simulation.sh | 2 +- apitest/scripts/trade-xmr-simulation.sh | 2 +- .../method/offer/BsqSwapOfferTest.java | 2 +- .../method/offer/CreateBSQOffersTest.java | 8 +-- .../offer/CreateOfferUsingFixedPriceTest.java | 6 +- ...CreateOfferUsingMarketPriceMarginTest.java | 10 +-- .../method/offer/CreateXMROffersTest.java | 8 +-- .../apitest/method/offer/EditOfferTest.java | 52 +++++++-------- .../method/trade/BsqSwapTradeTest.java | 2 +- .../LongRunningOfferDeactivationTest.java | 8 +-- cli/src/main/java/bisq/cli/CliMain.java | 2 +- cli/src/main/java/bisq/cli/GrpcClient.java | 2 + cli/src/main/java/bisq/cli/Method.java | 3 +- core/src/main/java/bisq/core/api/CoreApi.java | 9 +++ .../java/bisq/core/api/CoreOffersService.java | 64 +++++++++---------- .../bisq/daemon/grpc/GrpcOffersService.java | 13 +++- proto/src/main/proto/grpc.proto | 3 + 21 files changed, 113 insertions(+), 91 deletions(-) diff --git a/apitest/docs/api-beta-test-guide.md b/apitest/docs/api-beta-test-guide.md index 5eb57131f02..1d79ec1a00c 100644 --- a/apitest/docs/api-beta-test-guide.md +++ b/apitest/docs/api-beta-test-guide.md @@ -399,7 +399,7 @@ $ ./bisq-cli --password=xyz --port=9998 getmyoffers --direction= --cur To look at a specific offer you created: ``` -$ ./bisq-cli --password=xyz --port=9998 getmyoffer --offer-id= +$ ./bisq-cli --password=xyz --port=9998 getoffer --offer-id= ``` ### Browsing Available Offers diff --git a/apitest/scripts/bsqswap-simulation.sh b/apitest/scripts/bsqswap-simulation.sh index 482a0fc40c7..96ecf2cef40 100755 --- a/apitest/scripts/bsqswap-simulation.sh +++ b/apitest/scripts/bsqswap-simulation.sh @@ -60,7 +60,7 @@ sleeptraced 2 # Show Alice's new bsq swap offer. printdate "Alice looking at her new $DIRECTION $CURRENCY_CODE offer." -CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID" +CMD="$CLI_BASE --port=$ALICE_PORT getoffer --offer-id=$OFFER_ID" printdate "ALICE CLI: $CMD" OFFER=$($CMD) exitoncommandalert $? diff --git a/apitest/scripts/limit-order-simulation.sh b/apitest/scripts/limit-order-simulation.sh index 3ee50b63dda..5636b0758d2 100755 --- a/apitest/scripts/limit-order-simulation.sh +++ b/apitest/scripts/limit-order-simulation.sh @@ -135,7 +135,7 @@ sleeptraced 3 # Show Alice's new offer. printdate "ALICE: Looking at her new $DIRECTION $CURRENCY_CODE offer." -CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID" +CMD="$CLI_BASE --port=$ALICE_PORT getoffer --offer-id=$OFFER_ID" printdate "ALICE CLI: $CMD" OFFER=$($CMD) exitoncommandalert $? diff --git a/apitest/scripts/rolling-offer-simulation.sh b/apitest/scripts/rolling-offer-simulation.sh index 3bbfba4eb5f..48fc431f637 100755 --- a/apitest/scripts/rolling-offer-simulation.sh +++ b/apitest/scripts/rolling-offer-simulation.sh @@ -94,7 +94,7 @@ while : ; do # Show Alice's new offer. printdate "ALICE $ALICE_ROLE: Looking at her new $DIRECTION $CURRENCY_CODE offer." - CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID" + CMD="$CLI_BASE --port=$ALICE_PORT getoffer --offer-id=$OFFER_ID" printdate "ALICE CLI: $CMD" OFFER=$($CMD) exitoncommandalert $? diff --git a/apitest/scripts/trade-simulation.sh b/apitest/scripts/trade-simulation.sh index 0af66535aa5..5be7659cd48 100755 --- a/apitest/scripts/trade-simulation.sh +++ b/apitest/scripts/trade-simulation.sh @@ -95,7 +95,7 @@ sleeptraced 3 # Show Alice's new offer. printdate "ALICE $ALICE_ROLE: Looking at her new $DIRECTION $CURRENCY_CODE offer." -CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID" +CMD="$CLI_BASE --port=$ALICE_PORT getoffer --offer-id=$OFFER_ID" printdate "ALICE CLI: $CMD" OFFER=$($CMD) exitoncommandalert $? diff --git a/apitest/scripts/trade-xmr-simulation.sh b/apitest/scripts/trade-xmr-simulation.sh index 8d486496350..e361353da93 100755 --- a/apitest/scripts/trade-xmr-simulation.sh +++ b/apitest/scripts/trade-xmr-simulation.sh @@ -92,7 +92,7 @@ sleeptraced 3 # Show Alice's new offer. printdate "ALICE $ALICE_ROLE: Looking at her new $DIRECTION $CURRENCY_CODE offer." -CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID" +CMD="$CLI_BASE --port=$ALICE_PORT getoffer --offer-id=$OFFER_ID" printdate "ALICE CLI: $CMD" OFFER=$($CMD) exitoncommandalert $? diff --git a/apitest/src/test/java/bisq/apitest/method/offer/BsqSwapOfferTest.java b/apitest/src/test/java/bisq/apitest/method/offer/BsqSwapOfferTest.java index 2810938f5c3..c506794201e 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/BsqSwapOfferTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/BsqSwapOfferTest.java @@ -132,7 +132,7 @@ private void testGetMyBsqSwapOffer(OfferInfo bsqSwapOffer) { while (true) { try { numFetchAttempts++; - var fetchedBsqSwapOffer = aliceClient.getMyOffer(bsqSwapOffer.getId()); + var fetchedBsqSwapOffer = aliceClient.getOffer(bsqSwapOffer.getId()); assertEquals(bsqSwapOffer.getId(), fetchedBsqSwapOffer.getId()); log.debug("Alice found her (my) new bsq swap offer on attempt # {}.", numFetchAttempts); break; diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateBSQOffersTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateBSQOffersTest.java index 0f2c9702845..43f87fd1568 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/CreateBSQOffersTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateBSQOffersTest.java @@ -85,7 +85,7 @@ public void testCreateBuy1BTCFor20KBSQOffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -132,7 +132,7 @@ public void testCreateSell1BTCFor20KBSQOffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -179,7 +179,7 @@ public void testCreateBuyBTCWith1To2KBSQOffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -226,7 +226,7 @@ public void testCreateSellBTCFor5To10KBSQOffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java index d24840f6697..7ec7d98d1d4 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java @@ -75,7 +75,7 @@ public void testCreateAUDBTCBuyOfferUsingFixedPrice16000() { assertEquals("AUD", newOffer.getCounterCurrencyCode()); assertFalse(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -120,7 +120,7 @@ public void testCreateUSDBTCBuyOfferUsingFixedPrice100001234() { assertEquals(USD, newOffer.getCounterCurrencyCode()); assertFalse(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -165,7 +165,7 @@ public void testCreateEURBTCSellOfferUsingFixedPrice95001234() { assertEquals(EUR, newOffer.getCounterCurrencyCode()); assertFalse(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java index f40565ed612..cce443206a3 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java @@ -96,7 +96,7 @@ public void testCreateUSDBTCBuyOffer5PctPriceMargin() { assertEquals(USD, newOffer.getCounterCurrencyCode()); assertTrue(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -143,7 +143,7 @@ public void testCreateNZDBTCBuyOfferMinus2PctPriceMargin() { assertEquals("NZD", newOffer.getCounterCurrencyCode()); assertTrue(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -190,7 +190,7 @@ public void testCreateGBPBTCSellOfferMinus1Point5PctPriceMargin() { assertEquals("GBP", newOffer.getCounterCurrencyCode()); assertTrue(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -237,7 +237,7 @@ public void testCreateBRLBTCSellOffer6Point55PctPriceMargin() { assertEquals("BRL", newOffer.getCounterCurrencyCode()); assertTrue(newOffer.getIsCurrencyForMakerFeeBtc()); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -276,7 +276,7 @@ public void testCreateUSDBTCBuyOfferWithTriggerPrice() { assertTrue(newOffer.getIsMyPendingOffer()); genBtcBlocksThenWait(1, 4000); // give time to add to offer book - newOffer = aliceClient.getMyOffer(newOffer.getId()); + newOffer = aliceClient.getOffer(newOffer.getId()); log.debug("OFFER #5:\n{}", toOfferTable.apply(newOffer)); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java index 6cf609498a5..cf40632e8d9 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java @@ -88,7 +88,7 @@ public void testCreateFixedPriceBuy1BTCFor200KXMROffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -135,7 +135,7 @@ public void testCreateFixedPriceSell1BTCFor200KXMROffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); @@ -188,7 +188,7 @@ public void testCreatePriceMarginBasedBuy1BTCOfferWithTriggerPrice() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); log.debug("Available Sell XMR (Buy BTC) offer:\n{}", toOfferTable.apply(newOffer)); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); @@ -240,7 +240,7 @@ public void testCreatePriceMarginBasedSell1BTCOffer() { genBtcBlockAndWaitForOfferPreparation(); - newOffer = aliceClient.getMyOffer(newOfferId); + newOffer = aliceClient.getOffer(newOfferId); assertTrue(newOffer.getIsMyOffer()); assertFalse(newOffer.getIsMyPendingOffer()); assertEquals(newOfferId, newOffer.getId()); diff --git a/apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java b/apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java index 70e7ce7a962..33944dece8d 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java @@ -68,19 +68,19 @@ public void testOfferDisableAndEnable() { log.debug("Original EUR offer:\n{}", toOfferTable.apply(originalOffer)); assertFalse(originalOffer.getIsActivated()); // Not activated until prep is done. genBtcBlocksThenWait(1, 2_500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); assertTrue(originalOffer.getIsActivated()); // Disable offer aliceClient.editOfferActivationState(originalOffer.getId(), DEACTIVATE_OFFER); genBtcBlocksThenWait(1, 1500); // Wait for offer book removal. - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited EUR offer:\n{}", toOfferTable.apply(editedOffer)); assertFalse(editedOffer.getIsActivated()); assertTrue(editedOffer.getUseMarketBasedPrice()); // Re-enable offer aliceClient.editOfferActivationState(editedOffer.getId(), ACTIVATE_OFFER); genBtcBlocksThenWait(1, 1500); // Wait for offer book re-entry. - editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited EUR offer:\n{}", toOfferTable.apply(editedOffer)); assertTrue(editedOffer.getIsActivated()); assertTrue(editedOffer.getUseMarketBasedPrice()); @@ -99,7 +99,7 @@ public void testEditTriggerPrice() { NO_TRIGGER_PRICE); log.debug("Original EUR offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2_500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); assertEquals(0 /*no trigger price*/, originalOffer.getTriggerPrice()); // Edit the offer's trigger price, nothing else. @@ -109,7 +109,7 @@ public void testEditTriggerPrice() { aliceClient.editOfferTriggerPrice(originalOffer.getId(), newTriggerPriceAsLong); sleep(2_500); // Wait for offer book re-entry. - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited EUR offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(newTriggerPriceAsLong, editedOffer.getTriggerPrice()); assertTrue(editedOffer.getUseMarketBasedPrice()); @@ -153,7 +153,7 @@ public void testEditMktPriceMargin() { // Edit the offer's price margin, nothing else. var newMktPriceMargin = new BigDecimal("0.5").doubleValue(); aliceClient.editOfferPriceMargin(originalOffer.getId(), newMktPriceMargin); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited USD offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledDownMktPriceMargin.apply(newMktPriceMargin), editedOffer.getMarketPriceMargin()); assertTrue(editedOffer.getUseMarketBasedPrice()); @@ -178,7 +178,7 @@ public void testEditFixedPrice() { aliceClient.editOfferFixedPrice(originalOffer.getId(), editedFixedPriceAsString); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited RUB offer:\n{}", toOfferTable.apply(editedOffer)); var expectedNewFixedPrice = scaledUpFiatOfferPrice.apply(new BigDecimal(editedFixedPriceAsString)); assertEquals(expectedNewFixedPrice, editedOffer.getPrice()); @@ -210,7 +210,7 @@ public void testEditFixedPriceAndDeactivation() { FIXED_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited RUB offer:\n{}", toOfferTable.apply(editedOffer)); var expectedNewFixedPrice = scaledUpFiatOfferPrice.apply(new BigDecimal(editedFixedPriceAsString)); assertEquals(expectedNewFixedPrice, editedOffer.getPrice()); @@ -233,7 +233,7 @@ public void testEditMktPriceMarginAndDeactivation() { 0); log.debug("Original USD offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2_500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); assertEquals(scaledDownMktPriceMargin.apply(originalMktPriceMargin), originalOffer.getMarketPriceMargin()); // Edit the offer's price margin and trigger price, and deactivate it. @@ -247,7 +247,7 @@ public void testEditMktPriceMarginAndDeactivation() { MKT_PRICE_MARGIN_AND_ACTIVATION_STATE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited USD offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledDownMktPriceMargin.apply(newMktPriceMargin), editedOffer.getMarketPriceMargin()); assertEquals(0, editedOffer.getTriggerPrice()); @@ -271,7 +271,7 @@ public void testEditMktPriceMarginAndTriggerPriceAndDeactivation() { originalTriggerPriceAsLong); log.debug("Original USD offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2_500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); assertEquals(scaledDownMktPriceMargin.apply(originalMktPriceMargin), originalOffer.getMarketPriceMargin()); assertEquals(originalTriggerPriceAsLong, originalOffer.getTriggerPrice()); @@ -287,7 +287,7 @@ public void testEditMktPriceMarginAndTriggerPriceAndDeactivation() { MKT_PRICE_MARGIN_AND_TRIGGER_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited USD offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledDownMktPriceMargin.apply(newMktPriceMargin), editedOffer.getMarketPriceMargin()); assertEquals(newTriggerPriceAsLong, editedOffer.getTriggerPrice()); @@ -375,7 +375,7 @@ public void testChangeFixedPriceOfferToPriceMarginBasedOfferWithTriggerPrice() { MKT_PRICE_MARGIN_AND_TRIGGER_PRICE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited MXN offer:\n{}", toOfferTable.apply(editedOffer)); assertTrue(editedOffer.getUseMarketBasedPrice()); assertEquals(scaledDownMktPriceMargin.apply(newMktPriceMargin), editedOffer.getMarketPriceMargin()); @@ -411,7 +411,7 @@ public void testChangePriceMarginBasedOfferToFixedPriceOfferAndDeactivateIt() { FIXED_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited GBP offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledUpFiatOfferPrice.apply(new BigDecimal(fixedPriceAsString)), editedOffer.getPrice()); assertFalse(editedOffer.getUseMarketBasedPrice()); @@ -499,7 +499,7 @@ public void testEditFixedPriceOnBsqOffer() { FIXED_PRICE_ONLY); // Wait for edited offer to be edited and removed from offer-book. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited BSQ offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledUpAltcoinOfferPrice.apply(newFixedPriceAsString), editedOffer.getPrice()); assertTrue(editedOffer.getIsActivated()); @@ -531,7 +531,7 @@ public void testDisableBsqOffer() { ACTIVATION_STATE_ONLY); // Wait for edited offer to be removed from offer-book. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited BSQ offer:\n{}", toOfferTable.apply(editedOffer)); assertFalse(editedOffer.getIsActivated()); assertEquals(scaledUpAltcoinOfferPrice.apply(fixedPriceAsString), editedOffer.getPrice()); @@ -564,7 +564,7 @@ public void testEditFixedPriceAndDisableBsqOffer() { FIXED_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be edited and removed from offer-book. genBtcBlocksThenWait(1, 2_500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited BSQ offer:\n{}", toOfferTable.apply(editedOffer)); assertFalse(editedOffer.getIsActivated()); assertEquals(scaledUpAltcoinOfferPrice.apply(newFixedPriceAsString), editedOffer.getPrice()); @@ -589,7 +589,7 @@ public void testChangePriceMarginBasedXmrOfferWithTriggerPriceToFixedPricedAndDe log.debug("Pending XMR offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Original XMR offer:\n{}", toOfferTable.apply(originalOffer)); String newFixedPriceAsString = calcPriceAsString.apply(mktPriceAsDouble, -0.001); @@ -602,7 +602,7 @@ public void testChangePriceMarginBasedXmrOfferWithTriggerPriceToFixedPricedAndDe FIXED_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be removed from offer-book, edited & not re-published. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledUpAltcoinOfferPrice.apply(newFixedPriceAsString), editedOffer.getPrice()); assertFalse(editedOffer.getUseMarketBasedPrice()); @@ -626,7 +626,7 @@ public void testEditTriggerPriceOnPriceMarginBasedXmrOffer() { log.debug("Pending XMR offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); log.info("Original XMR offer:\n{}", toOfferTable.apply(originalOffer)); double mktPriceAsDouble = aliceClient.getBtcPrice(XMR); @@ -640,7 +640,7 @@ public void testEditTriggerPriceOnPriceMarginBasedXmrOffer() { TRIGGER_PRICE_ONLY); // Wait for edited offer to be removed from offer-book, edited & not re-published. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.info("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertTrue(editedOffer.getUseMarketBasedPrice()); assertEquals(scaledDownMktPriceMargin.apply(mktPriceMargin), editedOffer.getMarketPriceMargin()); @@ -667,7 +667,7 @@ public void testChangeFixedPricedXmrOfferToPriceMarginBasedOfferWithTriggerPrice log.debug("Pending XMR offer:\n{}", toOfferTable.apply(originalOffer)); genBtcBlocksThenWait(1, 2500); // Wait for offer book entry. - originalOffer = aliceClient.getMyOffer(originalOffer.getId()); + originalOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Original XMR offer:\n{}", toOfferTable.apply(originalOffer)); // Change the offer to mkt price based and set a trigger price. @@ -683,7 +683,7 @@ public void testChangeFixedPricedXmrOfferToPriceMarginBasedOfferWithTriggerPrice MKT_PRICE_MARGIN_AND_TRIGGER_PRICE); // Wait for edited offer to be removed from offer-book, edited, and re-published. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertTrue(editedOffer.getUseMarketBasedPrice()); assertEquals(scaledDownMktPriceMargin.apply(newMktPriceMargin), editedOffer.getMarketPriceMargin()); @@ -748,7 +748,7 @@ public void testEditFixedPriceOnXmrOffer() { FIXED_PRICE_ONLY); // Wait for edited offer to be edited and removed from offer-book. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertEquals(scaledUpAltcoinOfferPrice.apply(newFixedPriceAsString), editedOffer.getPrice()); assertTrue(editedOffer.getIsActivated()); @@ -781,7 +781,7 @@ public void testDisableXmrOffer() { ACTIVATION_STATE_ONLY); // Wait for edited offer to be removed from offer-book. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertFalse(editedOffer.getIsActivated()); assertEquals(scaledUpAltcoinOfferPrice.apply(fixedPriceAsString), editedOffer.getPrice()); @@ -815,7 +815,7 @@ public void testEditFixedPriceAndDisableXmrOffer() { FIXED_PRICE_AND_ACTIVATION_STATE); // Wait for edited offer to be edited and removed from offer-book. genBtcBlocksThenWait(1, 2500); - OfferInfo editedOffer = aliceClient.getMyOffer(originalOffer.getId()); + OfferInfo editedOffer = aliceClient.getOffer(originalOffer.getId()); log.debug("Edited XMR offer:\n{}", toOfferTable.apply(editedOffer)); assertFalse(editedOffer.getIsActivated()); assertEquals(scaledUpAltcoinOfferPrice.apply(newFixedPriceAsString), editedOffer.getPrice()); diff --git a/apitest/src/test/java/bisq/apitest/method/trade/BsqSwapTradeTest.java b/apitest/src/test/java/bisq/apitest/method/trade/BsqSwapTradeTest.java index 8938231c74a..bbf2074c7be 100644 --- a/apitest/src/test/java/bisq/apitest/method/trade/BsqSwapTradeTest.java +++ b/apitest/src/test/java/bisq/apitest/method/trade/BsqSwapTradeTest.java @@ -98,7 +98,7 @@ public void testAliceCreateBsqSwapBuyOffer() { genBtcBlocksThenWait(1, 2_500); - mySwapOffer = aliceClient.getMyOffer(newOfferId); + mySwapOffer = aliceClient.getOffer(newOfferId); log.debug("My fetched BsqSwap Sell BSQ (Buy BTC) OFFER:\n{}", toOfferTable.apply(mySwapOffer)); assertNotEquals(0, mySwapOffer.getMakerFee()); diff --git a/apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java b/apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java index 39660d42a31..61904bfad8b 100644 --- a/apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java +++ b/apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java @@ -75,13 +75,13 @@ public void testSellOfferAutoDisable(final TestInfo testInfo) { formatPrice(offer.getPrice())); genBtcBlocksThenWait(1, 2500); // Wait for offer book entry. - offer = aliceClient.getMyOffer(offer.getId()); // Offer has trigger price now. + offer = aliceClient.getOffer(offer.getId()); // Offer has trigger price now. log.info("SELL offer should be automatically disabled when mkt price falls below {}.", formatPrice(offer.getTriggerPrice())); int numIterations = 0; while (++numIterations < MAX_ITERATIONS) { - offer = aliceClient.getMyOffer(offer.getId()); + offer = aliceClient.getOffer(offer.getId()); var mktPrice = aliceClient.getBtcPrice("USD"); if (offer.getIsActivated()) { @@ -123,13 +123,13 @@ public void testBuyOfferAutoDisable(final TestInfo testInfo) { formatPrice(offer.getPrice())); genBtcBlocksThenWait(1, 2500); // Wait for offer book entry. - offer = aliceClient.getMyOffer(offer.getId()); // Offer has trigger price now. + offer = aliceClient.getOffer(offer.getId()); // Offer has trigger price now. log.info("BUY offer should be automatically disabled when mkt price rises above {}.", formatPrice(offer.getTriggerPrice())); int numIterations = 0; while (++numIterations < MAX_ITERATIONS) { - offer = aliceClient.getMyOffer(offer.getId()); + offer = aliceClient.getOffer(offer.getId()); var mktPrice = aliceClient.getBtcPrice("USD"); if (offer.getIsActivated()) { diff --git a/cli/src/main/java/bisq/cli/CliMain.java b/cli/src/main/java/bisq/cli/CliMain.java index 5689fbdad0a..1170774e3e7 100644 --- a/cli/src/main/java/bisq/cli/CliMain.java +++ b/cli/src/main/java/bisq/cli/CliMain.java @@ -753,7 +753,7 @@ private static long toInternalTriggerPrice(GrpcClient client, // how to scale the trigger-price (for a fiat or altcoin offer) param sent // to the server in its 'editoffer' request. That means a preliminary round // trip to the server: a 'getmyoffer' request. - var offer = client.getMyOffer(offerId); + var offer = client.getOffer(offerId); if (offer.getCounterCurrencyCode().equals("BTC")) return toInternalCryptoCurrencyPrice(unscaledTriggerPrice); else diff --git a/cli/src/main/java/bisq/cli/GrpcClient.java b/cli/src/main/java/bisq/cli/GrpcClient.java index 17eb49e43ca..99af68ca30d 100644 --- a/cli/src/main/java/bisq/cli/GrpcClient.java +++ b/cli/src/main/java/bisq/cli/GrpcClient.java @@ -274,6 +274,8 @@ public OfferInfo getMyBsqSwapOffer(String offerId) { return offersServiceRequest.getMyBsqSwapOffer(offerId); } + @Deprecated // Since 5-Dec-2021. + // Endpoint to be removed from future version. Use getOffer service method instead. public OfferInfo getMyOffer(String offerId) { return offersServiceRequest.getMyOffer(offerId); } diff --git a/cli/src/main/java/bisq/cli/Method.java b/cli/src/main/java/bisq/cli/Method.java index 76011877310..273150aad5d 100644 --- a/cli/src/main/java/bisq/cli/Method.java +++ b/cli/src/main/java/bisq/cli/Method.java @@ -32,7 +32,8 @@ public enum Method { getbalance, getbtcprice, getfundingaddresses, - getmyoffer, + @Deprecated // Since 27-Dec-2021. + getmyoffer, // Endpoint to be removed from future version. Use getoffer instead. getmyoffers, getoffer, getoffers, diff --git a/core/src/main/java/bisq/core/api/CoreApi.java b/core/src/main/java/bisq/core/api/CoreApi.java index 137f81c74c2..9808d2e7d9f 100644 --- a/core/src/main/java/bisq/core/api/CoreApi.java +++ b/core/src/main/java/bisq/core/api/CoreApi.java @@ -46,6 +46,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.function.Consumer; @@ -140,10 +141,18 @@ public Offer getOffer(String id) { return coreOffersService.getOffer(id); } + public Optional findAvailableOffer(String id) { + return coreOffersService.findAvailableOffer(id); + } + public OpenOffer getMyOffer(String id) { return coreOffersService.getMyOffer(id); } + public Optional findMyOpenOffer(String id) { + return coreOffersService.findMyOpenOffer(id); + } + public Offer getMyBsqSwapOffer(String id) { return coreOffersService.getMyBsqSwapOffer(id); } diff --git a/core/src/main/java/bisq/core/api/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java index ce6219d20c2..f321ad17d0c 100644 --- a/core/src/main/java/bisq/core/api/CoreOffersService.java +++ b/core/src/main/java/bisq/core/api/CoreOffersService.java @@ -145,21 +145,53 @@ Offer getOffer(String id) { new IllegalStateException(format("offer with id '%s' not found", id))); } + Optional findAvailableOffer(String id) { + return offerBookService.getOffers().stream() + .filter(o -> o.getId().equals(id)) + .filter(o -> !o.isMyOffer(keyRing)) + .filter(o -> offerFilterService.canTakeOffer(o, coreContext.isApiUser()).isValid()) + .findAny(); + } + OpenOffer getMyOffer(String id) { return findMyOpenOffer(id).orElseThrow(() -> new IllegalStateException(format("offer with id '%s' not found", id))); } + Optional findMyOpenOffer(String id) { + return openOfferManager.getObservableList().stream() + .filter(o -> o.getId().equals(id)) + .filter(o -> o.getOffer().isMyOffer(keyRing)) + .findAny(); + } + Offer getBsqSwapOffer(String id) { return findAvailableBsqSwapOffer(id).orElseThrow(() -> new IllegalStateException(format("offer with id '%s' not found", id))); } + Optional findAvailableBsqSwapOffer(String id) { + return offerBookService.getOffers().stream() + .filter(o -> o.getId().equals(id)) + .filter(o -> !o.isMyOffer(keyRing)) + .filter(o -> offerFilterService.canTakeOffer(o, coreContext.isApiUser()).isValid()) + .filter(Offer::isBsqSwapOffer) + .findAny(); + } + Offer getMyBsqSwapOffer(String id) { return findMyBsqSwapOffer(id).orElseThrow(() -> new IllegalStateException(format("offer with id '%s' not found", id))); } + Optional findMyBsqSwapOffer(String id) { + return offerBookService.getOffers().stream() + .filter(o -> o.getId().equals(id)) + .filter(o -> o.isMyOffer(keyRing)) + .filter(Offer::isBsqSwapOffer) + .findAny(); + } + List getBsqSwapOffers(String direction) { return offerBookService.getOffers().stream() .filter(o -> !o.isMyOffer(keyRing)) @@ -364,38 +396,6 @@ private void placeOffer(Offer offer, throw new IllegalStateException(offer.getErrorMessage()); } - private Optional findAvailableBsqSwapOffer(String id) { - return offerBookService.getOffers().stream() - .filter(o -> o.getId().equals(id)) - .filter(o -> !o.isMyOffer(keyRing)) - .filter(o -> offerFilterService.canTakeOffer(o, coreContext.isApiUser()).isValid()) - .filter(Offer::isBsqSwapOffer) - .findAny(); - } - - private Optional findMyBsqSwapOffer(String id) { - return offerBookService.getOffers().stream() - .filter(o -> o.getId().equals(id)) - .filter(o -> o.isMyOffer(keyRing)) - .filter(Offer::isBsqSwapOffer) - .findAny(); - } - - private Optional findAvailableOffer(String id) { - return offerBookService.getOffers().stream() - .filter(o -> o.getId().equals(id)) - .filter(o -> !o.isMyOffer(keyRing)) - .filter(o -> offerFilterService.canTakeOffer(o, coreContext.isApiUser()).isValid()) - .findAny(); - } - - private Optional findMyOpenOffer(String id) { - return openOfferManager.getObservableList().stream() - .filter(o -> o.getId().equals(id)) - .filter(o -> o.getOffer().isMyOffer(keyRing)) - .findAny(); - } - private OfferPayload getMergedOfferPayload(EditOfferValidator editOfferValidator, OpenOffer openOffer, String editedPriceAsString, diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java index edfa09a3d6d..f49881e1713 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java @@ -58,6 +58,7 @@ import lombok.extern.slf4j.Slf4j; +import static bisq.core.api.model.OfferInfo.toMyOfferInfo; import static bisq.core.api.model.OfferInfo.toMyPendingOfferInfo; import static bisq.core.api.model.OfferInfo.toOfferInfo; import static bisq.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; @@ -122,9 +123,13 @@ public void getBsqSwapOffer(GetOfferRequest req, public void getOffer(GetOfferRequest req, StreamObserver responseObserver) { try { - Offer offer = coreApi.getOffer(req.getId()); + String offerId = req.getId(); + Optional myOpenOffer = coreApi.findMyOpenOffer(offerId); + OfferInfo offerInfo = myOpenOffer.isPresent() + ? toMyOfferInfo(myOpenOffer.get()) + : toOfferInfo(coreApi.getOffer(offerId)); var reply = GetOfferReply.newBuilder() - .setOffer(toOfferInfo(offer).toProtoMessage()) + .setOffer(offerInfo.toProtoMessage()) .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); @@ -148,13 +153,15 @@ public void getMyBsqSwapOffer(GetMyOfferRequest req, } } + @Deprecated // Since 27-Dec-2021. + // Endpoint to be removed from future version. Use getOffer service method instead. @Override public void getMyOffer(GetMyOfferRequest req, StreamObserver responseObserver) { try { OpenOffer openOffer = coreApi.getMyOffer(req.getId()); var reply = GetMyOfferReply.newBuilder() - .setOffer(OfferInfo.toMyOfferInfo(openOffer).toProtoMessage()) + .setOffer(toMyOfferInfo(openOffer).toProtoMessage()) .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 10a90940db9..646ab0a85c8 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -70,6 +70,7 @@ service Offers { } rpc GetMyBsqSwapOffer (GetMyOfferRequest) returns (GetMyBsqSwapOfferReply) { } + // @Deprecated since 27-Dec-2021 (v1.8.0) rpc GetMyOffer (GetMyOfferRequest) returns (GetMyOfferReply) { } rpc GetBsqSwapOffers (GetBsqSwapOffersRequest) returns (GetBsqSwapOffersReply) { @@ -121,10 +122,12 @@ message GetMyBsqSwapOfferReply { OfferInfo bsqSwapOffer = 1; } +// @Deprecated since 27-Dec-2021 (v1.8.0) message GetMyOfferRequest { string id = 1; } +// @Deprecated since 27-Dec-2021 (v1.8.0) message GetMyOfferReply { OfferInfo offer = 1; } From cb4df2b1c3e9b4f3c8d5ec1190f1ddcbbeed1f2a Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 27 Dec 2021 13:10:16 -0300 Subject: [PATCH 2/3] Rename CLI opt '--payment-account' -> '--payment-account-id' Adjust related docs and scripts. --- apitest/docs/api-beta-test-guide.md | 10 +++++----- .../java/bisq/cli/opts/CreateOfferOptionParser.java | 2 +- cli/src/main/java/bisq/cli/opts/OptLabel.java | 2 +- .../java/bisq/cli/opts/TakeOfferOptionParser.java | 4 ++-- .../test/java/bisq/cli/opts/OptionParsersTest.java | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apitest/docs/api-beta-test-guide.md b/apitest/docs/api-beta-test-guide.md index 1d79ec1a00c..f0d2593bb94 100644 --- a/apitest/docs/api-beta-test-guide.md +++ b/apitest/docs/api-beta-test-guide.md @@ -345,7 +345,7 @@ and pay the Bisq maker fee in BSQ. Alice had already created an EUR face-to-fac `f3c1ec8b-9761-458d-b13d-9039c6892413`, and used this `createoffer` command: ``` $ ./bisq-cli --password=xyz --port=9998 createoffer \ - --payment-account=f3c1ec8b-9761-458d-b13d-9039c6892413 \ + --payment-account-id=f3c1ec8b-9761-458d-b13d-9039c6892413 \ --direction=BUY \ --currency-code=EUR \ --amount=0.125 \ @@ -358,7 +358,7 @@ If Alice was in Japan, and wanted to create an offer to sell 0.125 BTC at 0.5% a putting up a 15% security deposit, the `createoffer` command to do that would be: ``` $ ./bisq-cli --password=xyz --port=9998 createoffer \ - --payment-account=f3c1ec8b-9761-458d-b13d-9039c6892413 \ + --payment-account-id=f3c1ec8b-9761-458d-b13d-9039c6892413 \ --direction=SELL \ --currency-code=JPY \ --amount=0.125 \ @@ -466,7 +466,7 @@ and vice-versa. Suppose you used `createoffer` to create a market price margin based offer as follows: ``` $ ./bisq-cli --password=xyz --port=9998 createoffer \ - --payment-account=f3c1ec8b-9761-458d-b13d-9039c6892413 \ + --payment-account-id=f3c1ec8b-9761-458d-b13d-9039c6892413 \ --direction=SELL \ --currency-code=JPY \ --amount=0.125 \ @@ -485,7 +485,7 @@ To change the market price margin based offer to a fixed price offer: Suppose you used `createoffer` to create a fixed price offer as follows: ``` $ ./bisq-cli --password=xyz --port=9998 createoffer \ - --payment-account=f3c1ec8b-9761-458d-b13d-9039c6892413 \ + --payment-account-id=f3c1ec8b-9761-458d-b13d-9039c6892413 \ --direction=SELL \ --currency-code=JPY \ --amount=0.125 \ @@ -551,7 +551,7 @@ with the `takeoffer` command: ``` $ ./bisq-cli --password=xyz --port=9998 takeoffer \ --offer-id=83e8b2e2-51b6-4f39-a748-3ebd29c22aea \ - --payment-account=fe20cdbd-22be-4b8a-a4b6-d2608ff09d6e \ + --payment-account-id=fe20cdbd-22be-4b8a-a4b6-d2608ff09d6e \ --fee-currency=btc ``` Depending on the offer type, the taken offer will be used to (1) create a trade contract, or (2) execute a BSQ swap. diff --git a/cli/src/main/java/bisq/cli/opts/CreateOfferOptionParser.java b/cli/src/main/java/bisq/cli/opts/CreateOfferOptionParser.java index a9788a8956a..5c338434815 100644 --- a/cli/src/main/java/bisq/cli/opts/CreateOfferOptionParser.java +++ b/cli/src/main/java/bisq/cli/opts/CreateOfferOptionParser.java @@ -28,7 +28,7 @@ public class CreateOfferOptionParser extends AbstractMethodOptionParser implements MethodOpts { - final OptionSpec paymentAccountIdOpt = parser.accepts(OPT_PAYMENT_ACCOUNT, + final OptionSpec paymentAccountIdOpt = parser.accepts(OPT_PAYMENT_ACCOUNT_ID, "id of payment account used for offer") .withRequiredArg() .defaultsTo(EMPTY); diff --git a/cli/src/main/java/bisq/cli/opts/OptLabel.java b/cli/src/main/java/bisq/cli/opts/OptLabel.java index 7dc78165d7a..5caeb1f05e6 100644 --- a/cli/src/main/java/bisq/cli/opts/OptLabel.java +++ b/cli/src/main/java/bisq/cli/opts/OptLabel.java @@ -37,7 +37,7 @@ public class OptLabel { public final static String OPT_MIN_AMOUNT = "min-amount"; public final static String OPT_OFFER_ID = "offer-id"; public final static String OPT_PASSWORD = "password"; - public final static String OPT_PAYMENT_ACCOUNT = "payment-account"; + public final static String OPT_PAYMENT_ACCOUNT_ID = "payment-account-id"; public final static String OPT_PAYMENT_ACCOUNT_FORM = "payment-account-form"; public final static String OPT_PAYMENT_METHOD_ID = "payment-method-id"; public final static String OPT_PORT = "port"; diff --git a/cli/src/main/java/bisq/cli/opts/TakeOfferOptionParser.java b/cli/src/main/java/bisq/cli/opts/TakeOfferOptionParser.java index 6f848f8e413..45602a26a7c 100644 --- a/cli/src/main/java/bisq/cli/opts/TakeOfferOptionParser.java +++ b/cli/src/main/java/bisq/cli/opts/TakeOfferOptionParser.java @@ -21,11 +21,11 @@ import joptsimple.OptionSpec; import static bisq.cli.opts.OptLabel.OPT_FEE_CURRENCY; -import static bisq.cli.opts.OptLabel.OPT_PAYMENT_ACCOUNT; +import static bisq.cli.opts.OptLabel.OPT_PAYMENT_ACCOUNT_ID; public class TakeOfferOptionParser extends OfferIdOptionParser implements MethodOpts { - final OptionSpec paymentAccountIdOpt = parser.accepts(OPT_PAYMENT_ACCOUNT, "id of payment account used for trade") + final OptionSpec paymentAccountIdOpt = parser.accepts(OPT_PAYMENT_ACCOUNT_ID, "id of payment account used for trade") .withRequiredArg(); final OptionSpec takerFeeCurrencyCodeOpt = parser.accepts(OPT_FEE_CURRENCY, "taker fee currency code (bsq|btc)") diff --git a/cli/src/test/java/bisq/cli/opts/OptionParsersTest.java b/cli/src/test/java/bisq/cli/opts/OptionParsersTest.java index cd8062cdd10..818b4c9d26e 100644 --- a/cli/src/test/java/bisq/cli/opts/OptionParsersTest.java +++ b/cli/src/test/java/bisq/cli/opts/OptionParsersTest.java @@ -84,11 +84,11 @@ public void testCreateOfferWithEmptyPaymentAccountIdOptShouldThrowException() { String[] args = new String[]{ PASSWORD_OPT, createoffer.name(), - "--" + OPT_PAYMENT_ACCOUNT + "--" + OPT_PAYMENT_ACCOUNT_ID }; Throwable exception = assertThrows(RuntimeException.class, () -> new CreateOfferOptionParser(args).parse()); - assertEquals("payment-account requires an argument", exception.getMessage()); + assertEquals("payment-account-id requires an argument", exception.getMessage()); } @Test @@ -96,7 +96,7 @@ public void testCreateOfferWithMissingDirectionOptShouldThrowException() { String[] args = new String[]{ PASSWORD_OPT, createoffer.name(), - "--" + OPT_PAYMENT_ACCOUNT + "=" + "abc-payment-acct-id-123" + "--" + OPT_PAYMENT_ACCOUNT_ID + "=" + "abc-payment-acct-id-123" }; Throwable exception = assertThrows(RuntimeException.class, () -> new CreateOfferOptionParser(args).parse()); @@ -109,7 +109,7 @@ public void testCreateOfferWithMissingDirectionOptValueShouldThrowException() { String[] args = new String[]{ PASSWORD_OPT, createoffer.name(), - "--" + OPT_PAYMENT_ACCOUNT + "=" + "abc-payment-acct-id-123", + "--" + OPT_PAYMENT_ACCOUNT_ID + "=" + "abc-payment-acct-id-123", "--" + OPT_DIRECTION + "=" + "" }; Throwable exception = assertThrows(RuntimeException.class, () -> @@ -122,7 +122,7 @@ public void testValidCreateOfferOpts() { String[] args = new String[]{ PASSWORD_OPT, createoffer.name(), - "--" + OPT_PAYMENT_ACCOUNT + "=" + "abc-payment-acct-id-123", + "--" + OPT_PAYMENT_ACCOUNT_ID + "=" + "abc-payment-acct-id-123", "--" + OPT_DIRECTION + "=" + "BUY", "--" + OPT_CURRENCY_CODE + "=" + "EUR", "--" + OPT_AMOUNT + "=" + "0.125", @@ -146,7 +146,7 @@ public void testCreateBsqSwapOfferWithPaymentAcctIdOptShouldThrowException() { PASSWORD_OPT, createoffer.name(), "--" + OPT_SWAP + "=" + "true", - "--" + OPT_PAYMENT_ACCOUNT + "=" + "abc", + "--" + OPT_PAYMENT_ACCOUNT_ID + "=" + "abc", "--" + OPT_DIRECTION + "=" + "buy", "--" + OPT_CURRENCY_CODE + "=" + "bsq", "--" + OPT_AMOUNT + "=" + "0.125" From 5a390fa359f3ae8023b7699f02b509e2605df0c6 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 27 Dec 2021 13:45:16 -0300 Subject: [PATCH 3/3] Document 'createcryptopaymentacct' in API beta-test guide --- apitest/docs/api-beta-test-guide.md | 41 +++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/apitest/docs/api-beta-test-guide.md b/apitest/docs/api-beta-test-guide.md index f0d2593bb94..9929f4df75c 100644 --- a/apitest/docs/api-beta-test-guide.md +++ b/apitest/docs/api-beta-test-guide.md @@ -295,9 +295,9 @@ To remove a custom withdrawal transaction fee rate preference, and revert to the $ ./bisq-cli --password=xyz unsettxfeerate ``` -### Creating Test Payment Accounts +### Creating Test Fiat Payment Accounts -Creating a payment account using the Api involves three steps: +Creating a fiat payment account using the Api involves three steps: 1. Find the payment-method-id for the payment account type you wish to create. For example, if you want to create a face-to-face type payment account, find the face-to-face payment-method-id (`F2F`): @@ -329,6 +329,43 @@ Creating a payment account using the Api involves three steps: $ ./bisq-cli --password=xyz --port=9998 getpaymentaccts ``` +### Creating Test Altcoin Payment Accounts + +Unlike more complex fiat payment account setups, the `createcryptopaymentacct` command does not require a json form. + +#### BSQ Altcoin Payment Accounts + +A default BSQ Swap Altcoin payment account was created for you when the BSQ Swap protocol was introduced, and you do +not need to create BSQ Altcoin payment accounts to execute BSQ Swaps. But if you do want to trade BSQ using the +version 1 trade protocol, you will need to create a BSQ Altcoin payment accounts as show below. +``` +$ ./bisq-cli --password=xyz --port=9998 createcryptopaymentacct --account-name="My BSQ Account" \ + --currency-code=BSQ \ + --address=Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne \ + --trade-instant=false +``` +To create a BSQ Altcoin _Instant_ payment account, use the `--trade-instant=true` parameter: +``` +$ ./bisq-cli --password=xyz --port=9998 createcryptopaymentacct --account-name="My Instant BSQ Account" \ + --currency-code=BSQ \ + --address=Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne \ + --trade-instant=true +``` + +_Note: Use your own BSQ recipient address, not the `Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne` address used in the +example above._ + +#### XMR Altcoin Payment Accounts + +To create an XMR Altcoin payment account associated with example XMR address +`44G4jWmSvTEfifSUZzTDnJVLPvYATmq9XhhtDqUof1BGCLceG82EQsVYG9Q9GN4bJcjbAJEc1JD1m5G7iK4UPZqACubV4Mq`: +``` +$ ./bisq-cli --password=xyz --port=9999 createcryptopaymentacct --account-name=XMR-Account \ + --currency-code=XMR + --address=44G4jWmSvTEfifSUZzTDnJVLPvYATmq9XhhtDqUof1BGCLceG82EQsVYG9Q9GN4bJcjbAJEc1JD1m5G7iK4UPZqACubV4Mq +``` + + ### Creating Offers The createoffer command is the Api's most complex command (so far), but CLI posix-style options are self-explanatory,