Merge branch 'main' into ok300-snippets-rust

This commit is contained in:
Erdem Yerebasmaz
2023-11-03 02:41:25 +03:00
3 changed files with 31 additions and 13 deletions

View File

@@ -11,6 +11,10 @@ The Breez SDK provides the following services:
Connecting to a node requires a seed (your master key). The seed is a bip39 mnemonic. Connecting to a node requires a seed (your master key). The seed is a bip39 mnemonic.
## Pricing
The Breez SDK is free for developers.
## API Key and Invite Code ## API Key and Invite Code
Before you start, you will need an API Key to use the SDK, as well as an Invite Code when you create a new node. Before you start, you will need an API Key to use the SDK, as well as an Invite Code when you create a new node.

View File

@@ -2,7 +2,7 @@
There are cases when you have funds in some bitcoin address and you would like to send those to your lightning node. There are cases when you have funds in some bitcoin address and you would like to send those to your lightning node.
In such cases, the SDK might have to open a new channel, for which case you can specify an optional user-selected In such cases, the SDK might have to open a new channel, for which case you can specify an optional user-selected
channel opening fee[^1]. For simplicity, the examples below use the cheapest fee available. channel opening fee[^1].
In order to receive funds you first have to be connected to an [LSP](connecting_lsp.md). In order to receive funds you first have to be connected to an [LSP](connecting_lsp.md).
<custom-tabs category="lang"> <custom-tabs category="lang">

View File

@@ -15,11 +15,11 @@ Once you have outbound liquidity you can start sending payments too.
<section> <section>
```swift ```swift
let bolt11 = "...";
do { do {
// The `amountSats` param is optional so nil can be passed if the // The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
// bolt11 invoice spesifies an amount. // The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000) let req = SendPaymentRequest(bolt11: "...", amountMsat: 3000000)
let response = try sdk.sendPayment(req: req)
} catch { } catch {
// handle error // handle error
} }
@@ -32,7 +32,11 @@ do {
```kotlin,ignore ```kotlin,ignore
val bolt11 = "..." val bolt11 = "..."
try { try {
val payment = sdk.sendPayment(bolt11, 3000L.toULong()) // The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
// The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
val amountMsat = 3000000L.toULong()
val req = SendPaymentRequest(bolt11, amountMsat)
val response = sdk.sendPayment(req)
} catch (e: Exception) { } catch (e: Exception) {
// handle error // handle error
} }
@@ -61,9 +65,10 @@ try {
```python ```python
bolt11 = "..." bolt11 = "..."
try: try:
# The `amountSats` param is optional so None can be passed if the # The `amount_msat` param is optional and should only passed if the bolt11 doesn't specify an amount.
# bolt11 invoice spesifies an amount. # The amount_msat is required in case an amount is not specified in the bolt11 invoice'.
sdk_services.send_payment(bolt11=bolt11, amount_sats=None) req = breez_sdk.SendPaymentRequest(bolt11=bolt11, amount_msat=3000000)
sdk_services.send_payment(req=req)
except Exception as error: except Exception as error:
# Handle error # Handle error
``` ```
@@ -74,9 +79,15 @@ except Exception as error:
```go ```go
bolt11 := "bolt11 invoice" bolt11 := "bolt11 invoice"
amountSats := uint64(3000) // The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
if payment, err := sdk.SendPayment(bolt11, &amountSats); err == nil { // The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
log.Printf("%#v", payment) amountMsat := uint64(3000000)
sendPaymentRequest := breez_sdk.SendPaymentRequest{
Bolt11: bolt11,
AmountMsat: amountMsat,
}
if response, err := sdk.SendPayment(sendPaymentRequest); err == nil {
log.Printf("%#v", response)
} }
``` ```
</section> </section>
@@ -86,9 +97,12 @@ if payment, err := sdk.SendPayment(bolt11, &amountSats); err == nil {
```cs ```cs
var bolt11 = "..."; var bolt11 = "...";
var amountMsat = 3000000;
try try
{ {
var payment = sdk.SendPayment(bolt11, 3000); // The `amountMsat` param is optional and should only passed if the bolt11 doesn't specify an amount.
// The amountMsat is required in case an amount is not specified in the bolt11 invoice'.
var response = sdk.SendPayment(new SendPaymentRequest(bolt11, amountMsat));
} }
catch (Exception) catch (Exception)
{ {