Commit Graph

286 Commits

Author SHA1 Message Date
ghubstan
65fb8e8225
Add CliMain.main(args) tests
There are no asserts, but helpful for looking at affects of CLI commands
from terminal because apitest cases use gRPC service stubs instead of terminal.
2021-12-02 19:17:03 -03:00
ghubstan
a45c5fa61f
Adjust CLI opts parsers & opt parsing test for XMR support 2021-12-02 19:09:54 -03:00
ghubstan
03b57916a5
Make altcoin offer sorting method names more generic 2021-12-02 19:07:49 -03:00
ghubstan
54f815eb4f
Adjust API cli-side CryptoCurrencyUtil & OffersServiceRequest for XMR support 2021-12-02 19:04:28 -03:00
ghubstan
b1dd20572c
Allow unrecognized options in OfferIdOptionParser where appropriate
The OfferIdOptionParser superclass reduces duplication for parsing
offer-id parameters, but it needs to let subclass parsers' other
options pass validation.
2021-11-29 12:30:13 -03:00
ghubstan
66115f3d81
Revert "There is no --swap opt in editoffer command"
This reverts commit b5981b5b71.

This was a mistake.  There is a swap opt in the createoffer command.
2021-11-28 14:56:57 -03:00
ghubstan
b5981b5b71
There is no --swap opt in editoffer command
BSQ swap offers cannot be edited
2021-11-27 14:17:52 -03:00
ghubstan
b95e4b37b6
Block attempts to edit BsqSwap offers from CLI 2021-11-27 14:01:38 -03:00
ghubstan
05d1916ae9
Fix help text typo 2021-11-26 10:54:28 -03:00
ghubstan
0aa0852407
Add CLI createoffer smoketest (for bsq swaps)
NEVER RUN ON MAINNET!
2021-11-25 18:21:06 -03:00
ghubstan
132ecc9ac3
Adjust CliMain's createoffer for BSQ swaps 2021-11-25 18:20:04 -03:00
ghubstan
eff10842b9
Tighten createoffer param validation (only bsq swaps supported) 2021-11-25 17:31:54 -03:00
ghubstan
35aeb61338
Adjust createoffer opt parser for bsq swaps 2021-11-25 17:10:19 -03:00
ghubstan
b1c872c515
Adjust createoffer opt parser/test for bsq swaps 2021-11-25 17:08:07 -03:00
ghubstan
3077be54f0
Remove API createoffer's paymentAcctId request param (BSQ swap) 2021-11-25 16:12:05 -03:00
ghubstan
0c5c343fe0
Adjust CLI to support getting/taking BSQ swaps
Also refactored some of the opt parsers.
2021-11-24 13:10:34 -03:00
ghubstan
d8f1e446ea
Try to hide from pesky codacy 2021-11-14 14:30:41 -03: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
fc53ca48c1
Add CLI output IntegerColumn 2021-11-14 13:40:59 -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
16be35790b
Paritally adjust bsq-swap-offer related gRPC CLI side classes
- Adjust to removal of BsqSwapOfferInfo proto, use ammended OfferInfo instead.

- Remove currency-code param from all get(My)BsqSwapOffer(s) requests.

- Add new OfferCategory getAvailableOfferCategory(String offerId) service.
  CLI uses this to determine which kind of gRPC request object should be
  sent with a 'takeoffer' request.

