Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'placeoffer' method #4574

Closed
wants to merge 46 commits into from
Closed

Conversation

ghubstan
Copy link
Contributor

New offer placement is moved out of createoffer into a separate method, to give users a chance to review new offer details before broadcasting it.

When createoffer is called, the new offer is cached in CoreOffersService for 5 minutes, and details are displayed in the CLI console. The user can broadcast the cached offer by calling placeoffer offer-id security-deposit. The security-deposit parameter is a % as double, e.g., 0.15.

PRs #4554 and #4559 need to be review/merged before this one.

Bats version check tests now use a bash script for parsing
the value from the Bisq class file, and these test cases
no longer need to be manually updated.
The string constants deleted from the test case are re-defined as enums,
but the test harness still passes around strings (enum.name()) because
the handling of invalid dispute agent type string args needs to be
tested.  (Reminder:  CLI does not accept any enum arguments.)
And make test dispute agent registration work from static fixture
setup methods.
The converter is needed for CLI, which has no access to core or
common utils.
Don't convert parameter case in CLI.
And list the args in CLI --help outout.
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.
And move createAndPlaceOffer to bottom of class file.
A gRPC price service was added, and api create-offer tests can check
mkt based price margin calculations.
The CLI needs to be able to register a REFUND_AGENT using the
'refund_agent' or 'refundagent' parameter value (in any case),
so an alt-name mapping was added to the enum def.
This is an ugly, temporary fix.  Need to refactor again.
…oblem"

This reverts commit 50d4b9f.
Back out codacy fix;  it did not work.
Separates offer placement from offer creation to fix tx result
handling problem in GrpcOffersService, and readies the core api
for a new CLI 'placeoffer' implementation.  Offer placement still
happens in the api's 'createoffer', but we may want to change it
to show the created offer to a CLI user for review, prior to manual
placement via a new 'placeoffer offer-id' (of 'confirmoffer offer-id'?)
api method.
This needs to be carefully reviewed to be sure it does not break the
create/place offer error messaging in the UI, and should be
reverted if offer validation will be refactored to work for both
UI and gRPC CLI.
New offer placement is moved out of 'createoffer' into a separate
method, to give users a chance to review new offer details before
broadcasting it.

When createoffer is called, the new offer is cached in CoreOffersService
for 5 minutes and details are displayed in the CLI console.  The user
can broadcast the cached offer by calling 'placeoffer offer-id security-deposit'.
The security-deposit parameter is a % as double, e.g., 0.15.
@ghubstan
Copy link
Contributor Author

CLI example:

Start daemons:

$ ./bisq-apitest --apiPassword=xyz --supportingApps=bitcoind,seednode,arbdaemon,alicedaemon  --shutdownAfterTests=false

Get the dummy payment account id needed for create offer:

$ ./bisq-cli --password=xyz getpaymentaccts

Name                Currency  Payment Method  ID                                                    
PerfectMoney dummy       EUR  PERFECT_MONEY   c1ca87a6-918f-4a57-960a-979596dee7f6                
ETH dummy                ETH  BLOCK_CHAINS    d55040c4-aff4-4ed4-a900-73df578f9d2a                

Create and cache a new offer, then examine it:

$ ./bisq-cli --password=xyz createoffer c1ca87a6-918f-4a57-960a-979596dee7f6 sell usd 0.125 0.125 true 0.00 0.15

Buy/Sell  Price in usd for 1 BTC  BTC(min - max)            usd(min - max)  Payment Method  Creation Date (UTC)   ID
SELL                 10,735.0905  0.12500000                         1,342  Perfect Money   2020-09-29T19:24:27Z  NAUGWFYZ-ddbc5348-2a9e-4ba6-a9b1-7cc10e622d9e-139   

Place the offer with offer-id param, and a security deposit param as a % double value:

$ ./bisq-cli --password=xyz placeoffer NAUGWFYZ-ddbc5348-2a9e-4ba6-a9b1-7cc10e622d9e-139  0.15	

offer placed

Look at the sell/usd offer just placed:

$ ./bisq-cli --password=xyz getoffers sell usd	

Buy/Sell  Price in usd for 1 BTC  BTC(min - max)            usd(min - max)  Payment Method  Creation Date (UTC)   ID
SELL                 10,735.0905  0.12500000                         1,342  Perfect Money   2020-09-29T19:24:27Z  NAUGWFYZ-ddbc5348-2a9e-4ba6-a9b1-7cc10e622d9e-139

But show original error msgs in server log.

- TaskRunner:  Prepend "Error at taskRunner:" to logged server error,
  but pass only the throwable.message to the error msg handler.

- Task:  Prepend "An error occurred at task:" to logged server error,
  but pass only the throwable.message to the error msg handler.

This change will show a CLI user cleaner error msgs.  For example,
a CLI user would now see:  "Amount is larger than 1.00 BTC", not
"Error at taskRunner: An error occurred at task ValidateOffer: Amount is larger than 1.00 BTC"

Minor re-formatting was made in Task and TaskRunner.
@ghubstan
Copy link
Contributor Author

ghubstan commented Oct 2, 2020

Closed, as per #4559 (review).

@ghubstan ghubstan closed this Oct 2, 2020
@ghubstan ghubstan deleted the placeoffer branch October 7, 2020 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant