add dart examples

This commit is contained in:
ruben beck
2023-09-04 11:02:57 +02:00
parent 33eef9fdc4
commit 6fe109347a
4 changed files with 20 additions and 12 deletions

View File

@@ -51,7 +51,15 @@ try {
<section> <section>
```dart ```dart
// TODO add docs try {
BuyBitcoinResponse buyBitcoinResponse = buyBitcoin(
reqData: BuyBitcoinRequest(provider: BuyBitcoinProvider.Moonpay,
),
);
} catch {
// Handle error
}
``` ```
</section> </section>

View File

@@ -61,8 +61,12 @@ try {
```dart ```dart
try { try {
ReceivePaymentRequestData requestData = ReceivePaymentRequestData(amountSats: 3000, description: "Invoice for 3000 sats"); ReceivePaymentResponse invoice = await receivePayment(
ReceivePaymentResponse invoice = await receivePayment(reqData: requestData); reqData: ReceivePaymentRequestData(
amountSats: 3000,
description: "Invoice for 3000 sats",
),
);
} catch (error) { } catch (error) {
// handle error // handle error
} }

View File

@@ -69,11 +69,7 @@ try {
```dart ```dart
try { try {
// Optional user-selected dynamic fees (see Connecting to LSP section for details) SwapInfo swapInfo = await receiveOnchain(ReceiveOnchainRequest());
OpeningFeeParams? openingFeeParams = null;
ReceiveOnchainRequest request = new ReceiveOnchainRequest(openingFeeParams);
SwapInfo swapInfo = await receiveOnchain(request);
// Send your funds to the below bitcoin address // Send your funds to the below bitcoin address
String address = swapInfo.bitcoinAddress; String address = swapInfo.bitcoinAddress;

View File

@@ -66,7 +66,7 @@ try {
try { try {
ReverseSwapPairInfo currentFees = await fetchReverseSwapFees(); ReverseSwapPairInfo currentFees = await fetchReverseSwapFees();
print(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`); print("Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}");
} catch (error) { } catch (error) {
// handle error // handle error
} }
@@ -161,8 +161,8 @@ console.log(`Maximum amount, in sats: ${currentFees.max}`);
<section> <section>
```dart ```dart
print(`Minimum amount, in sats: ${currentFees.min}`); print("Minimum amount, in sats: ${currentFees.min}");
print(`Maximum amount, in sats: ${currentFees.max}`); print("Maximum amount, in sats: ${currentFees.max}");
``` ```
</section> </section>
@@ -262,7 +262,7 @@ try {
```dart ```dart
String destinationAddress = "bc1.."; String destinationAddress = "bc1..";
int amountSat = currentFees.min; int amountSat = <amount>;
int satPerVbyte = <fee rate> int satPerVbyte = <fee rate>
try { try {
ReverseSwapInfo reverseSwapInfo = await sendOnchain( ReverseSwapInfo reverseSwapInfo = await sendOnchain(