Commit Graph

290 Commits

Author SHA1 Message Date
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
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
ghubstan
7e9ab22d65
Refactor api getbalance methods.
This change fixes the recently bloated wallet balances api.  Now there
is one CLI getbalance [bsq|btc] method that calls a getbalances(currency-code)
on the server.  The server returns full wallet balance information for
BSQ, BTC, or both if the CLI's currency argument is absent.

- grpc.proto:  Reduced number of getbalance(s) proto services from
  four to one.

- GrpcWalletsService:  Reduced number of getbalance(s) gRPC service
  boilerplate methods from four to one.

- CoreApi, CoreWalletsService:  Reduced number of getbalance(s) gRPC
  service implementation methods from four to one.

- CliMain:  Reduced number of getbalance(s) commands from four to one.

- BalancesInfo: Changed BsqBalanceInfo & BtcBalanceInfo field names
  to bsq and btc, respectively, to make calling their accessors
  more readable, less verbose.

- BtcBalanceInfo, BsqBalanceInfo: Defined static final EMPTY instances
  as place holders in a BalancesInfo returned by the gRPC server, when
  one or the other balance types is not requested.  Would be nice
  to serve Optional.empty() instead, but protobuf does not support
  it or null.

- Adjusted affected api tests and build doc.
2020-11-14 13:08:10 -03:00
ghubstan
722460e7e5
Support paying trade fees in bsq or btc (api)
- Add optional makerFeeCurrencyCode argument to CLI's 'createoffer'.

- Add optional takerFeeCurrencyCode argument to CLI's 'takeoffer'.

- Add isCurrencyForMakerFeeBtc field to OfferInfo proto wrapper.

- Pass fee currency argument down to CoreOffersService and CoreTradesService's
  create and take offer methods.

- Add maybeSetFeePaymentCurrencyPreference method to OfferUtil to
  conditionally set the 'payFeeInBtc' preference before creating
  or taking an offer.

- Adjust affected tests.
2020-11-13 16:36:06 -03:00
ghubstan
0d3b3a6ead
Stub out api method 'sendbsq' in core
All the boilerplate for this method is included in this change, but
the implementation in CoreWalletsService#sendBsq is commented out
until the needed logic to send bsq is refactored out of desktop's
BsqSendView class -- to be included in the next PR.

- Added new method to CLI.

- Added the gRPC server boilerplate.

- Added the core implementation, commented out.

- Enabled tests.
2020-11-13 14:57:28 -03:00
ghubstan
208a37b339
Implement and test new getbalance(s) api methods
- Added three new methods to CLI:

      getbalances   ...	returns complete bsq and btc balance info
      getbsqbalance ...	returns complete bsq balance info
      getbtcbalance ...	returns complete btc balance info

      The old getbalance method is deprecated and will be removed
      if there is agreement to do that.

- Made the needed changes in the CLI's output formatting classes.

- Added new tests to existing BsqWalletTest, added new BtcWalletTest
  and WalletBalancesTest.

- Added disabled tests for funding a bsq wallet (todo in next PR).
2020-11-13 14:21:26 -03:00
ghubstan
c1c099c832
Implement and test api method 'getunusedbsqaddress'
- Added new method to CLI, split some long msg strings into two lines,
  and added a white space after a braceless else statement.

- Added the gRPC server boilerplate.

- Added the core implementation.

- Added a test, and moved method wallet tests into their own package.
2020-11-13 12:40:16 -03:00
ghubstan
3cd3bf0e3e
Fix grammar / typo
This change resolves issue found in PR review.  See
https://github.com/bisq-network/bisq/pull/4703#discussion_r515076872
2020-10-30 11:52:37 -03:00
ghubstan
0f1d4f8ac3
Fix typo 2020-10-27 15:03:36 -03:00
ghubstan
027a7d5cd3
Stub out canceloffer api method
The implementation will be added to CoreOffersService in the next PR.
2020-10-27 14:54:50 -03:00
ghubstan
f1db254073
Make formatSatoshis visible for testing 2020-10-27 13:01:33 -03:00
ghubstan
a8decafc2f
Stub out api methods 'keepfunds', 'withdrawfunds'
This PR adds trade closing method stubs to keep funds in the
Bisq wallet or send them to an external BTC wallet.

