Commit Graph

124 Commits

Author SHA1 Message Date
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
ghubstan
a603044f2e
Pass isMyOffer flag to trade/offer proto wrappers from core services 2021-06-18 17:41:45 -03:00
ghubstan
2b8b53bba8
Add server/core editOffer, adjust getMyOffer(s) impls
- Add editOffer to GrpcOffersService, CoreApi, CoreOffersService.

- Set editOffer call rate meter to 1 / minute.

- Use new EditOfferValidator to verify editOffer params OK.

- Adust getMyOffer(s) rpc impl and OfferInfo model to use OpenOffer
  for accessing activation state and trigger price.
2021-06-13 12:24:45 -03:00
ghubstan
c4c07d0f06
Configure call rate meter for CreateCryptoCurrencyPaymentAccount 2021-04-15 14:39:23 -03:00
ghubstan
8ac30262c0
Add verifyBsqSentToAddress to GrpcWalletsService, CoreApi
The implemenation is already present in CoreWalletsService
2021-04-15 11:40:19 -03:00
ghubstan
6bde12ba40
Improve takeoffer output and failure reason messaging
- Added AvailabilityResultWithDescription proto for better takeoffer failure msgs.
- Added VerifyBsqSentToAddress impl to api, but don't expose to CLI yet.
- Show BSQ Buyer Address in gettrade output (changed cli output formatting classes).
- Fixed api.model.PaymentAccountPayloadInfo altcoin instant acct support bug
2021-04-01 16:40:08 -03:00
ghubstan
58c885efc1
Add support for creating instant altcoin payment accounts in api
- Added bool tradeInstant field to proto message def.
- Adjusted core createcryptopaymentacct impl to new tradeInstant request param.
- Adjusted cli side createcryptopaymentacct impl to new tradeInstant request param.
- Fixed CliMain's takeoffer help text (was missing the --payment-account opt).
2021-04-01 15:43:48 -03:00
ghubstan
2d66a5996d
Merge branch 'master' into 01-api-add-createcryptopaymentacct 2021-04-01 14:54:05 -03:00
ghubstan
c3f5669cf8
Add api method createcryptopaymentacct
This change supports creation of BSQ BLOCKCHAIN payment method accounts.

- Added proto message defs to grpc.proto.
- Added grpc server boilerplate to GrpcPaymentAccountsService.
- Added server impl to CoreApi, CorePaymentAccountsService.
- Added createcryptopaymentacct-help.txt.
- Added CLI side support for new api method.
- Added opt parsing unit tests to OptionParsersTest.

This is the 1st PR in a series, with the goal of supporting the BTC/BSQ trading
pair.  Support for other crypto currency payment accounts will be added later.
2021-03-25 18:36:26 -03:00
Steven Barclay
f21379160b
Merge branch 'release/v1.6.0' into implement-segwit-for-bsq 2021-03-20 23:18:49 +00:00
ghubstan
9b62a005df
Refactor takeoffer reply proto & ErrorMessageHandler
- Add description msg TakeOfferReply proto, and fromProto method
  to core.offer.enum AvailabilityResult.  The description field
  maps a client usable error message to the enum.

- Adjust GrpcErrorMessageHandler to add AvailabilityResult.description()
  to takeoffer reply.

- Refactor (split up) GrpcClient's takeOffer.  Add getTakeOfferReply()
  to give clients a chance to make choices based on the reply's
  AvailabilityResult when the takeoffer command did not result in a
  trade. (Some errors are fatal, some not.)
2021-03-19 19:38:03 +01:00
ghubstan
c58366090f
Derive AvailabilityResult from Task errorMessage 2021-03-19 19:37:41 +01:00
ghubstan
14215a1fbd
Adjust grpc & core services to new takeoffer error handling
- GrpcErrorMessageHandler  A new ErrorMessageHandler implementation
  to get around the api specific problem of having to use Task
  ErrorMessageHandlers that build task error messages for the UI.

- GrpcExceptionHandler  A new method for working with the
  ErrorMessageHandler interface.