- Adjust GetOffersSmokeTest to help see offer/swap-offer CLI output.
2021-11-11 13:20:58 -03:00
ghubstan
3f61375622
Remove white space 2021-11-07 14:19:38 -03:00
ghubstan
eb57b7e75e
Merge branch '01-use-default-bsq-swap-acct' into 02-cli-console-formatting-api 2021-11-07 14:04:13 -03:00
ghubstan
1d403e7a42
Add CLI test dependency to check console output diffs, and tests 2021-11-07 14:01:36 -03:00
ghubstan
0341104823
Adjust CLI classes to new console output api 2021-11-07 13:59:58 -03:00
ghubstan
08d16e6040
Deprecate old CLI console output formatters
A minor refactoring of some deprecated classes is included.
2021-11-07 13:51:27 -03:00
ghubstan
19436c3e2f
Add new bisq.cli.table classes 2021-11-07 13:47:32 -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
ghubstan
eb234bf93a
Remove apitest's create bsq-swap account method
If not present, a default BSQ swap account is saved when a User object
is initialized.  Use the existing default account in API bsq-swap test
cases, and rename the legacy BSQ payment account fixtures to distinguish
them from the new default 'BSQ Swap' payment account.
2021-11-05 13:59:41 -03: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
54f17b00af
Cleanups 2021-10-21 17:44:48 +02:00
chimp1984
611b944609
Move protobuf OfferPayload.Direction to OfferDirection 2021-10-21 15:40:25 +02:00
ghubstan
55cb126e4f
Show trade.price in margin based altcoin 'gettrade' console output
Fixes problem simlar to other CLI output changes in this PR.
CLI's 'gettrade' output should show contracted trade.price instead of
moving offer.price value for price margin based altcoin offers.

This fixed bug did not affect any fiat or BSQ trades, only price margin
based XMR trades, and API support for XMR trading has not yet been
released.
2021-09-18 13:40:55 -03:00
ghubstan
542aa774b0
Fix typo in help text 2021-09-18 12:40:58 -03:00
ghubstan
a0f3d0a44c
Show correct altcoin trade amount (volume) in CLI console
This is a bug fix for the CLI's displayed altcoin trade amount
value, which should be trade.volume, not offer.volume.  It has been
hidden by the stability of the BSQ price, and exposed while testing
API support for XMR trades.
2021-09-17 16:28:07 -03:00
ghubstan
484f882077
Show frozen fiat trade cost in CLI console
This is a bug fix for the CLI's displayed fiat trade cost
value, which should be trade.volume, not offer.volume.  Offer volume
varies with BTC volatility, and the CLI should be showing the trade.volume
value instead, frozen when the contract is made.
2021-09-17 16:25:37 -03: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
649c98a3f0
Always use Locale.US in CLI DecimalFormats
Avoid inconsistent CLI output decimal formats across different
systems' default locales.
2021-07-15 12:43:29 -03:00
ghubstan
eb62f9354a
Rename and move private function
And make sure function is not duplicated CLI side logic.
2021-07-12 11:28:33 -03:00
ghubstan
b74f084893
Optionally show ENABLED column in CLI's getoffer(bsq) output 2021-06-18 17:50:28 -03:00
ghubstan
063b52eb70
Add editoffer test case, suppress annoying warnings 2021-06-15 11:39:06 -03:00
ghubstan
4da64b9bd0
Improve 'editoffer' opt parsing, fix test pkg name 2021-06-15 11:27:23 -03:00
ghubstan
e2a205a31d
Show enable/trigger-price cols for 'getmyoffer' 2021-06-15 11:24:27 -03:00
ghubstan
05f3985447
Fix problems found in codacy check 2021-06-13 13:54:16 -03:00
ghubstan
be249c5e79
Add editoffer to CLI 2021-06-13 12:56:29 -03:00
ghubstan
d2939cc567
Add new EditOfferOptionParser and test 2021-06-13 12:43:02 -03:00
ghubstan
9231e48c43
Refactor GrpcClient: request builders moved bisq.cli.request pkg
Reduces size of GrpcClient while allowing for additional bot-friendly
variations of the new grpc editOffer method.
2021-06-13 12:35:43 -03:00
BtcContributor
a39da12ef6
Fix cli test that blocks building on Windows 2021-04-23 11:16:22 +02:00
ghubstan
2308afb41b
Adjust to changing minimum tx fee rates
- Append minFeeServiceRate to TxFeeRateInfo proto.
- Display min rate in CLI console.
- Fix broken test due to changing min fee rate.
2021-04-19 12:08:52 -03:00
ghubstan
40e76fb4ee
Remove white space in console msg 2021-04-15 14:57:44 -03:00
ghubstan
e96da16df8
Complete API support for BSQ/BTC trade pair
- Finished API server's verify bsq payment impl.
- Added verifybsqsenttoaddress method to CLI.
- Added verifybsqsenttoaddress-help.txt to server.
- Fixed client getoffers, getmyoffers to work with BSQ offers.
2021-04-15 14:21:25 -03:00
ghubstan
bddc273bb2
Fix spelling 2021-04-02 12:58:46 -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
6299dc33d9
Merge branch '01-api-add-createcryptopaymentacct' into 02-api-trade-contract-details 2021-04-01 15:58:59 -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
aad998cf3a
Fix maker/taker fee format bug, rename methods 2021-03-28 16:42:55 -03:00
ghubstan
9e035e5542
Provide more offer & contract detail available to CLI.
This change adds offer and trade contract detail to the API's Offer
and Trade protos, and improves CLI output formatting.

