Add --amount parameter to takeoffer examples

This commit is contained in:
ghubstan 2022-08-10 11:49:33 -03:00
parent 98d7405639
commit ffe277a596
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
3 changed files with 14 additions and 7 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

@ -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,