Commit Graph

160 Commits

Author SHA1 Message Date
helixx87
aca897fa03
API: gettransactions method 2023-06-08 10:19:41 +02:00
Alva Swanson
796205c7a6
Remove redundant 'testRuntimeOnly libs.junit.jupiter.engine' 2023-05-13 23:05:04 +07:00
Alva Swanson
6e0e5028a3
Move JUnit dependency definition to bisq.java-conventions 2023-05-08 17:51:05 +10:00
napoly
e19ffe2308
Upgrade JUnit4 to JUnit5 Jupiter 2023-05-04 20:04:49 +02:00
helixx87
458f50dec9
Support "all" attribute in getoffers API method 2023-04-11 12:50:00 +02:00
Alejandro García
b1e2cb03ad
Merge pull request #6568 from alvasw/gradle_apply_central_bisq_java_conventions
Gradle apply central bisq java conventions
2023-02-05 22:43:48 +00:00
Alva Swanson
53837bf00b
Move SingleThreadExecutors to its own Utils class 2023-02-05 22:11:35 +01:00
Alva Swanson
c1c4caf87f
Gradle: Apply bisq.java-conventions to all projects 2023-02-05 22:02:13 +01:00
Alva Swanson
6a8fb05156
Centralize all ExecutorService creations in Utilities 2023-01-27 16:15:24 +02:00
Alva Swanson
798f84968a
Create build.gradle for daemon module 2023-01-16 17:33:27 +02:00
HenrikJannsen
21541d6880
Add INVALID_SNAPSHOT_HEIGHT to AvailabilityResult.
Use AvailabilityResult.INVALID_SNAPSHOT_HEIGHT instead of AckMessage with error.
Show description in error popup instead of enum name.
Return PRICE_CHECK_FAILED instead of UNKNOWN_FAILURE at error at price check also for non api users.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
2022-12-18 13:13:36 -05:00
ghubstan
7d4e7dd696
Support TakeOfferRequest's intended trade amt in daemon 2022-08-06 15:08:30 -03:00
ghubstan
2c043b4b21
Minor refactoring 2022-06-18 11:24:39 -03:00
ghubstan
a12dd52b81
Add API method 'getavgbsqprice'
Returns volume weighted average BSQ price in BTC and USD over N days.

The need for this arose while creating a Java BSQ Swap bot example
(PR pending).  API bots can use this to determine whether or not to
take swap offers based on their price distance above or below the 30
(or 90) day trade price average.
2022-06-17 18:26:10 -03:00
ghubstan
71365be48c
Add rate meter for getnetwork method (1/sec) 2022-06-17 09:22:08 -03:00
ghubstan
ae41e98db9
Add API API method 'getnetwork'
Returns name of the BTC network API daemon is connected to.

I am working on some Java bot examples in another repo, and want to stop
worrying about accidentally simulating trade payments on mainnet, despite
all the warnings I add in comments.  The 'getnetwork' method allows bots
to know what network the API daemon is connected to, and gives API bot
devs and users a way to avoid one potential source of costly mistakes.

API CLI manpage and apitest case are included in this commit.
2022-06-16 15:31:03 -03:00
ghubstan
639d3994ca
Accept a VERSION parameter, default to SNAPSHOT 2022-03-28 11:05:13 -03:00
ghubstan
365ed4cc42
Comment the daemon & cli zipfile creation scripts 2022-03-28 10:50:17 -03:00
ghubstan
8382419a3b
Set execution bit on bash scripts 2022-03-26 14:02:36 -03:00
ghubstan
645b9d6046
Create API daemon & cli releases as zip files
Each distribution contains a runnable jar with a MANIFEST.MF
defining the classpath (all jar files in lib/).

To run daemon.jar:  $ java -jar daemon.jar --apiPassword=xyz
To run cli.jar:     $ java -jar cli.jar --password=xyz <cmd>

TODO Sign jar files, generate checksums.
2022-03-26 13:28:39 -03:00
ghubstan
4c2649b118
Fix 'unnecessary use of fully qualified name' 2022-03-07 21:02:13 -03:00
ghubstan
1ba2b6ca18
Fix API OfferInfo.isActivated setting for bsqswaps
I think this bug was introduced when deprecating GrpcOffersService
 .getMyOffer(id), in favor of using only getOffer(id) for 'my'
