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.
This commit is contained in:
ghubstan 2021-12-27 12:05:17 -03:00
parent 98b41cb56c
commit 5f571cccca
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
21 changed files with 113 additions and 91 deletions

View File

@ -399,7 +399,7 @@ $ ./bisq-cli --password=xyz --port=9998 getmyoffers --direction=<BUY|SELL> --cur
To look at a specific offer you created:
```
$ ./bisq-cli --password=xyz --port=9998 getmyoffer --offer-id=<offer-id>
$ ./bisq-cli --password=xyz --port=9998 getoffer --offer-id=<offer-id>
```
### Browsing Available Offers

View File

@ -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 $?

View File

@ -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 $?

View File

@ -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 $?

View File

@ -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 $?

View File

@ -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 $?

View File

@ -132,7 +132,7 @@ public class BsqSwapOfferTest extends AbstractOfferTest {
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;

View File

@ -85,7 +85,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());
@ -132,7 +132,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());
@ -179,7 +179,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());
@ -226,7 +226,7 @@ public class CreateBSQOffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());

View File

@ -75,7 +75,7 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
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 class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
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 class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
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());

View File

@ -96,7 +96,7 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
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 class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
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 class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
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 class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
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 class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
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());

View File

@ -88,7 +88,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());
@ -135,7 +135,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());
@ -188,7 +188,7 @@ public class CreateXMROffersTest extends AbstractOfferTest {
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 class CreateXMROffersTest extends AbstractOfferTest {
genBtcBlockAndWaitForOfferPreparation();
newOffer = aliceClient.getMyOffer(newOfferId);
newOffer = aliceClient.getOffer(newOfferId);
assertTrue(newOffer.getIsMyOffer());
assertFalse(newOffer.getIsMyPendingOffer());
assertEquals(newOfferId, newOffer.getId());

View File

@ -68,19 +68,19 @@ public class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
// 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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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 class EditOfferTest extends AbstractOfferTest {
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());

View File

@ -98,7 +98,7 @@ public class BsqSwapTradeTest extends AbstractTradeTest {
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());

View File

@ -75,13 +75,13 @@ public class LongRunningOfferDeactivationTest extends AbstractOfferTest {
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 class LongRunningOfferDeactivationTest extends AbstractOfferTest {
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()) {

View File

@ -753,7 +753,7 @@ public class CliMain {
// 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

View File

@ -274,6 +274,8 @@ public final class GrpcClient {
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);
}

View File

@ -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,

View File

@ -46,6 +46,7 @@ import com.google.common.util.concurrent.FutureCallback;
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 class CoreApi {
return coreOffersService.getOffer(id);
}
public Optional<Offer> findAvailableOffer(String id) {
return coreOffersService.findAvailableOffer(id);
}
public OpenOffer getMyOffer(String id) {
return coreOffersService.getMyOffer(id);
}
public Optional<OpenOffer> findMyOpenOffer(String id) {
return coreOffersService.findMyOpenOffer(id);
}
public Offer getMyBsqSwapOffer(String id) {
return coreOffersService.getMyBsqSwapOffer(id);
}

View File

@ -145,21 +145,53 @@ class CoreOffersService {
new IllegalStateException(format("offer with id '%s' not found", id)));
}
Optional<Offer> 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<OpenOffer> 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<Offer> 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<Offer> findMyBsqSwapOffer(String id) {
return offerBookService.getOffers().stream()
.filter(o -> o.getId().equals(id))
.filter(o -> o.isMyOffer(keyRing))
.filter(Offer::isBsqSwapOffer)
.findAny();
}
List<Offer> getBsqSwapOffers(String direction) {
return offerBookService.getOffers().stream()
.filter(o -> !o.isMyOffer(keyRing))
@ -364,38 +396,6 @@ class CoreOffersService {
throw new IllegalStateException(offer.getErrorMessage());
}
private Optional<Offer> 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<Offer> findMyBsqSwapOffer(String id) {
return offerBookService.getOffers().stream()
.filter(o -> o.getId().equals(id))
.filter(o -> o.isMyOffer(keyRing))
.filter(Offer::isBsqSwapOffer)
.findAny();
}
private Optional<Offer> 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<OpenOffer> 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,

View File

@ -58,6 +58,7 @@ import java.util.stream.Collectors;
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 @@ class GrpcOffersService extends OffersImplBase {
public void getOffer(GetOfferRequest req,
StreamObserver<GetOfferReply> responseObserver) {
try {
Offer offer = coreApi.getOffer(req.getId());
String offerId = req.getId();
Optional<OpenOffer> 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 @@ class GrpcOffersService extends OffersImplBase {
}
}
@Deprecated // Since 27-Dec-2021.
// Endpoint to be removed from future version. Use getOffer service method instead.
@Override
public void getMyOffer(GetMyOfferRequest req,
StreamObserver<GetMyOfferReply> 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();

View File

@ -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;
}