mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Update Dart documentation
This commit is contained in:
@@ -68,7 +68,8 @@ try {
|
|||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
BuyBitcoinResponse buyBitcoinResponse = buyBitcoin(
|
BuyBitcoinResponse buyBitcoinResponse = buyBitcoin(
|
||||||
reqData: BuyBitcoinRequest(provider: BuyBitcoinProvider.Moonpay,
|
reqData: BuyBitcoinRequest(
|
||||||
|
provider: BuyBitcoinProvider.Moonpay,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ try {
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
Map<String, Rate> fiatRatesMap = fetchFiatRates();
|
Map<String, Rate> fiatRatesMap = await fetchFiatRates();
|
||||||
// print your desired rate
|
// print your desired rate
|
||||||
print(fiatRatesMap["USD"]?.value);
|
print(fiatRatesMap["USD"]?.value);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -201,7 +201,31 @@ fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
|
|||||||
<section>
|
<section>
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
// TODO
|
Future<Map<FiatCurrency, Rate>> fiatCurrenciesAndRate() async {
|
||||||
|
try {
|
||||||
|
List<FiatCurrency> fiatCurrencies = await _breezLib.listFiatCurrencies();
|
||||||
|
Map<String, Rate> fiatRates = await _breezLib.fetchFiatRates();
|
||||||
|
|
||||||
|
var sorted = fiatCurrencies.toList();
|
||||||
|
sorted.sort((f1, f2) {
|
||||||
|
return f1.id.compareTo(f2.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<FiatCurrency, Rate> result = {};
|
||||||
|
for (var currency in sorted) {
|
||||||
|
var rate = fiatRates[currency.id];
|
||||||
|
if (rate != null) {
|
||||||
|
result[currency] = rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (e) {
|
||||||
|
// Handle error
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ try {
|
|||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
ReceivePaymentResponse invoice = await receivePayment(
|
ReceivePaymentResponse invoice = await receivePayment(
|
||||||
reqData: ReceivePaymentRequestData(
|
reqData: ReceivePaymentRequest(
|
||||||
amountSats: 3000,
|
amountSats: 3000,
|
||||||
description: "Invoice for 3000 sats",
|
description: "Invoice for 3000 sats",
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ try {
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
SwapInfo swapInfo = await receiveOnchain(ReceiveOnchainRequest());
|
SwapInfo swapInfo = await receiveOnchain(
|
||||||
|
reqData: ReceiveOnchainRequest(),
|
||||||
|
);
|
||||||
|
|
||||||
// Send your funds to the below bitcoin address
|
// Send your funds to the below bitcoin address
|
||||||
String address = swapInfo.bitcoinAddress;
|
String address = swapInfo.bitcoinAddress;
|
||||||
@@ -175,7 +177,7 @@ try {
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
SwapInfo? swapInfo = await inProgressSwap()
|
SwapInfo? swapInfo = await inProgressSwap();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
@@ -507,7 +509,8 @@ try {
|
|||||||
```dart
|
```dart
|
||||||
int amountMsats = <amount msats>
|
int amountMsats = <amount msats>
|
||||||
try {
|
try {
|
||||||
int channelFees = openChannelFee(OpenChannelFeeRequest(
|
int channelFees = openChannelFee(
|
||||||
|
req: OpenChannelFeeRequest(
|
||||||
amountMsats: amountMsats,
|
amountMsats: amountMsats,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ try {
|
|||||||
String destinationAddress = "bc1..";
|
String destinationAddress = "bc1..";
|
||||||
int amountSat = <amount>;
|
int amountSat = <amount>;
|
||||||
int satPerVbyte = <fee rate>
|
int satPerVbyte = <fee rate>
|
||||||
|
ReverseSwapPairInfo currentFees = <current reverse swap fees>
|
||||||
try {
|
try {
|
||||||
ReverseSwapInfo reverseSwapInfo = await sendOnchain(
|
ReverseSwapInfo reverseSwapInfo = await sendOnchain(
|
||||||
amountSat: amountSat,
|
amountSat: amountSat,
|
||||||
|
|||||||
@@ -63,7 +63,11 @@ try {
|
|||||||
|
|
||||||
```dart
|
```dart
|
||||||
try {
|
try {
|
||||||
StaticBackupResponse backupData = await staticBackup(request: StaticBackupRequest(workingDir: "<working directory>"));
|
StaticBackupResponse backupData = await staticBackup(
|
||||||
|
request: StaticBackupRequest
|
||||||
|
workingDir: "<working directory>",
|
||||||
|
),
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user