Merge pull request #2 from ghubstan/add-takeoffer-amount-param

Add takeoffer amount param to reference doc & examples
This commit is contained in:
Bisq GitHub Admin 2022-08-10 20:13:27 +02:00 committed by GitHub
commit 655f741fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 100 additions and 23 deletions

View File

@ -2,11 +2,13 @@
source "env.sh"
# Take a BSQ swap offer.
$BISQ_HOME/bisq-cli --password=xyz --port=9998 takeoffer --offer-id=8368b2e2-anb6-4ty9-ab09-3ebdk34f2aea
# The amount param is optional.
$BISQ_HOME/bisq-cli --password=xyz --port=9998 takeoffer --offer-id=8368b2e2-anb6-4ty9-ab09-3ebdk34f2aea --amount=0.1
# Take an offer that is not a BSQ swap offer.
# The payment-account-id param is required, the fee-currency param is optional.
# The payment-account-id param is required, the amount and fee-currency params are optional.
$BISQ_HOME/bisq-cli --password=xyz --port=9998 takeoffer \
--offer-id=83e8b2e2-51b6-4f39-a748-3ebd29c22aea \
--payment-account-id=fe20cdbd-22be-4b8a-a4b6-d2608ff09d6e \
--amount=0.08 \
--fee-currency=BTC

View File

@ -0,0 +1,27 @@
# How to upgrade the Gradle version
Visit the [Gradle website](https://gradle.org/releases) and decide the:
- desired version
- desired distribution type
- what is the sha256 for the version and type chosen above
Adjust the following command with tha arguments above and execute it twice:
```asciidoc
$ ./gradlew wrapper --gradle-version 7.5 \
--distribution-type bin \
--gradle-distribution-sha256-sum cb87f222c5585bd46838ad4db78463a5c5f3d336e5e2b98dc7c0c586527351c2
```
The first execution should automatically update:
- `java-examples/gradle/wrapper/gradle-wrapper.properties`
The second execution should then update:
- `java-examples/gradle/wrapper/gradle-wrapper.jar`
- `java-examples/gradlew`
- `java-examples/gradlew.bat`
The four updated files are ready to be committed.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionSha256Sum=cb87f222c5585bd46838ad4db78463a5c5f3d336e5e2b98dc7c0c586527351c2
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

View File

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@ -28,7 +28,8 @@ public class TakeOffer extends BaseJavaExample {
var offerCategory = offersStub.getOfferCategory(getOfferCategoryRequest);
// Create a takeoffer request builder with just the offerId parameter.
var takeOfferRequestBuilder = TakeOfferRequest.newBuilder()
.setOfferId("83e8b2e2-51b6-4f39-a748-3ebd29c22aea");
.setOfferId("83e8b2e2-51b6-4f39-a748-3ebd29c22aea")
.setAmount(1_000_000L); // 1 million satoshis = 0.01 BTC
// If offer is not a BSQ swap offer, add the paymentAccountId and takerFeeCurrencyCode parameters.
if (!offerCategory.equals(BSQ_SWAP))
takeOfferRequestBuilder

View File

@ -8,7 +8,7 @@ import bisq.api.grpc_pb2_grpc as bisq_service
def main():
grpc_channel = grpc.insecure_channel('localhost:9999')
grpc_channel = grpc.insecure_channel('localhost:9998')
grpc_offers_service_stub = bisq_service.OffersStub(grpc_channel)
grpc_trades_service_stub = bisq_service.TradesStub(grpc_channel)
api_password: str = 'xyz' # getpass("Enter API password: ")
@ -16,13 +16,17 @@ def main():
# We need to send our payment account id and an (optional) taker fee currency code if offer
# is not a BSQ swap offer. Find out by calling GetOfferCategory before taking the offer.
get_offer_category_response = grpc_offers_service_stub.GetOfferCategory.with_call(
bisq_messages.GetOfferCategoryRequest(id='4940749-73a2e9c3-d5b9-440a-a05d-9feb8e8805f0-182'),
bisq_messages.GetOfferCategoryRequest(id='MGAQRIJJ-3aba77be-588c-4f98-839e-53fac183b823-194'),
metadata=[('password', api_password)])
offer_category = get_offer_category_response[0].offer_category
is_bsq_swap = offer_category == bisq_messages.GetOfferCategoryReply.BSQ_SWAP
take_offer_request = bisq_messages.TakeOfferRequest(offer_id='4940749-73a2e9c3-d5b9-440a-a05d-9feb8e8805f0-182')
take_offer_request = bisq_messages.TakeOfferRequest(
offer_id='MGAQRIJJ-3aba77be-588c-4f98-839e-53fac183b823-194',
# 10 million satoshis = 0.1 BTC
amount=10000000
)
if not is_bsq_swap:
take_offer_request.payment_account_id = '44838060-ddb5-4fa4-8b34-c128a655316e'
take_offer_request.payment_account_id = '88892636-81a1-4864-a396-038297e112cf'
take_offer_request.taker_fee_currency_code = 'BSQ'
response = grpc_trades_service_stub.TakeOffer.with_call(
take_offer_request,

View File

@ -0,0 +1,27 @@
# How to upgrade the Gradle version
Visit the [Gradle website](https://gradle.org/releases) and decide the:
- desired version
- desired distribution type
- what is the sha256 for the version and type chosen above
Adjust the following command with tha arguments above and execute it twice:
```asciidoc
$ ./gradlew wrapper --gradle-version 7.5 \
--distribution-type bin \
--gradle-distribution-sha256-sum cb87f222c5585bd46838ad4db78463a5c5f3d336e5e2b98dc7c0c586527351c2
```
The first execution should automatically update:
- `reference-doc-builder/gradle/wrapper/gradle-wrapper.properties`
The second execution should then update:
- `reference-doc-builder/gradle/wrapper/gradle-wrapper.jar`
- `reference-doc-builder/gradlew`
- `reference-doc-builder/gradlew.bat`
The four updated files are ready to be committed.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionSha256Sum=cb87f222c5585bd46838ad4db78463a5c5f3d336e5e2b98dc7c0c586527351c2
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

View File

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal