Commit Graph

167 Commits

Author SHA1 Message Date
ghubstan
9c12b31019
Add new cli option parser test
Does not check every combination of options for every method, but
we finally have an option parser test case to build on.
2021-03-05 07:16:36 -03:00
ghubstan
d01a7b7fee
Improve required-argument opt validation
Make sure non-empty opt values are present in the parsers' custom
validation, or jsimpleopt will throw exceptions with stylistically
inconsisent messages.
2021-03-05 07:10:42 -03:00
ghubstan
62ff79d718
Update cli getoffers smoke test to posix style opts 2021-03-05 07:09:41 -03:00
ghubstan
cfaa539a5e
Fix opt validation bugs in CLI
Unset empty string default values on some the createoffer method's
required option declarations in CreateOfferOptionParser, and adds a
check for presence of required currency-code option.

- Removes default "" value from required opt direction.
- Removes default "" value from required opt currency-code.
- Removes default "" value from required opt amount.
- Removes default "" value from required opt min-amount.
- Removes default "" value from required opt fixed-price.
- Removes default "" value from required opt security-deposit.
- Check for required currency-code option.

Unset empty string default values on some of the createoffer method's
required option declarations in TakeOfferOptionParser.

- Removes default "" value from required opt offer-id.
- Removes default "" value from required opt payment-account.

Other opt parser default values removed from:

- CancelOfferOptionParser#offer-id
- CreatePaymentAcctOptionParser#payment-account-form
- GetAddressBalanceOptionParser#address
- GetBTCMarketPriceOptionParser#currency-code
- GetOfferOptionParser#offer-id
- GetOffersOptionParser#direction
- GetOffersOptionParser#currency-code
- GetPaymentAcctFormOptionParser#payment-method-id
- GetTradeOptionParser#trade-id
- GetTransactionOptionParser#transaction-id
- RegisterDisputeAgentOptionParser#registration-key
- RegisterDisputeAgentOptionParser#dispute-agent-type
- RemoveWalletPasswordOptionParser#wallet-password
- SendBsqOptionParser#address
- SendBsqOptionParser#amount
- SendBtcOptionParser#address
- SendBtcOptionParser#amount
- SetTxFeeRateOptionParser#tx-fee-rate
- SetWalletPasswordOptionParser#wallet-password
- UnlockWalletOptionParser#wallet-password
- UnlockWalletOptionParser#timeout
- WithdrawFundsOptionParser#trade-id
- WithdrawFundsOptionParser#address
2021-03-04 13:03:04 -03:00
ghubstan
8590c67670
Remove warning supression 2021-03-02 14:40:36 -03:00
ghubstan
2473ff6374
Fix tx-fee-rate formatting (and math) bug in cli/CurrencyFormat
Now prints '<integer> sats/byte' to console.
2021-03-02 13:28:51 -03:00
ghubstan
392c0f58af
Fix CLI number opt validation, improve server-not-up msg
- Fix tx-fee-rate opt validation bug.

- Tell user what option value is not a number.

- Append ", server may not be running" text to "io exception" exception msg.
2021-03-01 15:20:08 -03:00
ghubstan
d60c0dd3ca
Display buyer's cost in api's gettrade output
The offer volume is shown so traders know how much fiat
they are sending or receiving without having to call getoffer.

Changed the 'Fiat Sent' and 'Fiat Received' column headers
to show which fiat is being transfered, e.g., 'EUR Sent',
'EUR Received'.

Adjusted apitest's trade-simulation-utils.sh to the modified
gettrade output.
2021-02-26 15:25:31 -03:00
ghubstan
ce2a523309
Remove unused imports 2021-02-25 22:24:56 -03:00
ghubstan
3bc5d05bb6
Refactor apitest cases to use GrpcClient
This is a follow up to PR https://github.com/bisq-network/bisq/pull/5240,
which moved client side gRPC boilerplate to a new, reusable GrpcClient class.

From this change forward, all (including test) client side gRPC request/response
boilerplate should now live in GrpcClient.
2021-02-25 22:05:21 -03:00
ghubstan
a5e5b9fc39
Refactor grpc stub boilerplate from CliMain to GrpcClient
CliMain no longer uses gRPC stubs directly, just parses &
validates command options, and prints responses.

Also, anticipates reuse by java bots (avoiding grpc boilerplate
duplication on the client side), reduces size of CliMain class, and
will allow clean up of duplicated grpc boilerplate in apitest cases.
2021-02-25 14:27:55 -03:00
ghubstan
7c3ec458b9
Make @VisibleForTesting 2021-02-18 12:50:47 -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
ced422e930
Add new api CLI method 'getbtcprice'
The server impl was there, but it is now needed by the trading
sim scripts (CLI) to get the price from the Bisq server instead
of the feed.  (The server does not request prices more than
once a minute.)
2021-01-20 15:01:16 -03:00
ghubstan
8907d6b4a8
Keep CLI method enum members in alphabetical order 2021-01-17 13:05:07 -03:00
ghubstan
68092a0f82
Add --memo opt to help text 2021-01-16 15:09:52 -03:00
ghubstan
d14fc40029
Fix help text typos 2021-01-16 15:07:06 -03:00
ghubstan
ef4acc0b73
Make opt description generic 2021-01-16 13:44:02 -03:00
ghubstan
f2a899917c
Fix default opt values 2021-01-14 19:05:27 -03:00
ghubstan
baf79e2b50
Make opt description more generic 2021-01-14 19:03:49 -03:00
ghubstan
acf2c7c50e
Remove deprecated NegativeNumberOptions
Not needed anymore, and all method opts are posix style.
(The opts parsing lib used to treat negative numbers as opt labels.)
2021-01-14 10:27:47 -03:00
ghubstan
9f0f083cf7
Change CLI opts to posix-style 2021-01-14 10:26:11 -03:00
ghubstan
f4e735faec
Move CLI method enum to it's own class
This helps reduce size of growing CLI class file.
2021-01-14 10:25:08 -03:00
ghubstan
37ad73d4f4
Add posix-style api method option parsers 2021-01-14 10:23:38 -03:00
ghubstan
49a3b46960
Add CoreHelpService gRPC stubs and test case 2021-01-14 10:22:14 -03:00
ghubstan
9a4e311193
Fix file conflict
The createoffer trigger price was defined as the 0 default value
in the gRPC request object (causing the file conflict with the
main branch).  This line can be removed because a protobuf
long's default value is 0.
2021-01-13 09:31:34 -03:00
ghubstan
f1a6783c15
Display fiat ccy code in upper case 2021-01-11 14:56:47 -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
9180ca61f6
Fix two CLI option parsing bugs
- Fix bug locating index of method name in String[] args.

- Make createoffer method's security-deposit param format consistent with UI's.

  When creating an offer, the CLI should take "15.0", not "0.15" as
  a 15% security deposit.  This is consistent with the UI, and the
  CLI's mkt-price-margin input format.
2021-01-08 11:14:16 -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
f8cf109aed
Fix CLI --help formatting bugs 2020-12-31 12:18:33 -03:00
ghubstan
97dcac2a2d
Adjust TradeFormat to reverting 6aa385e494 2020-12-21 15:19:10 -03:00
ghubstan
5522d0c53e
Add new api method gettransaction
This change was prompted by the recent changes in the main branch to
allow a tx memo field to be set from the UI and API.

This and the prior PR address the API's need to be able to fetch a
tx (with a memo).  The API can now get a completed trade's withdrawal
txid and pass it as a gettransaction parameter.

See previous PR "Append nullable withdrawalTxId field to Trade".

	https://github.com/bisq-network/bisq/pull/4937

A summary of changes by file:

grpc.proto

- Added withdrawalTxId field to existing TradeInfo proto & wrapper.
- Reordered fields in TradeInfo proto.
- Added new fields to be displayed by TxInfo proto in CLI.
- Fixed typo: unsetTxFeeRatePreference -> UnsetTxFeeRatePreference.
- Added new GetTransaction rpc.

GrpcWalletsService - Added new getTransaction gRPC boilerplate.

CoreWalletsService - Added new getTransaction implementation.

TxInfo - Added the new fields for displaying a tx summary from CLI.
This is not intended to be more than a brief summary;  a block explorer
or bitcoin-core client should be used to see the complete definition.

TradeInfo - Added the new withdrawalTxId field defined in grpc.proto.

CliMain - Added new 'case gettransaction'.

TransactionFormat - Formats a TxInfo sent from the server to CLI.

ColumnHeaderConstants - Added console headers used by TransactionFormat.

TradeFormat - Displays a completed trade's WithdrawalTxId if present.

Apitest - Adjusted affected tests: assert tx memo is persisted and
test gettransaction.
2020-12-14 15:01:03 -03:00
ghubstan
bd66008062
Support tx memo field for btc withdrawals from api
- Added optional memo parameter to the api's sendbtc and
  withdrawfunds commands.

- Removed the @Nullable annotation was removed because protobuf
  does not support null.

- Visibility in two wallet check methods were changed from private
  to pkg protected so the CoreTradeService could use them.