- Add grpc protos
- Add new methods to GrpcTradesService, CoreApi
- Stub out implementations in CoreTradesService
- Add methods to CLI
2020-10-26 17:43:08 -03:00
ghubstan
a2b292318c
Add boolean 'showcontract' argument to api's 'gettrade'
Optionally print the json contract for a given trade id.
2020-10-25 17:44:18 -03:00
ghubstan
2b23704b5a
Add 'gettrade' to api method CLI 2020-10-25 17:15:02 -03:00
ghubstan
31435bba51
Move semicolon up from blank line 2020-10-25 17:02:40 -03:00
ghubstan
d8bc26588c
Add license comment 2020-10-25 16:52:45 -03:00
ghubstan
3379376bab
Refactor CLI output formatting code & add trade formatter
- Move output column header specs to its own shared constants class.

- Add new TradeFormat class for printing trade details in the console.

- Print formatted trade in api trade tests -- to see output before
  using formatter in CLI (in next PR).
2020-10-25 16:50:22 -03:00
ghubstan
ac8ed8dd06
Add 'confirmpaymentreceived' api method
- Implement confirmpaymentsent on server and cli side

- Enable confirmpaymentreceived method tests
2020-10-20 16:51:48 -03:00
ghubstan
3d2b90fb96
Add 'confirmpaymentsent' api method
- Implement confirmpaymentsent on server and cli side

- Enable confirmpaymentsent method tests
2020-10-20 16:20:40 -03:00
ghubstan
e809af37cc
Add 'takeoffer' API method
- Add new core.offer.takeoffer.TakeOfferModel

	Would have been nice to move more logic from
	bisq.desktop.main.offer.takeoffer.TakeOfferDataModel,
	but it has JFX dependencies that cannot be use in :core.

- Add grpc protos to support takeoffer, confirmpaymentsent, confirmpaymentreceived

	Only takeoffer is implemented in this commit.

- Refactor OfferInfo grpc proto wrapper, and add offer state field

- Add new TradeInfo grpc proto wrapper

- Implement takeoffer on server and cli side

- Refactor offer/trade tests, add test cases
2020-10-20 16:00:05 -03:00
ghubstan
29d1905f31
Add new 'getoffer offer-id' api method
There are a number of use cases where a user may want to see a single
offer instead of every offer for a currency pair on the buy or sell side.
The changes are:

- Add getoffer to grpc.proto
- Add new method to GrpcOffersService, CoreApi, CoreOffersService
- Add new method to CLI
- Adjust create offer tests to use this new convenience
2020-10-07 12:09:13 -03:00
ghubstan
723fc8fc08
Skip over method name in args loop, start at i=1 2020-10-02 18:11:25 -03:00
ghubstan
e09b821222
Explain use of args clone index (i-1) 2020-10-02 14:41:47 -03:00
ghubstan
23a677d3b8
Use list.set, not list.remove, list.add 2020-10-02 14:24:22 -03:00
ghubstan
2f3e3a31e1
Add simple mkt-price service & test calculated offer prices
A gRPC price service was added, and api create-offer tests can check
mkt based price margin calculations.
2020-09-25 20:48:26 -03:00
ghubstan
6cdbc137c1
Move 'createoffer' price arg transform to server & test it
The CreateOfferRequest's price field type was changed from long to string,
so a CLI param like 10000.0055 can be passed to the server as is, to be
scaled and converted there.  In general, we want to keep validation logic
on the CLI as simple as possible, and use existing core logic to
validate args and convert arg types when needed.
2020-09-24 18:13:19 -03:00
ghubstan
942a6f2203
Scale & convert (double) fixed price input to long 2020-09-24 14:56:27 -03:00
ghubstan
9999c95a9e
Change 'createoffer' argument order
And list the args in CLI --help outout.
2020-09-24 13:48:50 -03:00
ghubstan
ec9c1b0f10
Uppercase direction & ccy-code CLI arguments in core
Don't convert parameter case in CLI.
2020-09-24 09:18:13 -03:00
ghubstan
a6048a4f7d
Add comment to empty catch block for codacy 2020-09-23 20:43:56 -03:00
ghubstan
c8a7fe4b97
Print createoffer's reply in the CLI's console 2020-09-23 19:57:22 -03:00
ghubstan
d5b8800ba4
Add license comment and btc-string to satoshi converter
The converter is needed for CLI, which has no access to core or
common utils.
2020-09-23 19:52:37 -03:00
ghubstan
1431a076b2
Add license comment 2020-09-23 19:51:40 -03:00
ghubstan
adb175c21a
Add options helper for handling negative number CLI params 2020-09-23 19:50:04 -03:00
ghubstan
2b68e57273
Stub out createoffer method in CLI 2020-09-22 22:09:58 -03:00
ghubstan
e2bd89f39a
Refactor API & add registerdisputeagent method to CLI
This commit contains most of the changes suggested by @chimp1984 in
his api-suggestions branch.  See
961703ecea