- GrpcTradesService, CoreApi, CoreTradesService:  Ajdusted takeoffer
  error handling to give a failure reason provided by the new
  GrpcErrorMessageHandler.
2021-03-19 19:37:10 +01:00
ghubstan
1d56d79457
Refactor takeoffer reply proto & ErrorMessageHandler
- Add description msg TakeOfferReply proto, and fromProto method
  to core.offer.enum AvailabilityResult.  The description field
  maps a client usable error message to the enum.

- Adjust GrpcErrorMessageHandler to add AvailabilityResult.description()
  to takeoffer reply.

- Refactor (split up) GrpcClient's takeOffer.  Add getTakeOfferReply()
  to give clients a chance to make choices based on the reply's
  AvailabilityResult when the takeoffer command did not result in a
  trade. (Some errors are fatal, some not.)
2021-03-15 11:17:09 -03:00
ghubstan
48ecb5b2f9
Derive AvailabilityResult from Task errorMessage 2021-03-10 15:07:34 -03:00
ghubstan
d0590d93a9
Adjust grpc & core services to new takeoffer error handling
- GrpcErrorMessageHandler  A new ErrorMessageHandler implementation
  to get around the api specific problem of having to use Task
  ErrorMessageHandlers that build task error messages for the UI.

- GrpcExceptionHandler  A new method for working with the
  ErrorMessageHandler interface.

- GrpcTradesService, CoreApi, CoreTradesService:  Ajdusted takeoffer
  error handling to give a failure reason provided by the new
  GrpcErrorMessageHandler.
2021-03-10 14:16:15 -03:00
ghubstan
3f84246f59
Improve interceptor's rate metering key definition and lookup
This change replaces the hard coded strings used as keys in
interceptor rate-metering lookup maps.

Now, the fullMethodName defined in each bisq.proto.grpc.* class'
io.grpc.MethodDescriptor is used, not a hard coded String.

For example, the rate metering lookup key for 'GetBalances',
in 'GrpcWalletsService', is the

   fullMethodName = SERVICE_NAME + '/' + "GetBalances",

   where SERVICE_NAME = "io.bisq.protobuffer.Wallets".

Also adjusted affected tests, and tidy'd up interceptor logging.
2021-02-28 17:10:51 -03:00
ghubstan
6b2c386a7c
Fix call rate metering interceptor bug
The gRPC interceptor was not using the correct method/ratemeter
map key, and failing to find a rate meter for the server call.

- Fix the rate meter key lookup bug.

- Disable most strict, default call rate meters in tests.
  Made an adjustment to the test harness' scaffold setup so an interceptor
  testing or disabling config file is always picked up by bob and alice
  daemons.

- Set arbitration daemon's registerDisputeAgent rate @ 10/second, so
  it does not interfere with the test harness.  (There is no pre-existing
  arb node appDataDir before that daemon starts.)

Note:  The test harness cannot install the custom rate metering file in
an arb daemon's appDataDir before it starts because there is no dao-setup
file for that node type.

TODO:  Adjust api simulation scripts to interceptor bug fix.
2021-02-27 21:47:52 -03:00
ghubstan
f90d2cee57
Fix test bug 2021-02-27 18:24:57 -03:00
ghubstan
320e63c0a1
Log 'trade not found' a warning instead of full stack trace 2021-02-27 17:25:49 -03:00
ghubstan
e5a0a3998d
Permit some gRPC excptions to be logged only as warning
A new handleExceptionAsWarning method logs warn(ex.msg) instead of
the full stack trace.
2021-02-27 17:14:22 -03:00
ghubstan
e5291e9f45
Use the logger of the gRPC service throwing an exception 2021-02-27 17:09:54 -03:00
ghubstan
1154085632
Add api method 'stop'
This change gives CLI users a 'stop' command to shutdown a daemon.

- Server side gRPC boilerpate was added to :proto and :daemon.

- When the new GrpcShutdownService accepts a 'stop' request from the CLI,
  it calls UserThread.runAfter(BisqHeadlessApp.getShutDownHandler(), 500, MILLISECONDS);

- Method help file 'stop-help.txt' was added to :core.