and 'available' offers.  This change explicitly sets the proto's
isActivated flag in the OfferInfo factory methods, and adds checks
to api offer test cases.

Based on branch `2-improve-grpc-exception-status-code-mapping`,
PR https://github.com/bisq-network/bisq/pull/6088
2022-03-07 20:46:27 -03:00
ghubstan
df2cac3015
Make codacy happy 2022-03-05 21:00:33 -03:00
ghubstan
82549b3c22
Fix comment 2022-03-05 20:45:09 -03:00
ghubstan
784e2ae894
Send meaningful io.grpc.Status.Code to gRPC clients
Exceptions thrown by the core.api services for the daemon Grpc*Services
have to be converted into gRPC StatusRuntimeExceptions before being sent to
gRPC clients.  Most of these gRPC StatusRuntimeExceptions had a gRPC
Status.Code.UNKNOWN, which not helpful to client error handlers.

This change partially resolves the issue by sending more meaningful
io.grpc.Status.Codes to clients, where possible.  But it is not as
comprehensive as it an be for a webapp because HTTP has so many more
possible response status codes than the gRPC library (sixteen). See:
https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/Status.java

There are three types of changes:

- Create custom exceptions in bisq.core.api.exception.

- Map any custom bisq.core.api.exception to a meaningful
  io.grpc.Status.Code within daemon Grpc*Service classes.

- Adjust apitest cases to new grpc status codes.

Based on branch `move-cli-crypto-offer-filter-to-server`,  PR https://github.com/bisq-network/bisq/pull/6086
2022-03-05 20:31:50 -03:00
ghubstan
2e9e51eb41
Remove GetTradeStatistics service from grpc.proto
This protobuf definition and service stub has been in place since
the start of work on the API, but was never fully implmented, nor
intended to be included in the API beta & v1 releases.

Its presence added a useless section to the gRPC API Reference doc.

	https://ghubstan.github.io/slate

Based on branch `7-more-grpcproto-comments`,
PR https://github.com/bisq-network/bisq/pull/6068.
2022-02-26 11:11:26 -03:00
ghubstan
66c04134fc
Check offer exists before trying to take it
This was overlooked in tests, but client might use a bad offer-id param.
2022-02-25 18:51:07 -03:00
ghubstan
8408c093e0
Adjust GrpcOffersService to new .proto *Pct field names 2022-02-20 15:18:37 -03:00
ghubstan
111e39ffe8
Sort the final, cumulative trades list in gRPC GetTrades service
Resolves issue https://github.com/bisq-network/bisq/pull/5976#issuecomment-1023004215
2022-01-27 17:36:16 -03:00
ghubstan
3cd1e05a9f
Try to display accurate status of closed trades, or "Pending" if still open 2022-01-18 13:01:42 -03:00
ghubstan
e6e944bcb0
Add GrpcTradesService.getTrades service method 2022-01-16 16:38:09 -03:00
ghubstan
7690ffd953
Add API methods 'failtrade', 'unfailtrade'
Prerequisite for next PR: Add API method 'gettrades'

The `gettrades` method will show 'open', 'closed', and 'failed' trades.
Users already needed to be able to fail and unfail trades for the
same reasons they do in the UI.  API test cases will need to be able to
fail and unfail trades to check correct behavior of 'gettrades' method.