- Adjusted affected tests.  (Asserting the memo field was set on a
  transaction cannot be checked from apitest yet.)
2020-12-09 16:51:56 -03:00
ghubstan
6c9f0c252d
Add new api method 'sendbtc' and test
Takes an address, amount, and optional txfeerate param,
returns a lightweight TxInfo proto.

Also overloaded two BtcWalletService methods to allow sendbtc
to pass in the tx fee rate -- overriding the fee service and
custom fee rate setting.
2020-12-08 21:12:02 -03:00
ghubstan
159d4cc6f5
Add optional txFeeRate parameter to api sendbsq
If present in the sendbsq command, the parameter will override the fee
service and custom fee rate setting for the BSQ transaction.

Also changed the sendbsq grpc return type to a lightweight TX proto wrapper.

Besides some small refactoring in the CLI, all the changes are
adjustments for this new sendbsq parameter and its new grpc return value.
2020-12-04 17:17:37 -03:00
ghubstan
65df9e1503
Change sendbsq's amount parameter type to String 2020-12-02 14:52:05 -03:00
ghubstan
987d89319e
Use ListenableFuture and callback when requesting tx fee
This change fixes the blocking problem in the fee rate request api.
Also redefined the TxFeeRateInfo.

- Redefined grpc.proto message TxFeeRateInfo, added
  lastFeeServiceRequestTs field. (CLI user may want to know
  TS of last fee request.)

- Adjusted TxFeeRateInfo proto wrapper.

- Adjusted CurrencyFormat and BtcTxFeeRateTest to new TxFeeRateInfo.

- Added @Getter annotation to FeeService.  (CLI user may want to know
  TS of last fee request).

- Pass resultHandler from GrpcWalletsService through CoreApi, to
  CoreWalletsService's tx fee rate api methods.
2020-12-01 21:10:47 -03:00
ghubstan
faf030fbc5
Add useCustomTxFeeRate field to TxFeeRateInfo proto wrapper
This is set from the core preferences.isUseCustomWithdrawalTxFee(),
and simplifies fee changing logic in the API.
2020-12-01 17:14:08 -03:00
ghubstan
965b003f61
Remove unnecessary use of fully qualified name for codacy 2020-11-27 06:45:31 -03:00
ghubstan
0b0f9f1120
Add gettxfeerate, settxfeerate, unsettxfeerate implementations 2020-11-26 18:36:15 -03:00
ghubstan
baf300afae
Add missing newlines to console output statements
And remove some unecessary single quotes.
2020-11-26 15:02:30 -03:00
ghubstan
c88543848d
Fix minor error & help msg bugs 2020-11-23 12:06:57 -03:00
ghubstan
ab5780e0e1
Print 'no offers found' msg in CLI if list is empty 2020-11-22 18:58:43 -03:00
ghubstan
08d56733a8
Fix getbalance out bug in CLI
Running the bats test exposed a bug that shows BSQ and BTC balance
info no matter what currency code argument is passed to the server.
2020-11-22 16:54:24 -03:00
ghubstan
cb9a68bae1
Tidy up payment accts api related msgs on CLI 2020-11-19 12:01:41 -03:00
ghubstan
08228d07bc
Replace existing api method 'createpaymentacct' impl
In the CLI, this method now takes a single argument, the path to a json
file (a payment account form).  The json text is read from the file
and sent to the server, where it is serialized to a new PaymentAccount
instance, saved, and sent back to the CLI as a protobuf.PaymentAccount.

- Modified existing gRPC boilerplate in grpc.proto and GrpcPaymentAccountsService.

- Modified existing method signatures in CoreApi and CorePaymentAccountsService.

- Replaced existing method impl in CorePaymentAccountsService and
  removed dead code.

- Replaced the CLI's existing 'createpaymentacct' method impl.

- Modified existing tests.
2020-11-18 19:23:21 -03:00
ghubstan
dc227ec8cc
Add new api method 'getpaymentacctform' to CLI 2020-11-18 16:18:15 -03:00
ghubstan
7a7d5ba0a7
Print the payment method id (only) 2020-11-18 12:53:36 -03:00
ghubstan
ec381522ff
Add api method 'getpaymentmethods'
Returns a list of supported payment method IDs.  This gives CLI users
the correct payment method id for creating a new payment account.

- Added gRPC service GetPaymentMethods to grpc.proto.

- Added gRPC boilerplate method to GrpcPaymentAccountsService.

- Added implimentation to CoreApi -> CorePaymentAccountsService.

- Refactored PaymentAccountTest hierarchy.

- Add api method to CLI.
2020-11-18 12:03:22 -03:00