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

View File

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

View File

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

View File

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