A new 'registerdisputeagent' method was also added to MainCli, finishing
the work to support registration of mediators and refund agents on
arbitration daemons running in regtest mode.  This method cannot be
used to register dispute agents on mainnet;  users will see an error
msg if they try.
2020-09-18 11:33:16 -03:00
ghubstan
304047eaca
Create GrpcDisputeAgentsService stub 2020-09-14 11:40:22 -03:00
chimp1984
039860935d
Merge master
- fix tests
2020-09-01 19:53:23 -05:00
ghubstan
cb6166c65f
Remove duplicated grpc stub creation logic
The :apitest GrpcStubs class was removed and recreated in the :cli
subproject, to be used by both :cli and :apitest.  CliMain was changed
to use the new GrpcStubs.
2020-08-25 12:01:29 -03:00
ghubstan
2c803ef811
Move :cli test.sh to :apitest mainnet-test.sh
* The bats test script was moved to the apitest subproject and renamed.

* Version tests were updated for release 1.3.7.

* The duplicated "test getoffers buy eur check return status" was
  replaced by a new "test getoffers sell eur check return status" test.

* The bats dependency was switched to bats-core because development
  has halted on https://github.com/sstephenson/bats/tree/master.
  The new bats repository is
          https://github.com/bats-core/bats-core/tree/master
2020-08-25 11:42:09 -03:00
ghubstan
8269a0df6d
Remove final modifier 2020-07-17 17:13:45 -03:00
ghubstan
8da4646584
Update bats version test 2020-07-12 21:53:58 -03:00
ghubstan
f820897e5b
Format dates ISO 8601 in UTC
We display all dates in UTC, using the "yyyy-MM-dd'T'HH:mm:ss'Z'" format.
2020-06-24 13:27:43 -03:00
ghubstan
51d82b1dff
Fix offer list filter bug due to direction flip
Respect the direction parmeter;  do not give it meaning it does not
have.  If the user passes a 'buy' parameter, return buy offers.  Do
not misinterpret the param's intent.  The direction parameter's value
does not imply "buy=I'm a buyer, show me sell offers" or
"sell=I'm a seller, show me buy offers".

I got mixed up by looking at the UI.  If I want to sell BTC, I click
the SELL tab to view buy offers (maker as buyer).  If I want to buy
BTC, I click the BUY tab to view sell offers (maker as seller).

This change also fixes an offer list sorting bug.

The commit is in response to a requested changes in PR 4329:
https://github.com/bisq-network/bisq/pull/4329#pullrequestreview-436033502
2020-06-23 17:15:39 -03:00
ghubstan
69792098c6
Check param count only, not param order correctness
This change simplifies client 'getoffers' method parameter
validation.  It no longer assumes parameter ordering is correct, nor
validates the direction parameter value.  The client only verifies
the correct number of string parameters are present.
2020-06-23 15:29:32 -03:00
ghubstan
9691f35082
Check param count only, not param order correctness
This change simplifies client 'createpaymentacct' method parameter
validation.  It no longer assumes parameter ordering is correct, and
only verifies the string parameter count is correct.

A unit test was also added to cli/test.sh

This commit is in response to the requested change in PR 4308.
https://github.com/bisq-network/bisq/pull/4308#pullrequestreview-435052357
2020-06-23 12:42:56 -03:00
ghubstan
52529a912e
Move getpaymentaccts tbl formatting to TableFormat
Created a new TableFormat.formatPaymentAcctTbl method.

Also:

 * Defined new "Currency" and "Name" column headers in TableFormat.

 * Changed syntax of stream().map() calls in some TableFormat methods.

 * Fixed verbose return statement in TableFormat.getLengthOfLongestColumn.