- Client side gRPC boiler plate and 'stop' implementation was added to :cli.
2021-02-18 11:54:10 -03:00
ghubstan
c99624015b
Factor out repeated 'new CallRateMeteringInterceptor' calls
Move this into a static CallRateMeteringInterceptor.valueOf(Map) method.
2021-01-25 14:38:53 -03:00
ghubstan
4eed44d350
Define gRPC api call rate constraints
The general rule is limit calls that change p2p data to 1/minute,
others to 1/second.  An exception is made to set/remove wallet password
methods (1/5s), due to the latency of writing wallet changes to disk.

This change may affect api testing in the future.  If that happens,
further changes to the call rate metering interceptor may be made to loosen
the constraints when running in regtest/dev mode.
2021-01-22 13:45:12 -03:00
Steven Barclay
8104301b52
Use new Bitcoind(Client|Daemon) & remove btcd-cli4j
Migrate RpcService over to the new block notification daemon and RPC
client based on jsonrpc4j. Drop in own DTO classes in place of the ones
defined by btcd-cli4j and rename requestBtcBlock & addNewBtcBlockHandler
to requestDtoBlock & addNewDtoBlockHandler respectively.

Also remove now redundant filtering from the logback config and update
grade-witness.
2021-01-21 10:10:28 +00:00
ghubstan
d18b2d5a10
Run an async price feed request when CLI needs market price
The CLI was receiving stale, cached market prices from the feed service.
2021-01-20 17:46:35 -03:00
ghubstan
a067ba1228
Add new CoreHelpService and method help docs
Adds all the gRPC server boilerplate, and a simple help service
that serves method help in man page format.  Help text is maintained
in text files located in core/src/main/resources/help.

Only some of the method help text files are defined in this
change, more to be added.
2021-01-14 10:19:39 -03:00
ghubstan
a8d15d0161
Merge branch 'offer-protection-tools-api-integration' into 03-support-trigger-price 2021-01-13 20:03:03 -03:00
ghubstan
0e779a4bf6
Inject CoreContext into server, then set isApiUser=true
Do not set isApiUser=true based on hardcoded thread name ;-(

For requested change
https://github.com/bisq-network/bisq/pull/5065#pullrequestreview-567708569
2021-01-13 19:55:49 -03:00
ghubstan
0c6005ed2d
Stub out support for OpenOffer's triggerPrice in api
This is a feature that will not be included in api v1, but partial
support is added in this change to the server.  CLI will pass a
default triggerPrice of 0 (unused) with the createoffer command.

When fully implemented, an optional trigger-price param will be
added to the CLI's createoffer method, and the value will only be
visible to offer owners.  New enableoffer and disableoffer
methods will also need to be added.
2021-01-11 14:36:51 -03:00
ghubstan
18de222d38
Add new api methods 'getmyoffers' and 'getmyoffer'
Similar to 'getoffers' and 'getoffer', but filters out offers not
created by the user.  The new methods are so similar some offer list
filtering and sorting was refactored in CoreOffersService.

Also fixed some createoffer apitest cases in anticipation of a new OfferFilter,
which will filter out offers not matching any user payment account.
2021-01-04 21:43:34 -03:00
ghubstan
10727fc083
Fix GrpcCallRateMeter method and variable name
- Change method isAllowed() -> checkAndIncrement().

- Change variable allowedCallsPerTimeUnit -> allowedCallsPerTimeWindow.
2020-12-23 11:30:16 -03:00
ghubstan
63564760a8
Support more fine grained rate metering
We need to be able to define call rate meters for time spans not limited
to TimeUnit intervals of 1 SECOND, 1 HOUR, or 1 DAY.  This change allows
more flexibility, e.g., 10 per 5 seconds, 10 per 5 hrs, 100 per 7 days.
2020-12-22 21:11:04 -03:00
ghubstan
c8ef4141e3
Fix comment 2020-12-22 18:33:18 -03:00
ghubstan
0d4ed952e7
Remove redundant callCount field
The size of the timestamp queue is the call count
2020-12-22 17:00:01 -03:00
ghubstan
d61521276f
Remove unused local var 2020-12-22 16:30:37 -03:00