mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
Merge pull request #47 from breez/typescript-golang-0.2.3
Add typescript and golang examples
This commit is contained in:
@@ -39,9 +39,12 @@ do {
|
||||
<section>
|
||||
|
||||
```typescript
|
||||
// TODO add docs
|
||||
try {
|
||||
let buyBitcoinResponse = await buyBitcoin({provider: BuyBitcoinProvider.MOONPAY})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<div slot="title">Dart</div>
|
||||
@@ -69,9 +72,10 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
// TODO add docs
|
||||
buyBitcoinResponse, err := sdkService.BuyBitcoin(breez_sdk.BuyBitcoinRequest{
|
||||
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||
})
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<div slot="title">C#</div>
|
||||
|
||||
@@ -46,7 +46,10 @@ try {
|
||||
|
||||
```typescript
|
||||
try {
|
||||
const invoice = await receivePayment(3000, "Invoice for 3000 sats")
|
||||
const invoice = await receivePayment({
|
||||
amountSats: 3000,
|
||||
description: "Invoice for 3000 sats"
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
@@ -84,7 +87,10 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
invoice, err := sdkServices.ReceivePayment(3000, "Invoice for 3000 sats")
|
||||
invoice, err := sdkService.ReceivePayment(breez_sdk.ReceivePaymentRequest{
|
||||
AmountSats: 3000,
|
||||
Description: "Invoice for 3000 sats",
|
||||
})
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -54,11 +54,7 @@ try {
|
||||
|
||||
```typescript
|
||||
try {
|
||||
// Optional user-selected dynamic fees (see Connecting to LSP section for details)
|
||||
const openingFeeParams = null
|
||||
const request = {openingFeeParams: openingFeeParams}
|
||||
|
||||
const swapInfo = await receiveOnchain(request)
|
||||
const swapInfo = await receiveOnchain({})
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
const address = swapInfo.bitcoinAddress;
|
||||
@@ -105,12 +101,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
// Optional user-selected dynamic fees (see Connecting to LSP section for details)
|
||||
request := breez_sdk.ReceiveOnchainRequest{
|
||||
OpeningFeeParams: nil,
|
||||
}
|
||||
|
||||
if swapInfo, err := sdkServices.ReceiveOnchain(request); err != nil {
|
||||
if swapInfo, err := sdkServices.ReceiveOnchain(breez_sdk.ReceiveOnchainRequest{}); err != nil {
|
||||
// Send your funds to the below bitcoin address
|
||||
address := swapInfo.BitcoinAddress
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ try {
|
||||
let currentFees = try sdk.fetchReverseSwapFees(
|
||||
req: ReverseSwapFeesRequest(sendAmountSat: sendAmountSat))
|
||||
print("Total estimated fees for reverse swap: \(currentFees.totalEstimatedFees)")
|
||||
|
||||
} catch {
|
||||
// handle error
|
||||
}
|
||||
@@ -54,7 +53,6 @@ try {
|
||||
const currentFees = await fetchReverseSwapFees()
|
||||
|
||||
console.log(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
@@ -69,7 +67,6 @@ try {
|
||||
ReverseSwapPairInfo currentFees = await fetchReverseSwapFees();
|
||||
|
||||
print(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`);
|
||||
|
||||
} catch (error) {
|
||||
// handle error
|
||||
}
|
||||
@@ -96,7 +93,6 @@ except Exception as error:
|
||||
```go
|
||||
if currentFees, err := sdkServices.FetchReverseSwapFees(); err != nil {
|
||||
log.Printf("Total estimated fees for reverse swap: %v", currentFees.TotalEstimatedFees)
|
||||
|
||||
}
|
||||
```
|
||||
</section>
|
||||
@@ -109,7 +105,6 @@ try
|
||||
{
|
||||
var currentFees = sdk.FetchReverseSwapFees();
|
||||
Console.WriteLine($"Total estimated fees for reverse swap: {currentFees.totalEstimatedFees}");
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user