This commit is out of scope for the getoffers PR (4329), but is
included as part of the migration of all console tbl formatting
from the client into TableFormat.
2020-06-22 18:20:09 -03:00
ghubstan
8dcfa50bde
Define reusable headers from balance-info tbl 2020-06-22 17:49:46 -03:00
ghubstan
0d9bdefa00
Add 'getoffers' smoke test 2020-06-22 15:23:27 -03:00
ghubstan
61285a7602
Do not change case of input params in client
This commit is for a change requested in PR 4308:
https://github.com/bisq-network/bisq/pull/4308#pullrequestreview-435055483

  ".toUpperCase() seems misplaced here. It would soon get repetive.
  Whether the underlying logic differentiates between capitalizations
  is a low-level implementation detail and would do better at the
  lowest practical level."
2020-06-22 15:08:46 -03:00
ghubstan
a48af7c052
Add 'getoffers' unit tests 2020-06-22 14:43:59 -03:00
ghubstan
b25abf1b6b
Refactor CLI output table formatting
This change moves logic for formatting BTC balances, dates and
tables out of CliMain.  Two new output formatting classes were
added:  CurrencyFormat and TableFormat.
2020-06-21 19:46:37 -03:00
ghubstan
1756258e81
Do not use protobuf.OfferPayload.Direction in client 2020-06-20 20:09:18 -03:00
ghubstan
88cb90e209
Add rpc method 'getoffers'
The new method returns current buy or sell offers for a fiat ccy.

