Reorg custom-tabs sections to remove duplication

This commit is contained in:
ok300
2023-08-12 19:22:31 +02:00
parent c2be32c1d6
commit 3827b8ca43
9 changed files with 1215 additions and 1097 deletions

View File

@@ -1,11 +1,11 @@
# Connecting to an LSP # Connecting to an LSP
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```swift ```swift
do { do {
let lspId = try sdk.lspId() let lspId = try sdk.lspId()
@@ -14,22 +14,10 @@ do {
// Handle error // Handle error
} }
``` ```
When you have selected an LSP you may then connect to it.
```swift
do {
try sdk.connectLsp(lspId: lspId!)
} catch {
// Handle error
}
```
</section> </section>
<div slot="title">Adroid</div>
<section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following: <div slot="title">Android</div>
<section>
```kotlin ```kotlin
try { try {
@@ -43,23 +31,11 @@ try {
// Handle error // Handle error
} }
``` ```
When you have selected an LSP you may then connect to it.
```kotlin
try {
sdk.connectLsp(lspId)
} catch (e: Exception) {
// Handle error
}
```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```typescript ```typescript
try { try {
const lspId = await lspId() const lspId = await lspId()
@@ -68,23 +44,11 @@ try {
console.log(error) console.log(error)
} }
``` ```
When you have selected an LSP you may then connect to it.
```typescript
try {
await connectLsp(lspId)
} catch (error) {
console.log(error)
}
```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```dart ```dart
try { try {
List<LspInformation> lspList = await listLsps(); List<LspInformation> lspList = await listLsps();
@@ -93,23 +57,11 @@ try {
// Handle error // Handle error
} }
``` ```
When you have selected an LSP you may then connect to it.
```dart
try {
String lspId = await lspId();
await connectLSP(lspId);
} catch (e) {
// Handle error
}
```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```python ```python
try: try:
lsp_id = sdk_services.lsp_id() lsp_id = sdk_services.lsp_id()
@@ -118,23 +70,11 @@ try:
except Exception as error: except Exception as error:
# Handle error # Handle error
``` ```
When you have selected an LSP you may then connect to it.
```python
try:
sdk_services.connect_lsp(lsp_id)
except Exception as error:
# Handle error
```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```go ```go
lspId, err := sdkServices.LspId() lspId, err := sdkServices.LspId()
if err != nil { if err != nil {
@@ -145,22 +85,11 @@ if err != nil {
// Handle error // Handle error
} }
``` ```
When you have selected an LSP you may then connect to it.
```go
err = sdkServices.ConnectLsp(*lspId)
if err != nil {
// Handle error
}
```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
```cs ```cs
try try
{ {
@@ -172,9 +101,86 @@ catch (Exception)
// Handle error // Handle error
} }
``` ```
</section>
</custom-tabs>
When you have selected an LSP you may then connect to it. When you have selected an LSP you may then connect to it.
<custom-tabs category="lang">
<div slot="title">Swift</div>
<section>
```swift
do {
try sdk.connectLsp(lspId: lspId!)
} catch {
// Handle error
}
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
try {
sdk.connectLsp(lspId)
} catch (e: Exception) {
// Handle error
}
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
try {
await connectLsp(lspId)
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart
try {
String lspId = await lspId();
await connectLSP(lspId);
} catch (e) {
// Handle error
}
```
</section>
<div slot="title">Python</div>
<section>
```python
try:
sdk_services.connect_lsp(lsp_id)
except Exception as error:
# Handle error
```
</section>
<div slot="title">Go</div>
<section>
```go
err = sdkServices.ConnectLsp(*lspId)
if err != nil {
// Handle error
}
```
</section>
<div slot="title">C#</div>
<section>
```cs ```cs
try try
{ {

View File

@@ -1,9 +1,10 @@
# Supporting fiat currencies # Supporting fiat currencies
In order to list the available fiat currencies:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
In order to list the available fiat currencies.
```kotlin ```kotlin
try { try {
@@ -12,8 +13,73 @@ try {
// handle error // handle error
} }
``` ```
</section>
To get the current BTC rate for the currencies. <div slot="title">React Native</div>
<section>
```typescript
try {
const fiatCurrencyList = await listFiatCurrencies()
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart
try {
List<FiatCurrency> fiatCurrencyList = await listFiatCurrencies();
} catch(e) {
// Handle error
}
```
</section>
<div slot="title">Python</div>
<section>
```python
try:
fiat_currencies = sdk_services.list_fiat_currencies()
except Exception as error:
#Handle error
```
</section>
<div slot="title">Go</div>
<section>
```go
fiatCurrencies, err := sdkServices.ListFiatCurrencies()
```
</section>
<div slot="title">C#</div>
<section>
```cs
try
{
var fiatCurrencies = sdk.ListFiatCurrencies();
}
catch (Exception)
{
// Handle error
}
```
</section>
</custom-tabs>
To get the current BTC rate for the currencies:
<custom-tabs category="lang">
<div slot="title">Android</div>
<section>
```kotlin ```kotlin
try { try {
@@ -22,8 +88,75 @@ try {
// handle error // handle error
} }
``` ```
</section>
At the example project you can see these methods combined <div slot="title">React Native</div>
<section>
```typescript
try {
const fiatRatesMap = fetchFiatRates()
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart
try {
Map<String, Rate> fiatRatesMap = fetchFiatRates();
// print your desired rate
print(fiatRatesMap["USD"]?.value);
} catch(e) {
// Handle error
}
```
</section>
<div slot="title">Python</div>
<section>
```python
try:
fiat_rates = sdk_services.fetch_fiat_rates()
# print your desired rate
except Exception as error:
# Handle error
```
</section>
<div slot="title">Go</div>
<section>
```go
fiatRates, err := sdkServices.FetchFiatRates()
```
</section>
<div slot="title">C#</div>
<section>
```cs
try
{
var fiatRates = sdk.FetchFiatRates();
}
catch (Exception)
{
// Handle error
}
```
</section>
</custom-tabs>
At the example project you can see these methods combined:
<custom-tabs category="lang">
<div slot="title">Android</div>
<section>
```kotlin ```kotlin
fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try { fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
@@ -51,114 +184,4 @@ fun fiatCurrenciesAndRate(): Map<FiatCurrency, Rate> = try {
} }
``` ```
</section> </section>
<div slot="title">React Native</div>
<section>
In order to list the available fiat currencies.
```typescript
try {
const fiatCurrencyList = await listFiatCurrencies()
} catch (error) {
console.log(error)
}
```
To get the current BTC rate for the currencies.
```typescript
try {
const fiatRatesMap = fetchFiatRates()
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
In order to list the available fiat currencies.
```dart
try {
List<FiatCurrency> fiatCurrencyList = await listFiatCurrencies();
} catch(e) {
// Handle error
}
```
To get the current BTC rate for the currencies.
```dart
try {
Map<String, Rate> fiatRatesMap = fetchFiatRates();
// print your desired rate
print(fiatRatesMap["USD"]?.value);
} catch(e) {
// Handle error
}
```
</section>
<div slot="title">Python</div>
<section>
In order to list the available fiat currencies.
```python
try:
fiat_currencies = sdk_services.list_fiat_currencies()
except Exception as error:
#Handle error
```
To get the current BTC rate for the currencies.
```python
try:
fiat_rates = sdk_services.fetch_fiat_rates()
# print your desired rate
except Exception as error:
# Handle error
```
</section>
<div slot="title">Go</div>
<section>
In order to list the available fiat currencies.
```go
fiatCurrencies, err := sdkServices.ListFiatCurrencies()
```
To get the current BTC rate for the currencies.
```go
fiatRates, err := sdkServices.FetchFiatRates()
```
</section>
<div slot="title">C#</div>
<section>
In order to list the available fiat currencies.
```cs
try
{
var fiatCurrencies = sdk.ListFiatCurrencies();
}
catch (Exception)
{
// Handle error
}
```
To get the current BTC rate for the currencies.
```cs
try
{
var fiatRates = sdk.FetchFiatRates();
}
catch (Exception)
{
// Handle error
}
```
</section>
</custom-tabs> </custom-tabs>

View File

@@ -92,7 +92,6 @@ do {
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
## Connecting
```kotlin ```kotlin
// SDK events listener // SDK events listener
class SDKListener : EventListener { class SDKListener : EventListener {

View File

@@ -25,6 +25,7 @@ if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await {
} }
``` ```
</section> </section>
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
@@ -48,8 +49,8 @@ do {
// handle error // handle error
} }
``` ```
</section> </section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
@@ -70,8 +71,8 @@ try {
// handle error // handle error
} }
``` ```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
@@ -94,8 +95,8 @@ try {
console.log(error) console.log(error)
} }
``` ```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
@@ -118,8 +119,8 @@ try {
// handle error // handle error
} }
``` ```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
@@ -139,8 +140,8 @@ try:
except Exception as error: except Exception as error:
# Handle error # Handle error
``` ```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
@@ -162,6 +163,7 @@ if input, err := breez_sdk.ParseInput(lnurlAuthUrl); err != nil {
} }
``` ```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>
@@ -187,7 +189,6 @@ catch (Exception)
// Handle error // Handle error
} }
``` ```
</section> </section>
</custom-tabs> </custom-tabs>

View File

@@ -20,8 +20,8 @@ if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await {
sdk.lnurl_pay(amount_msat, Some(comment), pd).await?; sdk.lnurl_pay(amount_msat, Some(comment), pd).await?;
} }
``` ```
</section> </section>
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
@@ -41,13 +41,14 @@ do {
} }
``` ```
</section> </section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
```kotlin ```kotlin
// Endpoint can also be of the form: // Endpoint can also be of the form:
// lnurlp://domain.com/lnurl-pay?key=val // lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7 // lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
val lnurlPayUrl = "lightning@address.com"; val lnurlPayUrl = "lightning@address.com";
try { try {
val inputType = parseInput(lnurlPayUrl) val inputType = parseInput(lnurlPayUrl)
@@ -62,6 +63,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
@@ -82,6 +84,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
@@ -106,6 +109,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
@@ -124,6 +128,7 @@ except Exception as error:
# Handle error # Handle error
``` ```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
@@ -143,6 +148,7 @@ if input, err := breez_sdk.ParseInput(lnurlPayUrl); err != nil {
} }
``` ```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>

View File

@@ -13,7 +13,6 @@
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"; let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await { if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
// TODO Determine withdraw amount
let amount_msat = wd.min_withdrawable; let amount_msat = wd.min_withdrawable;
let description = "Test withdraw".to_string(); let description = "Test withdraw".to_string();
@@ -21,6 +20,7 @@ if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
} }
``` ```
</section> </section>
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
@@ -39,9 +39,9 @@ do {
} catch { } catch {
// handle error // handle error
} }
``` ```
</section> </section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
@@ -63,6 +63,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
@@ -82,6 +83,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
@@ -105,6 +107,7 @@ try {
} }
``` ```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
@@ -122,6 +125,7 @@ except Exception as error:
# Handle error # Handle error
``` ```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
@@ -140,6 +144,7 @@ if input, err := breez_sdk.ParseInput(lnurlWithdrawUrl); err != nil {
} }
``` ```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>

View File

@@ -1,37 +1,22 @@
# Sending and receiving Lightning payments # Sending and receiving Lightning payments
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Rust</div> <div slot="title">Rust</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```rust,ignore ```rust,ignore
let invoice = sdk.receive_payment(3000, "Invoice for 3000 sats".into()).await?; let invoice = sdk.receive_payment(3000, "Invoice for 3000 sats".into()).await?;
``` ```
## Sending Lightning Payments
```rust,ignore
let bolt11 = "...";
sdk.send_payment(bolt11.into(), Some(3000)).await?;
```
## Sending Spontaneous Lightning Payments
```rust,ignore
let node_id = "...";
sdk.send_payment(node_id.into(), Some(3000)).await?;
```
</section> </section>
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```swift ```swift
do { do {
let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats") let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats")
@@ -39,34 +24,11 @@ do {
// handle error // handle error
} }
``` ```
## Sending Lightning Payments
```swift
let bolt11 = "...";
do {
let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000)
} catch {
// handle error
}
```
## Sending Spontaneous Lightning Payments
```swift
let nodeId = "...";
do {
let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000)
} catch {
// handle error
}
```
</section> </section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```kotlin ```kotlin
try { try {
val invoice = sdk.receivePayment(3000L.toULong(), "Invoice for 3000 sats") val invoice = sdk.receivePayment(3000L.toULong(), "Invoice for 3000 sats")
@@ -74,34 +36,11 @@ try {
// handle error // handle error
} }
``` ```
## Sending Lightning Payments
```kotlin
val bolt11 = "..."
try {
val payment = sdk.sendPayment(bolt11, 3000L.toULong())
} catch (e: Exception) {
// handle error
}
```
## Sending Spontaneous Lightning Payments
```kotlin
val nodeId = "..."
try {
val payment = sdk.sendSpontaneousPayment(nodeId, 3000L.toULong())
} catch (e: Exception) {
// handle error
}
```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```typescript ```typescript
try { try {
const invoice = await receivePayment(3000, "Invoice for 3000 sats") const invoice = await receivePayment(3000, "Invoice for 3000 sats")
@@ -109,34 +48,11 @@ try {
console.log(error) console.log(error)
} }
``` ```
## Sending Lightning Payments
```typescript
const bolt11 = "...";
try {
const payment = await sendPayment(bolt11, 3000)
} catch (error) {
console.log(error)
}
```
## Sending Spontaneous Lightning Payments
```typescript
const nodeId = "...";
try {
const payment = await sendSpontaneousPayment(nodeId, 3000)
} catch (error) {
console.log(error)
}
```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```dart ```dart
try { try {
ReceivePaymentRequestData requestData = ReceivePaymentRequestData(amountSats: 3000, description: "Invoice for 3000 sats"); ReceivePaymentRequestData requestData = ReceivePaymentRequestData(amountSats: 3000, description: "Invoice for 3000 sats");
@@ -145,8 +61,97 @@ try {
// handle error // handle error
} }
``` ```
</section>
<div slot="title">Python</div>
<section>
```python
try:
invoice = sdk_services.receive_payment(3000, "Invoice for 3000 sats")
except Exception as error:
# Handle error
```
</section>
<div slot="title">Go</div>
<section>
```go
invoice, err := sdkServices.ReceivePayment(3000, "Invoice for 3000 sats")
```
</section>
<div slot="title">C#</div>
<section>
```cs
try
{
var invoice = sdk.ReceivePayment(3000, "Invoice for 3000 sats");
}
catch (Exception)
{
// Handle error
}
```
</section>
</custom-tabs>
## Sending Lightning Payments ## Sending Lightning Payments
<custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
let bolt11 = "...";
sdk.send_payment(bolt11.into(), Some(3000)).await?;
```
</section>
<div slot="title">Swift</div>
<section>
```swift
let bolt11 = "...";
do {
let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000)
} catch {
// handle error
}
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
val bolt11 = "..."
try {
val payment = sdk.sendPayment(bolt11, 3000L.toULong())
} catch (e: Exception) {
// handle error
}
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
const bolt11 = "...";
try {
const payment = await sendPayment(bolt11, 3000)
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart ```dart
String bolt11 = "..."; String bolt11 = "...";
try { try {
@@ -158,8 +163,100 @@ try {
// handle error // handle error
} }
``` ```
</section>
<div slot="title">Python</div>
<section>
```python
bolt11 = "..."
try:
sdk_services.send_payment(bolt11, 3000)
except Exception as error:
# Handle error
```
</section>
<div slot="title">Go</div>
<section>
```go
const bolt11 = "...";
payment, err := sdkServices.SendPayment(bolt11, 3000)
```
</section>
<div slot="title">C#</div>
<section>
```cs
const bolt11 = "...";
try
{
var payment = sdk.SendPayment(bolt11, 3000);
}
catch (Exception)
{
// Handle error
}
```
</section>
</custom-tabs>
## Sending Spontaneous Lightning Payments ## Sending Spontaneous Lightning Payments
<custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
let node_id = "...";
sdk.send_spontaneous_payment(node_id.into(), 3000).await?;
```
</section>
<div slot="title">Swift</div>
<section>
```swift
let nodeId = "...";
do {
let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000)
} catch {
// handle error
}
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
val nodeId = "..."
try {
val payment = sdk.sendSpontaneousPayment(nodeId, 3000L.toULong())
} catch (e: Exception) {
// handle error
}
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
const nodeId = "...";
try {
const payment = await sendSpontaneousPayment(nodeId, 3000)
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart ```dart
String nodeId = "..."; String nodeId = "...";
try { try {
@@ -172,30 +269,10 @@ try {
} }
``` ```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```python
try:
invoice = sdk_services.receive_payment(3000, "Invoice for 3000 sats")
except Exception as error:
# Handle error
```
## Sending Lightning Payments
```python
bolt11 = "..."
try:
sdk_services.send_payment(bolt11, 3000)
except Exception as error:
# Handle error
```
## Sending Spontaneous Lightning Payments
```python ```python
let node_id = "..." let node_id = "..."
try: try:
@@ -203,64 +280,20 @@ try:
except Exception as error: except Exception as error:
# Handle error # Handle error
``` ```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```go
invoice, err := sdkServices.ReceivePayment(3000, "Invoice for 3000 sats")
```
## Sending Lightning Payments
```go
const bolt11 = "...";
payment, err := sdkServices.SendPayment(bolt11, 3000)
```
## Sending Spontaneous Lightning Payments
```go ```go
const nodeId = "..."; const nodeId = "...";
payment, err := sdkServices.SendSpontaneousPayment(nodeId, 3000) payment, err := sdkServices.SendSpontaneousPayment(nodeId, 3000)
``` ```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>
## Receiving Lightning Payments
Breez SDK doesn't require you to open a channel and set up your inbound liquidity.
Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```cs
try
{
var invoice = sdk.ReceivePayment(3000, "Invoice for 3000 sats");
}
catch (Exception)
{
// Handle error
}
```
## Sending Lightning Payments
```cs
const bolt11 = "...";
try
{
var payment = sdk.SendPayment(bolt11, 3000);
}
catch (Exception)
{
// Handle error
}
```
## Sending Spontaneous Lightning Payments
```cs ```cs
const nodeId = "..."; const nodeId = "...";
try try

File diff suppressed because it is too large Load Diff

View File

@@ -15,39 +15,8 @@ info!("Percentage fee for the reverse swap service: {}", current_fees.fees_perce
info!("Estimated miner fees in sats for locking up funds: {}", current_fees.fees_lockup); info!("Estimated miner fees in sats for locking up funds: {}", current_fees.fees_lockup);
info!("Estimated miner fees in sats for claiming funds: {}", current_fees.fees_claim); info!("Estimated miner fees in sats for claiming funds: {}", current_fees.fees_claim);
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```rust,ignore
info!("Minimum amount, in sats: {}", current_fees.min);
info!("Maximum amount, in sats: {}", current_fees.max);
```
Once you checked the fees are acceptable, you can start the reverse swap:
```rust,ignore
let destination_address = String::from("bc1..");
let amount_sat = current_fees.min;
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash).await?;
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```rust,ignore
for rs in sdk.in_progress_reverse_swaps().await? {
info!("Reverse swap {} in progress, status is {}", rs.id, rs.status);
}
```
</section> </section>
<div slot="title">Swift</div> <div slot="title">Swift</div>
<section> <section>
@@ -62,43 +31,8 @@ try {
// handle error // handle error
} }
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```swift
println("Minimum amount, in sats: \(current_fees.min)")
println("Maximum amount, in sats: \(current_fees.max)")
```
Once you checked the fees are acceptable, you can start the reverse swap:
```swift
let destinationAddress = "bc1.."
let amountSat = currentFees.min
let satPerVbyte = <fee rate>
try {
try sdk.sendOnchain(amountSat: amountSat, onchainRecipientAddress: destinationAddress, pairHash: currentFees.feesHash, satPerVbyte: satPerVbyte)
} catch {
// handle error
}
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```swift
for rs in sdk.inProgressReverseSwaps() {
println("Reverse swap \(rs.id) in progress, status is \(rs.status)")
}
```
</section> </section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
@@ -112,43 +46,8 @@ try {
// handle error // handle error
} }
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```kotlin
Log.v("Breez", "Minimum amount, in sats: ${fees.min}")
Log.v("Breez", "Maximum amount, in sats: ${fees.max}")
```
Once you checked the fees are acceptable, you can start the reverse swap:
```kotlin
val address = "bc1.."
val amountSat = 123L.toULong()
val satPerVbyte = 1L.toULong()
try {
sdk.sendOnchain(amountSat, address, fees.feesHash, satPerVbyte)
} catch (e: Exception) {
// handle error
}
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```kotlin
for (rs in sdk.inProgressReverseSwaps()) {
Log.v("Breez", "Reverse swap ${rs.id} in progress, status is ${rs.status}")
}
```
</section> </section>
<div slot="title">React Native</div> <div slot="title">React Native</div>
<section> <section>
@@ -163,48 +62,8 @@ try {
console.log(error) console.log(error)
} }
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```typescript
console.log(`Minimum amount, in sats: ${currentFees.min}`);
console.log(`Maximum amount, in sats: ${currentFees.max}`);
```
Once you checked the fees are acceptable, you can start the reverse swap:
```typescript
const destinationAddress = "bc1..";
const amountSat = currentFees.min;
const satPerVbyte = <fee rate>
try {
const reverseSwapInfo = sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte)
} catch (error) {
console.log(error)
}
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```typescript
try {
const swaps = await inProgressReverseSwaps()
for (const swap in swaps) {
println(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
}
} catch (error) {
console.log(error)
}
```
</section> </section>
<div slot="title">Dart</div> <div slot="title">Dart</div>
<section> <section>
@@ -219,50 +78,8 @@ try {
// handle error // handle error
} }
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```dart
print(`Minimum amount, in sats: ${currentFees.min}`);
print(`Maximum amount, in sats: ${currentFees.max}`);
```
Once you checked the fees are acceptable, you can start the reverse swap:
```dart
String destinationAddress = "bc1..";
int amountSat = currentFees.min;
int satPerVbyte = <fee rate>
try {
ReverseSwapInfo reverseSwapInfo = await sendOnchain(
amountSat: amountSat,
onchainRecipientAddress: destinationAddress,
pairHash: currentFees.feesHash,
satPerVbyte: satPerVbyte,
);
} catch (error) {
// handle error
}
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```dart
try {
List<ReverseSwapInfo> swaps = await inProgressReverseSwaps();
for (swap in swaps) {
print(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
}
} catch (error) {
// handle error
}
```
</section> </section>
<div slot="title">Python</div> <div slot="title">Python</div>
<section> <section>
@@ -275,45 +92,8 @@ try:
except Exception as error: except Exception as error:
# Handle error # Handle error
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```python
print("Minimum amount, in sats: ", current_fees.min)
print("Maximum amount, in sats: ", current_fees.max)
```
Once you checked the fees are acceptable, you can start the reverse swap:
```python
destination_address = "bc1.."
amount_sat = current_fees.min
try:
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash)
except Exception as error:
# Handle erorr
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```python
try:
reverse_swaps = sdk_services.in_progress_reverse_swaps()
for rs in reverse_swaps:
print("Reverse swap ",rs.id , " in progress, status is ", rs.status)
except Exception as error:
# Handle erorr
```
</section> </section>
<div slot="title">Go</div> <div slot="title">Go</div>
<section> <section>
@@ -324,42 +104,8 @@ if currentFees, err := sdkServices.FetchReverseSwapFees(); err != nil {
log.Printf("Estimated miner fees in sats for claiming funds: %v", currentFees.FeesClaim) log.Printf("Estimated miner fees in sats for claiming funds: %v", currentFees.FeesClaim)
} }
``` ```
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture
of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
```go
log.Printf("Minimum amount, in sats: %v", currentFees.Min)
log.Printf("Maximum amount, in sats: %v", currentFees.Max)
```
Once you checked the fees are acceptable, you can start the reverse swap:
```go
destinationAddress := "bc1.."
amountSat := currentFees.Min
satPerVbyte := <fee rate>
reverseSwapInfo, err := sdkServices.SendOnchain(amountSat, destinationAddress, currentFees.FeesHash, satPerVbyte)
```
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
is either settled or cancelled. This will happen automatically at the end of the reverse swap.
You can check its status with:
```go
if swaps, err := sdkServices.InProgressReverseSwaps(); err != nil {
for _, swap := range swaps {
log.Printf("Reverse swap %v in progress, status is %v", swap.Id, swap.Status)
}
}
```
</section> </section>
<div slot="title">C#</div> <div slot="title">C#</div>
<section> <section>
@@ -376,6 +122,8 @@ catch (Exception)
// Handle error // Handle error
} }
``` ```
</section>
</custom-tabs>
The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen
automatically once the process is started, but the last two values above are these estimates to help you get a picture automatically once the process is started, but the last two values above are these estimates to help you get a picture
@@ -383,13 +131,188 @@ of the total costs.
Fetching the fees also tells you what is the range of amounts you can send: Fetching the fees also tells you what is the range of amounts you can send:
<custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
info!("Minimum amount, in sats: {}", current_fees.min);
info!("Maximum amount, in sats: {}", current_fees.max);
```
</section>
<div slot="title">Swift</div>
<section>
```swift
println("Minimum amount, in sats: \(current_fees.min)")
println("Maximum amount, in sats: \(current_fees.max)")
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
Log.v("Breez", "Minimum amount, in sats: ${fees.min}")
Log.v("Breez", "Maximum amount, in sats: ${fees.max}")
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
console.log(`Minimum amount, in sats: ${currentFees.min}`);
console.log(`Maximum amount, in sats: ${currentFees.max}`);
```
</section>
<div slot="title">Dart</div>
<section>
```dart
print(`Minimum amount, in sats: ${currentFees.min}`);
print(`Maximum amount, in sats: ${currentFees.max}`);
```
</section>
<div slot="title">Python</div>
<section>
```python
print("Minimum amount, in sats: ", current_fees.min)
print("Maximum amount, in sats: ", current_fees.max)
```
</section>
<div slot="title">Go</div>
<section>
```go
log.Printf("Minimum amount, in sats: %v", currentFees.Min)
log.Printf("Maximum amount, in sats: %v", currentFees.Max)
```
</section>
<div slot="title">C#</div>
<section>
```cs ```cs
Console.WriteLine($"Minimum amount, in sats: {currentFees.min}"); Console.WriteLine($"Minimum amount, in sats: {currentFees.min}");
Console.WriteLine($"Maximum amount, in sats: {currentFees.max}"); Console.WriteLine($"Maximum amount, in sats: {currentFees.max}");
``` ```
</section>
</custom-tabs>
Once you checked the fees are acceptable, you can start the reverse swap: Once you checked the fees are acceptable, you can start the reverse swap:
<custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
let destination_address = String::from("bc1..");
let amount_sat = current_fees.min;
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash).await?;
```
</section>
<div slot="title">Swift</div>
<section>
```swift
let destinationAddress = "bc1.."
let amountSat = currentFees.min
let satPerVbyte = <fee rate>
try {
try sdk.sendOnchain(amountSat: amountSat, onchainRecipientAddress: destinationAddress, pairHash: currentFees.feesHash, satPerVbyte: satPerVbyte)
} catch {
// handle error
}
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
val address = "bc1.."
val amountSat = 123L.toULong()
val satPerVbyte = 1L.toULong()
try {
sdk.sendOnchain(amountSat, address, fees.feesHash, satPerVbyte)
} catch (e: Exception) {
// handle error
}
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
const destinationAddress = "bc1..";
const amountSat = currentFees.min;
const satPerVbyte = <fee rate>
try {
const reverseSwapInfo = sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte)
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart
String destinationAddress = "bc1..";
int amountSat = currentFees.min;
int satPerVbyte = <fee rate>
try {
ReverseSwapInfo reverseSwapInfo = await sendOnchain(
amountSat: amountSat,
onchainRecipientAddress: destinationAddress,
pairHash: currentFees.feesHash,
satPerVbyte: satPerVbyte,
);
} catch (error) {
// handle error
}
```
</section>
<div slot="title">Python</div>
<section>
```python
destination_address = "bc1.."
amount_sat = current_fees.min
try:
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash)
except Exception as error:
# Handle erorr
```
</section>
<div slot="title">Go</div>
<section>
```go
destinationAddress := "bc1.."
amountSat := currentFees.Min
satPerVbyte := <fee rate>
reverseSwapInfo, err := sdkServices.SendOnchain(amountSat, destinationAddress, currentFees.FeesHash, satPerVbyte)
```
</section>
<div slot="title">C#</div>
<section>
```cs ```cs
var destinationAddress = "bc1.."; var destinationAddress = "bc1..";
var amountSat = currentFees.min; var amountSat = currentFees.min;
@@ -403,6 +326,8 @@ catch (Exception)
// Handle error // Handle error
} }
``` ```
</section>
</custom-tabs>
Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes. Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes.
This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice
@@ -410,6 +335,95 @@ is either settled or cancelled. This will happen automatically at the end of the
You can check its status with: You can check its status with:
<custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
for rs in sdk.in_progress_reverse_swaps().await? {
info!("Reverse swap {} in progress, status is {}", rs.id, rs.status);
}
```
</section>
<div slot="title">Swift</div>
<section>
```swift
for rs in sdk.inProgressReverseSwaps() {
println("Reverse swap \(rs.id) in progress, status is \(rs.status)")
}
```
</section>
<div slot="title">Android</div>
<section>
```kotlin
for (rs in sdk.inProgressReverseSwaps()) {
Log.v("Breez", "Reverse swap ${rs.id} in progress, status is ${rs.status}")
}
```
</section>
<div slot="title">React Native</div>
<section>
```typescript
try {
const swaps = await inProgressReverseSwaps()
for (const swap in swaps) {
println(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
}
} catch (error) {
console.log(error)
}
```
</section>
<div slot="title">Dart</div>
<section>
```dart
try {
List<ReverseSwapInfo> swaps = await inProgressReverseSwaps();
for (swap in swaps) {
print(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
}
} catch (error) {
// handle error
}
```
</section>
<div slot="title">Python</div>
<section>
```python
try:
reverse_swaps = sdk_services.in_progress_reverse_swaps()
for rs in reverse_swaps:
print("Reverse swap ",rs.id , " in progress, status is ", rs.status)
except Exception as error:
# Handle erorr
```
</section>
<div slot="title">Go</div>
<section>
```go
if swaps, err := sdkServices.InProgressReverseSwaps(); err != nil {
for _, swap := range swaps {
log.Printf("Reverse swap %v in progress, status is %v", swap.Id, swap.Status)
}
}
```
</section>
<div slot="title">C#</div>
<section>
```cs ```cs
try try
{ {
@@ -425,6 +439,7 @@ catch (Exception)
``` ```
</section> </section>
</custom-tabs> </custom-tabs>
If the reverse swap is successful, you'll get the on-chain payment on your destination address and the HODL invoice will If the reverse swap is successful, you'll get the on-chain payment on your destination address and the HODL invoice will
change from pending to settled. change from pending to settled.