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>
|
<section>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// TODO add docs
|
try {
|
||||||
|
let buyBitcoinResponse = await buyBitcoin({provider: BuyBitcoinProvider.MOONPAY})
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div slot="title">Dart</div>
|
<div slot="title">Dart</div>
|
||||||
@@ -69,9 +72,10 @@ except Exception as error:
|
|||||||
<section>
|
<section>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// TODO add docs
|
buyBitcoinResponse, err := sdkService.BuyBitcoin(breez_sdk.BuyBitcoinRequest{
|
||||||
|
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div slot="title">C#</div>
|
<div slot="title">C#</div>
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ try {
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
try {
|
try {
|
||||||
const invoice = await receivePayment(3000, "Invoice for 3000 sats")
|
const invoice = await receivePayment({
|
||||||
|
amountSats: 3000,
|
||||||
|
description: "Invoice for 3000 sats"
|
||||||
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
@@ -84,7 +87,10 @@ except Exception as error:
|
|||||||
<section>
|
<section>
|
||||||
|
|
||||||
```go
|
```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>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,7 @@ try {
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
try {
|
try {
|
||||||
// Optional user-selected dynamic fees (see Connecting to LSP section for details)
|
const swapInfo = await receiveOnchain({})
|
||||||
const openingFeeParams = null
|
|
||||||
const request = {openingFeeParams: openingFeeParams}
|
|
||||||
|
|
||||||
const swapInfo = await receiveOnchain(request)
|
|
||||||
|
|
||||||
// Send your funds to the below bitcoin address
|
// Send your funds to the below bitcoin address
|
||||||
const address = swapInfo.bitcoinAddress;
|
const address = swapInfo.bitcoinAddress;
|
||||||
@@ -105,12 +101,7 @@ except Exception as error:
|
|||||||
<section>
|
<section>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Optional user-selected dynamic fees (see Connecting to LSP section for details)
|
if swapInfo, err := sdkServices.ReceiveOnchain(breez_sdk.ReceiveOnchainRequest{}); err != nil {
|
||||||
request := breez_sdk.ReceiveOnchainRequest{
|
|
||||||
OpeningFeeParams: nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
if swapInfo, err := sdkServices.ReceiveOnchain(request); err != nil {
|
|
||||||
// Send your funds to the below bitcoin address
|
// Send your funds to the below bitcoin address
|
||||||
address := swapInfo.BitcoinAddress
|
address := swapInfo.BitcoinAddress
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,9 @@ info!("Total estimated fees for reverse swap: {}", current_fees.total_estimated_
|
|||||||
// Optional parameter.
|
// Optional parameter.
|
||||||
let sendAmountSat:UInt64? = nil
|
let sendAmountSat:UInt64? = nil
|
||||||
try {
|
try {
|
||||||
let currentFees = try sdk.fetchReverseSwapFees(
|
let currentFees = try sdk.fetchReverseSwapFees(
|
||||||
req: ReverseSwapFeesRequest(sendAmountSat: sendAmountSat))
|
req: ReverseSwapFeesRequest(sendAmountSat: sendAmountSat))
|
||||||
print("Total estimated fees for reverse swap: \(currentFees.totalEstimatedFees)")
|
print("Total estimated fees for reverse swap: \(currentFees.totalEstimatedFees)")
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
@@ -54,7 +53,6 @@ try {
|
|||||||
const currentFees = await fetchReverseSwapFees()
|
const currentFees = await fetchReverseSwapFees()
|
||||||
|
|
||||||
console.log(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`);
|
console.log(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
@@ -69,7 +67,6 @@ 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
|
||||||
}
|
}
|
||||||
@@ -96,7 +93,6 @@ except Exception as error:
|
|||||||
```go
|
```go
|
||||||
if currentFees, err := sdkServices.FetchReverseSwapFees(); err != nil {
|
if currentFees, err := sdkServices.FetchReverseSwapFees(); err != nil {
|
||||||
log.Printf("Total estimated fees for reverse swap: %v", currentFees.TotalEstimatedFees)
|
log.Printf("Total estimated fees for reverse swap: %v", currentFees.TotalEstimatedFees)
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</section>
|
</section>
|
||||||
@@ -109,7 +105,6 @@ try
|
|||||||
{
|
{
|
||||||
var currentFees = sdk.FetchReverseSwapFees();
|
var currentFees = sdk.FetchReverseSwapFees();
|
||||||
Console.WriteLine($"Total estimated fees for reverse swap: {currentFees.totalEstimatedFees}");
|
Console.WriteLine($"Total estimated fees for reverse swap: {currentFees.totalEstimatedFees}");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user