These changes need refactoring and polishing before merging, but they're
committed in this state to be safe (don't lose work).  Changes include:

* New core.grpc classes
    CoreOffersService
    GrpcOffersService
    model.OfferInfo

* CoreApi -- The new CoreOffersService is injected into CoreApi and
  the old getOffers() and placeOffer() impls were moved into the
  new CoreOffersService.  The getOffers implementation was re-done.
  Other changes are just rearranging location of core method calls.

* GrpcServer -- The new GrpcOffersService replaced the old
  GetOffersService and PlaceOfferService.

* grpc.proto -- The old GetOffers and PlaceOffer services were combined
  into a single Offers service, and the PlaceOffer rpc was renamed
  as CreateOffer.  These are the only substantive changes; the rest
  is just rearranging location of the service defs in the file.
  Also created a lighterweight OfferInfo proto message wrapper to
  be passed between server & client (client has no access to core's
  Offer and OfferPayload).

* OfferInfo -- A new wrapper around the OfferInfo proto message.

* CliMain -- The new GetOffers service stub was added.
  Some (maybe too much) number and ccy formatting logic was
  copied & modified from core.  Some tedius string formatting
  was added too (needs to be tidied up).

* License comments were also copied to several classes, and I
  made a mistake in reverting changes to the wrong file.

TODO add unit tests
2020-06-20 19:56:28 -03:00
ghubstan
37fb60672f
Add license comment
This is not in scope of current PR, but easy enough to review.
2020-06-20 09:59:06 -03:00
ghubstan
612bafe59a
Refactor AddressBalanceInfo display logic 2020-06-20 08:42:58 -03:00
ghubstan
331f488057
Return protos from funding address methods
The 'getaddressbalance' and 'getfundingaddresses' methods now send
new AddressBalanceInfo proto messages instead of a formatted String
to the client.  The AddressBalanceInfo message contains addressString,
balance, and # of confirmations (transaction confidence) fields.

Changes include:
* A new AddressBalanceInfo proto message
* A wrapper class for the new AddressBalanceInfo proto
* New 'getaddressbalance' and 'getfundingaddresses' signatures in server
* AddressBalanceInfo display logic in client
* Removal of balance formatting logic in server
* Refactoring of balance formatting logic in client
2020-06-19 20:00:28 -03:00
ghubstan
435672a5ee
Add rpc method 'getpaymentaccts'
This addresses task 5 in issue 4257
	https://github.com/bisq-network/bisq/issues/4257

This new gRPC PaymentAccounts service method displays the user's
saved payment accounts.

A unit test to check a successful return status code was added
to cli/test.sh.

This PR should be reviewed/merged after PR 4322.
	https://github.com/bisq-network/bisq/pull/4322
2020-06-19 12:45:04 -03:00
ghubstan
bac3ed5697
Call core wallets service methods from CoreApi
This change is a refactoring of the gRPC Wallets service
for the purpose of making CoreApi the entry point to
all core implementations.  These changes should have been
made in PR 4295.
See https://github.com/bisq-network/bisq/pull/4295

The gRPC Wallet proto def name was changed to Wallets because
this service manages BSQ and BTC wallets, and GrpcWalletService
was changed to GrpcWalletsService for the same reason.

This PR should be reviewed/merged after PR 4308.
See https://github.com/bisq-network/bisq/pull/4308

This PR's branch was created from the PR 4308 branch.
2020-06-15 16:43:26 -03:00
ghubstan
a7542e98bf
Add rpc method 'createpaymentacct'
This addresses task 4 in issue 4257.
    https://github.com/bisq-network/bisq/issues/4257

This PR should be reviewed/merged after PR 4304.
    https://github.com/bisq-network/bisq/pull/4304

This new gRPC PaymentAccounts service method creates a dummy
PerfectMoney payment account for the given name, number and fiat
currency code, as part of the required "simplest possible trading
API" (for demo).   An implementation supporting all payment
methods is not in the scope.

Changes specific to the new rpc method implementation follow:

* New createpaymentacct method + help text was added to CliMain.
  Help text formatting was also changed to make room for larger
  method names and argument lists.

* The PaymentAccount proto service def was renamed PaymentAccounts
  to avoid a name collision, and the new rpc CreatePaymentAccount
  was made part of the newly named PaymentAccounts service def.

* New GrpcPaymentAccountsService (gRPC boilerplate) and
  CorePaymentAccountsService (method implementations) classes were
  added.

* The gRPC GetPaymentAccountsService stub was moved from GrpcServer
  to the new GrpcPaymentAccountsService class, and
  GrpcPaymentAccountsService is injected into GrpcServer.

* A new createpaymentacct unit test was added to the bats test
  suite (checks for successful return status code).

Maybe bit out of scope, some small changes were made towards making
sure the entire API is defined in CoreApi, which is used as a
pass-through object to the new CorePaymentAccountsService.  In the
next PR, similar refactoring will be done to make CoreApi the
pass-through object for all of the existing CoreWalletsService
methods.  (CoreWalletsService will be injected into CoreApi.)
In the future, all Grpc*Service implementations will call core
services through CoreApi, for the sake of consistency.
2020-06-15 14:32:14 -03:00
ghubstan
b1228e5ea7
Add rpc method 'getaddressbalance'
This addresses task 2 in issue 4257
	https://github.com/bisq-network/bisq/issues/4257

This new gRPC Wallet service method displays the balance and number
of confimirmations of the most recent transaction for the given BTC
wallet address.

The new method required the usual boilerplate changes to grpc.proto,
CliMain, and GrpcWalletService.

Two unit tests to check error msgs was added to cli/test.sh.
2020-06-14 14:23:47 -03:00
ghubstan
2e415de4ad
Replace duplicate code in getFundingAddresses
Cleaned up the method body and improved the returned string's
formatting.  Also added a line for this method in the CLI help text.
2020-06-14 13:05:37 -03:00
ghubstan
85c96764fb
Add rpc method 'getfundingaddresses'
This addresses task #1 in issue https://github.com/bisq-network/bisq/issues/4257.

This new gRPC WalletService method displays the BTC wallet's list of
receiving addresses.  The balance and number of confirmations
for the most recent transaction is displayed to the right of each
address.  Instead of returning a gRPC data structure to the client,
the service method returns a formatted String.

If the BTC wallet has no unused addresses, one will be created and
included in the returned list, and it can be used to fund the wallet.

The new method required injection of the BtcWalletService into CoreWalletsService,
and the usual boilerplate changes to grpc.proto, CliMain, and GrpcWalletService.

Some of the next PRs (for #4257) will require some common functionality within
CoreWalletsService, so these additional changes were included:

  * a private, class level formatSatoshis function
  * a public getNumConfirmationsForMostRecentTransaction method
  * a public getAddressBalance method
  * a private getAddressEntry method

A unit test that verifies a successful return status was added to cli/test.sh.
2020-06-13 19:59:45 -03:00
ghubstan
ec66b14986
Add rpc wallet(s) protection tests
This commit includes the following changes:

 * New tests for methods `lockwallet`, `unlockwallet`,
   `removewalletpassword`, and `setwalletpassword`.

 * New `getbalance` method error handing tests to verify
   error message correctness when wallet is locked.

 * Update to `getversion` method test -- now expects `1.3.4`.

 * Check for new `[params]` column header in help text.
2020-06-12 15:56:19 -03:00
Chris Beams
2e33c2c87a
Merge pull request #4214 from ghubstan/rpc-wallet-protection
Add rpc wallet protection endpoints
2020-05-18 14:18:05 +02:00
ghubstan
9b156b86dd
Remove unlockwallet timeout variable initializer
This variable no longer needs to be initialized to avoid a compiler error.
2020-05-04 15:19:18 -03:00
Chris Beams
d48f9eb6f0
Tighten up error handling
This commit factors out a run() method in CliMain that either returns
(void) or throws an exception. This eliminates the need to call
System.exit in so many places as were previously. Indeed, now there is
only one place where System.exit is called.

It also removes the duplication of printing "Error: ..." to stderr when
something goes wrong by doing this once in the global catch clause in
the main method.
2020-05-04 13:58:46 +02:00
Chris Beams
b0e5da8e2e
Refactor setwalletpassword handling to eliminate duplication 2020-05-04 12:22:13 +02:00
Chris Beams
6334c5478c
Generalize gRPC exception message cleanup 2020-05-03 15:47:26 +02:00
Chris Beams
c7a6c87bd1
Refactor grpc wallet service
Previously, each wallet-related method was implemented with its own grpc
service. There is no need to do this, as a grpc service may declare
multiple rpc methods. This commit refactors everything wallet-related
into a single GrpcWalletService and also extracts a CoreWalletService
from CoreApi in order to avoid the latter becoming overly large.
Ideally, there would be no need for an abstraction in bisq.grpc called
CoreWalletService; we would ideally use such a service implemented in
bisq.core. The closest we have is WalletsManager, but it is not designed
to be used the way we are using it here in the grpc context. Rather than
making changes directly to core (which can be very risky), we will
rather make them here in this layer, designing exactly the "core wallet
service" we need, and can then later see about folding it into the
actual core.
2020-05-03 15:46:41 +02:00
ghubstan
2a9d1f6d34
Improve gRPC error handling
This change removes non-idiomatic gRPC *Reply proto message fields.
The client should not receive success/fail values from server methods
with a void return type, nor an optional error_message from any server
method.  This change improves error handling by wrapping an appropriate
gRPC Status with a meaningful error description in a StatusRuntimeException,
and placing it in the server's response StreamObserver.  User error
messages are mapped to general purpose gRPC Status codes in a new ApiStatus
enum class.  (Maybe ApiStatus should be renamed to CoreApiStatus.)
2020-05-01 17:29:14 -03:00
Chris Beams
765da55daa
Polish cli test suite documentation 2020-05-01 11:48:59 +02:00
Chris Beams
b88f1bf84f
Polish whitespace
Per https://github.com/bisq-network/style/issues/10
2020-05-01 11:11:50 +02:00
ghubstan
ca68d0567f
Add wallet protection methods to printHelp(opts) 2020-04-30 11:21:04 -03:00
ghubstan
2096275722
Handle unlockwallet parameter errors 2020-04-30 11:00:22 -03:00
ghubstan
de50692daa
Add rpc wallet protection endpoints
Implemented lockwallet, unlockwallet, removewalletpassword, and
setwalletpassword methods with basic error handling.

Also added basic error handling to existing getbalance method,
and removed unused BalancePresentation from CoreAPI.

TODO:  update help text
2020-04-29 19:25:23 -03:00
ghubstan
5d3abef3fc
Migrate expect based test to bats 2020-04-29 11:59:05 -03:00
ghubstan
cfb7e32e70
Remove note to self 2020-04-26 16:54:10 -03:00
Chris Beams
312ef30b70
Revert marking password as required in JOpt parser
This is a partial reversion of the earlier commit. Marking the password
option as required at the parser level made it impossible to run
./bisq-cli without options or arguments and get the help text. This is a
useful thing to do, and not worth creating a bad user experience to get
the free required option error handling and error messaging.
2020-04-26 21:44:03 +02:00