Based on branch `rename-keepfunds2closetrade`.
2022-01-07 19:11:34 -03:00
ghubstan
a9aaba87fa
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`
2022-01-05 12:10:46 -03:00
ghubstan
5f571cccca
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.
2021-12-27 12:05:17 -03:00
ghubstan
e3c40895fe
Use offer instance to determine ownership, not it's id 2021-12-01 16:05:30 -03:00
ghubstan
64f228d872
Make rpc GetOfferCategory service work for my+avail offers
There are some use cases where the CLI needs to know what kind of offer
is being acted on before the request is made, For example:

There are differences between a BsqSwap 'takeoffer'request, and a v1
'takeoffer' request.

A BsqSwap offer cannot be edited by an 'editoffer' request, and an
attempt should be blocked by the CLI.

- Append isMyOffer GetOfferCategoryRequest rpc msg def.

- Adjust daemon.grpc services for new boolean GetOfferCategoryRequest param.

- Adjust core.api for new boolean GetOfferCategoryRequest param.

- Add validation check in core.api EditOfferValidator to block attempt to
  edit a BsqSwap offer.

- Refactor CoreOffersService get*offer(id) methods to optionally throw
  excpetions.
2021-11-27 14:01:14 -03:00
ghubstan
c177b3b834
Merge branch 'master' into 2-api-bsq-swap-scratch 2021-11-24 13:14:13 -03:00
ghubstan
f88c1513ec
Refactor GrpcTradesService: use GetTrade & TakeOffer services for BSQ swaps
The rpc GetBsqSwapTrade and TakeBsqSwapOffer services were a quick hack
to help test BSQ swap feature development more quickly, using apitest
cases.  Their gRPC service method implementations are removed here and
the GetTrade & TakeOffer service methods are refactored to support BSQ
swaps.
2021-11-24 13:00:30 -03:00
chimp1984
becb64de5a
Remove code which is already in superclass 2021-11-23 23:22:28 +01:00
chimp1984
9c18899d66
Enforce inclusion of TradeLimits for headless apps
PaymentMethod use an instance of TradeLimits and expect that it
has been injected, which is the case for desktop but not for
headless apps, so we enforce injection in the app base classes
used for headless apps.

The validation of trade statistics use a method in PaymentMethod
where that dependency is required.

Tha hack how the PaymentMethod use TradeLimits is not nice, but
would require more effort for refactoring.
2021-11-23 21:34:43 +01:00
ghubstan
4ca878a8e1
Adjust API 'gettrade' for Bsq swaps
- Made several adjustments to CLI's 'gettrade' output related code
  so it can show single trade details for either Bisq v1 trades, or
  BSQ swap trades.

- Did minor refactoring of API's core to retrieve # tx confirmations
  for an addresses and transactions.

- Show # of tx confirmations in bsq swap trade detail.
2021-11-14 13:48:12 -03:00
ghubstan
564303ac20
Normalize API gRPC bsq-swap related protos & wrappers
This commit refactors the first cut of the BsqSwapTradeInfo and
TradeInfo gRPC proto defs and wrappers.  The change avoids duplication
of fields between BsqSwapTradeInfo and TradeInfo, and adds a
bsqSwapTradeInfo field to the old TradeInfo proto & wrapper.

The immediate goal is moving towards getting the API's 'gettrade'
method to work for both Bisq v1 trades and BSQ swap trades:  the TradeInfo
proto sent to the CLI should represent either a Bisq v1 trade or a BSQ
swap trade.  A mid-term term goal is to also make a new 'gettrades' method
return a List<TradeInfo> to the CLI, where items in the List<TradeInfo>
can be either v1 trades or bsq-swap trades.
2021-11-12 18:48:35 -03:00
ghubstan
c6aceb0458
Adjust bsq-swap-offer related gRPC daemon services
- Add GetOfferCategory service so CLI can determine what kind of takeoffer service is to be used.
- Adjust to removal of BsqSwapOfferInfo proto.
- Call new coreApi.getRole(BsqSwapTrade) before building BsqSwapTradeInfo proto.
2021-11-11 12:56:34 -03:00
ghubstan
edd01418ca
Remove fields/methods/logic for creating redundant bsq-swap accounts
The user's default bsq-swap account is used instead.
2021-11-07 10:36:40 -03:00
chimp1984
8ee8cba668
Apply patch from ghubstan
Remove currency params. Bsq swaps have statically defined currencies (BSQ/BTC).
2021-11-02 16:18:50 +01:00
chimp1984
1c1b2802cc
Apply codacy review suggestions 2021-11-02 16:18:50 +01:00
chimp1984
f7fcaa915e
Add BSQ swap code 2021-11-02 16:18:50 +01:00
chimp1984
0f7cfa99d5
Move Trade to bisq.core.trade.model.bisq_v1 package 2021-10-19 22:44:31 +02:00
chimp1984
20d298061d
Move AvailabilityResult into package bisq.core.offer.availability 2021-10-19 21:18:20 +02:00
ghubstan
71a61c63da
Display Enabled=PENDING in CLI 'createoffer' output
A newly created offer has no OpenOffer+State (AVAILABLE || DEACTIVATED)
when displayed in the CLI's console.  This change adds a 'bool isMyPendingOffer'
to the OfferInfo proto + wrapper, and the CLI's console offer output formatter
uses it to determine if it should display a new offer's Enabled column value
as PENDING, instead of an ambiguous NO value.
2021-08-14 16:58:47 -03:00