Merge pull request #47 from breez/typescript-golang-0.2.3

Add typescript and golang examples
This commit is contained in:
Ross Savage
2023-09-04 09:57:54 +02:00
committed by GitHub
4 changed files with 19 additions and 23 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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
}

View File

@@ -23,10 +23,9 @@ info!("Total estimated fees for reverse swap: {}", current_fees.total_estimated_
// Optional parameter.
let sendAmountSat:UInt64? = nil
try {
let currentFees = try sdk.fetchReverseSwapFees(
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)
{