mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
@@ -94,9 +94,12 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
buyBitcoinResponse, err := sdkService.BuyBitcoin(breez_sdk.BuyBitcoinRequest{
|
||||
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||
})
|
||||
buyBitcoinRequest := breez_sdk.BuyBitcoinRequest{
|
||||
Provider: breez_sdk.BuyBitcoinProviderMoonpay,
|
||||
}
|
||||
if buyBitcoinResponse, err := sdk.BuyBitcoin(buyBitcoinRequest); err == nil {
|
||||
log.Printf("%#v", buyBitcoinResponse)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -85,13 +85,11 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
lspId, err := sdkServices.LspId()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
if lspId, err := sdk.LspId(); lspId != nil && err == nil {
|
||||
log.Printf("%#v", *lspId)
|
||||
}
|
||||
lspInfo, err := sdkServices.LspInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
if lspInfo, err := sdk.LspInfo(); err == nil {
|
||||
log.Printf("%#v", lspInfo)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
@@ -188,11 +186,11 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
err = sdkServices.ConnectLsp(*lspId)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
lspId := "your selected lsp id"
|
||||
if err := sdk.ConnectLsp(lspId); err != nil {
|
||||
log.Printf("%#v", err)
|
||||
}
|
||||
```
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">C#</div>
|
||||
|
||||
@@ -55,7 +55,9 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
fiatCurrencies, err := sdkServices.ListFiatCurrencies()
|
||||
if fiatCurrencies, err := sdk.ListFiatCurrencies(); err == nil {
|
||||
log.Printf("%#v", fiatCurrencies)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -132,7 +134,9 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
fiatRates, err := sdkServices.FetchFiatRates()
|
||||
if fiatRates, err := sdk.FetchFiatRates(); err == nil {
|
||||
log.Printf("%#v", fiatRates)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ if err != nil {
|
||||
// Customize the config object according to your needs
|
||||
config.workingDir = "path to an existing directory"
|
||||
|
||||
sdkServices, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||
sdk, err := breez_sdk.Connect(config, seed, BreezListener{})
|
||||
if err != nil {
|
||||
log.Fatalf("Connect failed: %#v", err)
|
||||
}
|
||||
|
||||
@@ -153,10 +153,11 @@ lnurlAuthUrl := "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvd
|
||||
if input, err := breez_sdk.ParseInput(lnurlAuthUrl); err != nil {
|
||||
switch inputType := input.(type) {
|
||||
case breez_sdk.InputTypeLnUrlAuth:
|
||||
if result, err := sdkServices.LnurlAuth(inputType.Data); err != nil {
|
||||
if (result.Status === "ok") {
|
||||
if result, err := sdk.LnurlAuth(inputType.Data); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlCallbackStatusOk:
|
||||
log.Printf("Successfully authenticated")
|
||||
} else {
|
||||
default:
|
||||
log.Printf("Failed to authenticate")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,14 @@ if input, err := breez_sdk.ParseInput(lnurlPayUrl); err != nil {
|
||||
case breez_sdk.InputTypeLnUrlPay:
|
||||
amountsSats := inputType.Data.MinSendable
|
||||
comment := "comment"
|
||||
result, err := sdkServices.PayLnurl(inputType.Data, amountsSats, &comment)
|
||||
if result, err := sdk.PayLnurl(inputType.Data, amountsSats, &comment); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlPayResultEndpointSuccess:
|
||||
log.Printf("Successfully paid")
|
||||
default:
|
||||
log.Printf("Failed to pay")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -139,7 +139,14 @@ if input, err := breez_sdk.ParseInput(lnurlWithdrawUrl); err != nil {
|
||||
case breez_sdk.InputTypeLnUrlWithdraw:
|
||||
amountsSats := inputType.Data.MinWithdrawable
|
||||
description := "comment"
|
||||
result, err := sdkServices.WithdrawLnurl(inputType.Data, amountsSats, &description)
|
||||
if result, err := sdk.WithdrawLnurl(inputType.Data, amountsSats, &description); err != nil {
|
||||
switch result.(type) {
|
||||
case breez_sdk.LnUrlCallbackStatusOk:
|
||||
log.Printf("Successfully withdrawn")
|
||||
default:
|
||||
log.Printf("Failed to withdraw")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -104,10 +104,13 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
invoice, err := sdkService.ReceivePayment(breez_sdk.ReceivePaymentRequest{
|
||||
AmountSats: 3000,
|
||||
Description: "Invoice for 3000 sats",
|
||||
})
|
||||
receivePaymentRequest := breez_sdk.ReceivePaymentRequest{
|
||||
AmountSats: 3000,
|
||||
Description: "Invoice for 3000 sats",
|
||||
}
|
||||
if receivePaymentResponse, err := sdk.ReceivePayment(receivePaymentRequest); err == nil {
|
||||
log.Printf("%#v", receivePaymentResponse)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -215,8 +218,11 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
const bolt11 = "...";
|
||||
payment, err := sdkServices.SendPayment(bolt11, 3000)
|
||||
bolt11 := "bolt11 invoice"
|
||||
amountSats := uint64(3000)
|
||||
if payment, err := sdk.SendPayment(bolt11, &amountSats); err == nil {
|
||||
log.Printf("%#v", payment)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -320,8 +326,10 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
const nodeId = "...";
|
||||
payment, err := sdkServices.SendSpontaneousPayment(nodeId, 3000)
|
||||
nodeId := "node id"
|
||||
if payment, err := sdk.SendSpontaneousPayment(nodeId, 3000); err == nil {
|
||||
log.Printf("%#v", payment)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -96,9 +96,10 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if swapInfo, err := sdkServices.ReceiveOnchain(breez_sdk.ReceiveOnchainRequest{}); err != nil {
|
||||
if swapInfo, err := sdk.ReceiveOnchain(breez_sdk.ReceiveOnchainRequest{}); err != nil {
|
||||
// Send your funds to the below bitcoin address
|
||||
address := swapInfo.BitcoinAddress
|
||||
log.Printf("%v", address)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
@@ -196,7 +197,9 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
swapInfo, err := sdkServices.InProgressSwap()
|
||||
if swapInfo, err := sdk.InProgressSwap(); err == nil {
|
||||
log.Printf("%#v", swapInfo)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -295,7 +298,9 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
refundables, err := sdkServices.ListRefundables()
|
||||
if refundables, err := sdk.ListRefundables(); err == nil {
|
||||
log.Printf("%#v", refundables)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -414,10 +419,14 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
destinationAddress := "..."
|
||||
satPerVbyte := <refund tx fee rate>
|
||||
|
||||
result, err := sdkServices.Refund(refundable.BitcoinAddress, destinationAddress, satPerVbyte)
|
||||
if refundables, err := sdk.ListRefundables(); err == nil {
|
||||
destinationAddress := "..."
|
||||
satPerVbyte := uint32(5)
|
||||
|
||||
if result, err := sdk.Refund(refundables[0].BitcoinAddress, destinationAddress, satPerVbyte); err == nil {
|
||||
log.Printf("%v", result)
|
||||
}
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -526,8 +535,10 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
amountMsat := <amount msat>
|
||||
channelFees, err := sdkServices.OpenChannelFee(breez_sdk.OpenChannelFeeRequest{AmountMsat: amountMsat})
|
||||
amountMsat := uint64(10000)
|
||||
if channelFees, err := sdk.OpenChannelFee(breez_sdk.OpenChannelFeeRequest{AmountMsat: amountMsat}); err == nil {
|
||||
log.Printf("%#v", channelFees)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ sendAmountSat := uint64(50000)
|
||||
reverseSwapFeesRequest := breez_sdk.ReverseSwapFeesRequest{
|
||||
SendAmountSat: &sendAmountSat,
|
||||
}
|
||||
if currentFees, err := sdkService.FetchReverseSwapFees(reverseSwapFeesRequest); err != nil {
|
||||
if currentFees, err := sdk.FetchReverseSwapFees(reverseSwapFeesRequest); err == nil {
|
||||
log.Printf("Total estimated fees for reverse swap: %v", currentFees.TotalEstimatedFees)
|
||||
}
|
||||
```
|
||||
@@ -313,10 +313,13 @@ except Exception as error:
|
||||
|
||||
```go
|
||||
destinationAddress := "bc1.."
|
||||
amountSat := currentFees.Min
|
||||
satPerVbyte := <fee rate>
|
||||
|
||||
reverseSwapInfo, err := sdkServices.SendOnchain(amountSat, destinationAddress, currentFees.FeesHash, satPerVbyte)
|
||||
sendAmountSat := uint64(50000)
|
||||
satPerVbyte := uint64(5)
|
||||
if currentFees, err := sdk.FetchReverseSwapFees(breez_sdk.ReverseSwapFeesRequest{SendAmountSat: &sendAmountSat}); err == nil {
|
||||
if reverseSwapInfo, err := sdk.SendOnchain(sendAmountSat, destinationAddress, currentFees.FeesHash, satPerVbyte); err == nil {
|
||||
log.Printf("%#v", reverseSwapInfo)
|
||||
}
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -424,7 +427,7 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
if swaps, err := sdkServices.InProgressReverseSwaps(); err != nil {
|
||||
if swaps, err := sdk.InProgressReverseSwaps(); err == nil {
|
||||
for _, swap := range swaps {
|
||||
log.Printf("Reverse swap %v in progress, status is %v", swap.Id, swap.Status)
|
||||
}
|
||||
|
||||
@@ -85,11 +85,9 @@ except Exception as error:
|
||||
<section>
|
||||
|
||||
```go
|
||||
backupData, err := breez_sdk.StaticBackup(breez_sdk.StaticBackupRequest{
|
||||
WorkingDir: "<working directory>",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to retrieve static backup data: %#v", err)
|
||||
workingDir := "<working directory>"
|
||||
if staticBackupResponse, err := breez_sdk.StaticBackup(breez_sdk.StaticBackupRequest{WorkingDir: workingDir}); err == nil {
|
||||
log.Printf("%#v", staticBackupResponse)
|
||||
}
|
||||
```
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user