- Appended missing fields to OfferInfo proto message:
	uint64 sellerSecurityDeposit = 20;
	string offerFeePaymentTxId = 21;
	uint64 txFee = 22;
	uint64 makerFee = 23;

- Added new api proto messages ContractInfo and PaymentAccountPayloadInfo.
  Lighterweight protos are needed because core Trade/Contract classes are
  not visible to CLI.

- Appended ContractInfo field to api proto message TradeInfo.

- Added proto / model converters for ContractInfo and PaymentAccountPayloadInfo,
  and adjusted OfferInfo & TradeInfo.

- Improved CLI output formatting.  Added more trade detail to CLI's gettrade output,
  and prepared to support BTC/BSQ trading pair.  Note a reviewer is advised to
  look at the CLI outout formatting class files instead getting bogged down in the
  many commit changes.
2021-03-25 19:23:06 -03:00
ghubstan
27b090005d
Add cli side help for createcryptopaymentacct 2021-03-25 18:46:41 -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
ghubstan
8f092a6b4d
Fix comment, left justify non-numeric column value 2021-03-20 19:08:21 -03:00
ghubstan
8783889c36
Fix api getfundingaddresses bug
This change uses recently added walletService.isAddressUnused to ensure
the api's CoreWalletsService creates an unused address if none exists.

- grpc.proto:  Add bool isAddressUnused field to message AddressBalanceInfo.
- AddressBalanceInfo:  Adjust AddressBalanceInfo proto wrapper.
- CoreWalletsService:  Use walletService.isAddressUnused in getFundingAddresses.
- GrpcClient:  Adjust to modified AddressBalanceInfo.
- TableFormat, ColumnHeaderConstants:  Add 'Is Used' column to getfundingaddresses output.

Note: bugfix is out of scope for this PR, but the test case helped expose this bug.
2021-03-15 16:15:06 -03:00
ghubstan
588541ed15
Add bot convenience: getMyOffersSortedByDate(String currencyCode) 2021-03-15 13:48:32 -03:00
ghubstan
10e721767f
Add convenience (get all offers, both directions), and make sorter public 2021-03-15 13:20:05 -03: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
697cf66d7c
Convert AvailabilityResult to error msg when takeoffer fails 2021-03-10 14:16:43 -03:00
ghubstan
389abf459d
Check valid createoffer opt values with asserts 2021-03-09 10:43:05 -03:00
ghubstan
de59c0a5f9
Assign selected trading currency on new payment accts (api only)
If a new account has a trading currency, assign it as the selected trading currency.

Also fixed a payment acct console formatting issue (left justify the ccy code).
2021-03-08 15:22:28 -03:00
ghubstan
a13ef79e6e
Handle require-arg options missing the = sign
This change ensure a stylistically consistent error message is printed
to the CLI console if an option is present, but without the '=' sign.
2021-03-05 12:28:10 -03:00
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