From 3827b8ca433f059246fa1e7d1372cb15561e24ea Mon Sep 17 00:00:00 2001
From: ok300 <106775972+ok300@users.noreply.github.com>
Date: Sat, 12 Aug 2023 19:22:31 +0200
Subject: [PATCH] Reorg custom-tabs sections to remove duplication
---
src/guide/connecting_lsp.md | 166 +++---
src/guide/fiat_currencies.md | 249 +++++----
src/guide/getting_started.md | 1 -
src/guide/lnurl_auth.md | 13 +-
src/guide/lnurl_pay.md | 10 +-
src/guide/lnurl_withdraw.md | 9 +-
src/guide/payments.md | 353 +++++++------
src/guide/receive_onchain.md | 974 ++++++++++++++++++-----------------
src/guide/send_onchain.md | 537 +++++++++----------
9 files changed, 1215 insertions(+), 1097 deletions(-)
diff --git a/src/guide/connecting_lsp.md b/src/guide/connecting_lsp.md
index b16af80..e444e2c 100644
--- a/src/guide/connecting_lsp.md
+++ b/src/guide/connecting_lsp.md
@@ -1,11 +1,11 @@
# 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:
+
Swift
-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
do {
let lspId = try sdk.lspId()
@@ -14,22 +14,10 @@ do {
// Handle error
}
```
-
-When you have selected an LSP you may then connect to it.
-
-```swift
-do {
- try sdk.connectLsp(lspId: lspId!)
-} catch {
- // Handle error
-}
-```
-
-Adroid
-
-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:
+Android
+
```kotlin
try {
@@ -43,23 +31,11 @@ try {
// Handle error
}
```
-
-When you have selected an LSP you may then connect to it.
-
-```kotlin
-try {
- sdk.connectLsp(lspId)
-} catch (e: Exception) {
- // Handle error
-}
-```
-
+
React Native
-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
try {
const lspId = await lspId()
@@ -68,23 +44,11 @@ try {
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)
-}
-```
-
+
Dart
-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
try {
List lspList = await listLsps();
@@ -93,23 +57,11 @@ try {
// 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
-}
-```
+
Python
-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
try:
lsp_id = sdk_services.lsp_id()
@@ -118,23 +70,11 @@ try:
except Exception as 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
-```
-
+
Go
-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
lspId, err := sdkServices.LspId()
if err != nil {
@@ -145,22 +85,11 @@ if err != nil {
// Handle error
}
```
-
- When you have selected an LSP you may then connect to it.
-
- ```go
-err = sdkServices.ConnectLsp(*lspId)
-if err != nil {
- // Handle error
-}
- ```
-
+
C#
-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
try
{
@@ -172,9 +101,86 @@ catch (Exception)
// Handle error
}
```
+
+
When you have selected an LSP you may then connect to it.
+
+Swift
+
+
+```swift
+do {
+ try sdk.connectLsp(lspId: lspId!)
+} catch {
+ // Handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+try {
+ sdk.connectLsp(lspId)
+} catch (e: Exception) {
+ // Handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+try {
+ await connectLsp(lspId)
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ String lspId = await lspId();
+ await connectLSP(lspId);
+} catch (e) {
+ // Handle error
+}
+```
+
+
+Python
+
+
+```python
+try:
+ sdk_services.connect_lsp(lsp_id)
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+ ```go
+err = sdkServices.ConnectLsp(*lspId)
+if err != nil {
+ // Handle error
+}
+ ```
+
+
+C#
+
+
```cs
try
{
diff --git a/src/guide/fiat_currencies.md b/src/guide/fiat_currencies.md
index 0648af0..9f4e1f8 100644
--- a/src/guide/fiat_currencies.md
+++ b/src/guide/fiat_currencies.md
@@ -1,9 +1,10 @@
# Supporting fiat currencies
+In order to list the available fiat currencies:
+
Android
-In order to list the available fiat currencies.
```kotlin
try {
@@ -12,8 +13,73 @@ try {
// handle error
}
```
+
-To get the current BTC rate for the currencies.
+React Native
+
+
+```typescript
+try {
+ const fiatCurrencyList = await listFiatCurrencies()
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ List fiatCurrencyList = await listFiatCurrencies();
+} catch(e) {
+ // Handle error
+}
+```
+
+
+Python
+
+
+```python
+try:
+ fiat_currencies = sdk_services.list_fiat_currencies()
+
+except Exception as error:
+ #Handle error
+```
+
+
+Go
+
+
+```go
+fiatCurrencies, err := sdkServices.ListFiatCurrencies()
+```
+
+
+C#
+
+
+```cs
+try
+{
+ var fiatCurrencies = sdk.ListFiatCurrencies();
+}
+catch (Exception)
+{
+ // Handle error
+}
+```
+
+
+
+To get the current BTC rate for the currencies:
+
+
+Android
+
```kotlin
try {
@@ -22,8 +88,75 @@ try {
// handle error
}
```
+
-At the example project you can see these methods combined
+React Native
+
+
+```typescript
+try {
+ const fiatRatesMap = fetchFiatRates()
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ Map fiatRatesMap = fetchFiatRates();
+ // print your desired rate
+ print(fiatRatesMap["USD"]?.value);
+} catch(e) {
+ // Handle error
+}
+```
+
+
+Python
+
+
+```python
+try:
+ fiat_rates = sdk_services.fetch_fiat_rates()
+ # print your desired rate
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+fiatRates, err := sdkServices.FetchFiatRates()
+```
+
+
+C#
+
+
+```cs
+try
+{
+ var fiatRates = sdk.FetchFiatRates();
+}
+catch (Exception)
+{
+ // Handle error
+}
+```
+
+
+
+At the example project you can see these methods combined:
+
+
+Android
+
```kotlin
fun fiatCurrenciesAndRate(): Map = try {
@@ -51,114 +184,4 @@ fun fiatCurrenciesAndRate(): Map = try {
}
```
-React Native
-
-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)
-}
-```
-
-Dart
-
-In order to list the available fiat currencies.
-
-```dart
-try {
- List fiatCurrencyList = await listFiatCurrencies();
-} catch(e) {
- // Handle error
-}
-```
-
-To get the current BTC rate for the currencies.
-
-```dart
-try {
- Map fiatRatesMap = fetchFiatRates();
- // print your desired rate
- print(fiatRatesMap["USD"]?.value);
-} catch(e) {
- // Handle error
-}
-```
-
-Python
-
-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
-```
-
-Go
-
-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()
-```
-
-C#
-
-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
-}
-```
-
\ No newline at end of file
diff --git a/src/guide/getting_started.md b/src/guide/getting_started.md
index 266a1c3..db00052 100644
--- a/src/guide/getting_started.md
+++ b/src/guide/getting_started.md
@@ -92,7 +92,6 @@ do {
Android
-## Connecting
```kotlin
// SDK events listener
class SDKListener : EventListener {
diff --git a/src/guide/lnurl_auth.md b/src/guide/lnurl_auth.md
index f65b447..c950014 100644
--- a/src/guide/lnurl_auth.md
+++ b/src/guide/lnurl_auth.md
@@ -25,6 +25,7 @@ if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await {
}
```
+
Swift
@@ -48,8 +49,8 @@ do {
// handle error
}
```
-
+
Android
@@ -70,8 +71,8 @@ try {
// handle error
}
```
-
+
React Native
@@ -94,8 +95,8 @@ try {
console.log(error)
}
```
-
+
Dart
@@ -118,8 +119,8 @@ try {
// handle error
}
```
-
+
Python
@@ -139,8 +140,8 @@ try:
except Exception as error:
# Handle error
```
-
+
Go
@@ -162,6 +163,7 @@ if input, err := breez_sdk.ParseInput(lnurlAuthUrl); err != nil {
}
```
+
C#
@@ -187,7 +189,6 @@ catch (Exception)
// Handle error
}
```
-
diff --git a/src/guide/lnurl_pay.md b/src/guide/lnurl_pay.md
index 86d22f2..25d413c 100644
--- a/src/guide/lnurl_pay.md
+++ b/src/guide/lnurl_pay.md
@@ -20,8 +20,8 @@ if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await {
sdk.lnurl_pay(amount_msat, Some(comment), pd).await?;
}
```
-
+
Swift
@@ -41,13 +41,14 @@ do {
}
```
+
Android
```kotlin
// Endpoint can also be of the form:
// lnurlp://domain.com/lnurl-pay?key=val
-// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7…
+// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
val lnurlPayUrl = "lightning@address.com";
try {
val inputType = parseInput(lnurlPayUrl)
@@ -62,6 +63,7 @@ try {
}
```
+
React Native
@@ -82,6 +84,7 @@ try {
}
```
+
Dart
@@ -106,6 +109,7 @@ try {
}
```
+
Python
@@ -124,6 +128,7 @@ except Exception as error:
# Handle error
```
+
Go
@@ -143,6 +148,7 @@ if input, err := breez_sdk.ParseInput(lnurlPayUrl); err != nil {
}
```
+
C#
diff --git a/src/guide/lnurl_withdraw.md b/src/guide/lnurl_withdraw.md
index db6a7e8..cf7da6f 100644
--- a/src/guide/lnurl_withdraw.md
+++ b/src/guide/lnurl_withdraw.md
@@ -13,7 +13,6 @@
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
- // TODO Determine withdraw amount
let amount_msat = wd.min_withdrawable;
let description = "Test withdraw".to_string();
@@ -21,6 +20,7 @@ if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
}
```
+
Swift
@@ -39,9 +39,9 @@ do {
} catch {
// handle error
}
-
```
+
Android
@@ -63,6 +63,7 @@ try {
}
```
+
React Native
@@ -82,6 +83,7 @@ try {
}
```
+
Dart
@@ -105,6 +107,7 @@ try {
}
```
+
Python
@@ -122,6 +125,7 @@ except Exception as error:
# Handle error
```
+
Go
@@ -140,6 +144,7 @@ if input, err := breez_sdk.ParseInput(lnurlWithdrawUrl); err != nil {
}
```
+
C#
diff --git a/src/guide/payments.md b/src/guide/payments.md
index 5d64116..d1afe7a 100644
--- a/src/guide/payments.md
+++ b/src/guide/payments.md
@@ -1,37 +1,22 @@
# 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:
+
Rust
-## 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
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?;
-```
-
+
Swift
-## 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
do {
let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats")
@@ -39,34 +24,11 @@ do {
// 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
-}
-```
+
Android
-## 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
try {
val invoice = sdk.receivePayment(3000L.toULong(), "Invoice for 3000 sats")
@@ -74,34 +36,11 @@ try {
// 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
-}
-```
+
React Native
-## 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
try {
const invoice = await receivePayment(3000, "Invoice for 3000 sats")
@@ -109,34 +48,11 @@ try {
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)
-}
-```
+
Dart
-## 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
try {
ReceivePaymentRequestData requestData = ReceivePaymentRequestData(amountSats: 3000, description: "Invoice for 3000 sats");
@@ -145,8 +61,97 @@ try {
// handle error
}
```
+
+
+Python
+
+
+```python
+try:
+ invoice = sdk_services.receive_payment(3000, "Invoice for 3000 sats")
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+invoice, err := sdkServices.ReceivePayment(3000, "Invoice for 3000 sats")
+```
+
+
+C#
+
+
+```cs
+try
+{
+ var invoice = sdk.ReceivePayment(3000, "Invoice for 3000 sats");
+}
+catch (Exception)
+{
+ // Handle error
+}
+```
+
+
## Sending Lightning Payments
+
+
+Rust
+
+
+```rust,ignore
+let bolt11 = "...";
+sdk.send_payment(bolt11.into(), Some(3000)).await?;
+```
+
+
+Swift
+
+
+```swift
+let bolt11 = "...";
+do {
+ let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000)
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+val bolt11 = "..."
+try {
+ val payment = sdk.sendPayment(bolt11, 3000L.toULong())
+} catch (e: Exception) {
+ // handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+const bolt11 = "...";
+try {
+ const payment = await sendPayment(bolt11, 3000)
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
```dart
String bolt11 = "...";
try {
@@ -158,8 +163,100 @@ try {
// handle error
}
```
+
+
+Python
+
+
+```python
+bolt11 = "..."
+try:
+ sdk_services.send_payment(bolt11, 3000)
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+const bolt11 = "...";
+payment, err := sdkServices.SendPayment(bolt11, 3000)
+```
+
+
+C#
+
+
+```cs
+const bolt11 = "...";
+try
+{
+ var payment = sdk.SendPayment(bolt11, 3000);
+}
+catch (Exception)
+{
+ // Handle error
+}
+```
+
+
## Sending Spontaneous Lightning Payments
+
+
+Rust
+
+
+```rust,ignore
+let node_id = "...";
+sdk.send_spontaneous_payment(node_id.into(), 3000).await?;
+```
+
+
+Swift
+
+
+```swift
+let nodeId = "...";
+do {
+ let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000)
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+val nodeId = "..."
+try {
+ val payment = sdk.sendSpontaneousPayment(nodeId, 3000L.toULong())
+} catch (e: Exception) {
+ // handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+const nodeId = "...";
+try {
+ const payment = await sendSpontaneousPayment(nodeId, 3000)
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
```dart
String nodeId = "...";
try {
@@ -172,30 +269,10 @@ try {
}
```
+
Python
-## 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
let node_id = "..."
try:
@@ -203,64 +280,20 @@ try:
except Exception as error:
# Handle error
```
-
+
Go
-## 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
const nodeId = "...";
payment, err := sdkServices.SendSpontaneousPayment(nodeId, 3000)
```
-
+
C#
-## 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
const nodeId = "...";
try
diff --git a/src/guide/receive_onchain.md b/src/guide/receive_onchain.md
index acf526c..fe93e30 100644
--- a/src/guide/receive_onchain.md
+++ b/src/guide/receive_onchain.md
@@ -11,32 +11,8 @@ let swap_info = sdk.receive_onchain().await?;
// Send your funds to the below bitcoin address
let address = swap_info.bitcoin_address;
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```rust,ignore
-let swap_info = sdk.in_progress_swap().await?
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```rust,ignore
-let refundables = sdk.list_refundables().await?
-```
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```rust,ignore
-let destination_address = "...".into()
-let sat_per_vbyte =
-sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?
-```
+
Swift
@@ -50,48 +26,8 @@ do {
// handle error
}
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```swift
-do {
- let swapInfo = try sdk.inProgressSwap()
-} catch {
- // handle error
-}
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```swift
-do {
- let refundables = try sdk.listRefundables()
-} catch {
- // handle error
-}
-```
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```swift
-let destinationAddress = "..."
-let satPerVbyte =
-
-do {
- try sdk.refund(
- swapAddress: "",
- toAddress: destinationAddress,
- satPerVbyte: satPerVbyte)
-} catch {
- // handle error
-}
-```
+
Android
@@ -104,45 +40,8 @@ try {
// handle error
}
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```kotlin
-try {
- val swapInfo = sdk.inProgressSwap()
-} catch (e: Exception) {
- // handle error
-}
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```kotlin
-try {
- val refundables = sdk.listRefundables()
-} catch (e: Exception) {
- // handle error
-}
-```
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```kotlin
-val swapAddress = "..."
-val destinationAddress = "..."
-val satPerVbyte = 1.toUInt()
-try {
- sdk.refund(swapAddress, destinationAddress, satPerVbyte)
-} catch (e: Exception) {
- // handle error
-}
-```
+
React Native
@@ -156,44 +55,8 @@ try {
console.log(error)
}
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```typescript
-try {
- const swapInfo = await inProgressSwap()
-} catch (error) {
- console.log(error)
-}
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```typescript
-try {
- const refundables = await listRefundables()
-} catch (error) {
- console.log(error)
-}
-```
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```typescript
-const destinationAddress = "..."
-const satPerVbyte =
-try {
- const result = await refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte)
-} catch (error) {
- console.log(error)
-}
-```
+
Dart
@@ -207,46 +70,8 @@ try {
// handle error
}
```
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```dart
-try {
- SwapInfo? swapInfo = await inProgressSwap()
-} catch (error) {
- // handle error
-}
-```
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```dart
-try {
- List refundables = await listRefundables()
-} catch (error) {
- // handle error
-}
-```
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```dart
-String destinationAddress = "..."
-int satPerVbyte =
-try {
- String result = await refund(
- swapAddress: refundable.bitcoinAddress,
- toAddress: destinationAddress,
- satPerVbyte: satPerVbyte,
- );
-} catch (error) {
- // handle error
-}
-```
+
Python
@@ -258,45 +83,8 @@ try:
except Exception as error:
# Handle error
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```python
-try:
- swap_info = sdk_services.in_progress_swap()
-except Exception as error:
- # Handle error
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-
-Once you have a refundable swap in hand, use the following code to execute a refund:
-
-```python
-try:
- refundables = sdk_services.list_refundables()
-except Exception as error:
- # Handle error
-```
-
-Once you have a refundable swap in hand, use the follwing code to execute a refund:
-
-```python
-destination_address = "..."
-sat_per_vbyte =
-
-try:
- sdk_services.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte)
-except Exception as error:
- # Handle error
-```
+
Go
@@ -306,33 +94,8 @@ if swapInfo, err := sdkServices.ReceiveOnchain(); err != nil {
address := swapInfo.BitcoinAddress
}
```
-
-Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
-
-```go
-swapInfo, err := sdkServices.InProgressSwap()
-```
-
-The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
-
-1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful.
-2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund.
-
-In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
-
-```go
-refundables, err := sdkServices.ListRefundables()
-```
-
-Once you have a refundable swap in hand, use the follwing code to execute a refund:
-
-```go
-destinationAddress := "..."
-satPerVbyte :=
-
-result, err := sdkServices.Refund(refundable.BitcoinAddress, destinationAddress, satPerVbyte)
-```
+
C#
@@ -349,9 +112,90 @@ catch (Exception)
// Handle error
}
```
+
+
Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code:
+
+Rust
+
+
+```rust,ignore
+let swap_info = sdk.in_progress_swap().await?
+```
+
+
+Swift
+
+
+```swift
+do {
+ let swapInfo = try sdk.inProgressSwap()
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+try {
+ val swapInfo = sdk.inProgressSwap()
+} catch (e: Exception) {
+ // handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+try {
+ const swapInfo = await inProgressSwap()
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ SwapInfo? swapInfo = await inProgressSwap()
+} catch (error) {
+ // handle error
+}
+```
+
+
+Python
+
+
+```python
+try:
+ swap_info = sdk_services.in_progress_swap()
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+swapInfo, err := sdkServices.InProgressSwap()
+```
+
+
+C#
+
+
```cs
try
{
@@ -362,6 +206,8 @@ catch (Exception)
// Handle error
}
```
+
+
The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds:
@@ -370,6 +216,85 @@ The process of receiving funds via an on-chain address is trustless and uses a s
In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps:
+
+Rust
+
+
+```rust,ignore
+let refundables = sdk.list_refundables().await?
+```
+
+
+Swift
+
+
+```swift
+do {
+ let refundables = try sdk.listRefundables()
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+try {
+ val refundables = sdk.listRefundables()
+} catch (e: Exception) {
+ // handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+try {
+ const refundables = await listRefundables()
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ List refundables = await listRefundables()
+} catch (error) {
+ // handle error
+}
+```
+
+
+Python
+
+
+```python
+try:
+ refundables = sdk_services.list_refundables()
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+refundables, err := sdkServices.ListRefundables()
+```
+
+
+C#
+
+
```cs
try
{
@@ -380,9 +305,115 @@ catch (Exception)
// Handle error
}
```
+
+
Once you have a refundable swap in hand, use the following code to execute a refund:
+
+Rust
+
+
+```rust,ignore
+let destination_address = "...".into()
+let sat_per_vbyte =
+sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?
+```
+
+
+Swift
+
+
+```swift
+let destinationAddress = "..."
+let satPerVbyte =
+
+do {
+ try sdk.refund(
+ swapAddress: "",
+ toAddress: destinationAddress,
+ satPerVbyte: satPerVbyte)
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```kotlin
+val swapAddress = "..."
+val destinationAddress = "..."
+val satPerVbyte = 1.toUInt()
+try {
+ sdk.refund(swapAddress, destinationAddress, satPerVbyte)
+} catch (e: Exception) {
+ // handle error
+}
+```
+
+
+React Native
+
+
+```typescript
+const destinationAddress = "..."
+const satPerVbyte =
+try {
+ const result = await refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte)
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+String destinationAddress = "..."
+int satPerVbyte =
+try {
+ String result = await refund(
+ swapAddress: refundable.bitcoinAddress,
+ toAddress: destinationAddress,
+ satPerVbyte: satPerVbyte,
+ );
+} catch (error) {
+ // handle error
+}
+```
+
+
+Python
+
+
+```python
+destination_address = "..."
+sat_per_vbyte =
+
+try:
+ sdk_services.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte)
+except Exception as error:
+ # Handle error
+```
+
+
+Go
+
+
+```go
+destinationAddress := "..."
+satPerVbyte :=
+
+result, err := sdkServices.Refund(refundable.BitcoinAddress, destinationAddress, satPerVbyte)
+```
+
+
+C#
+
+
```cs
var destinationAddress = "...";
var satPerVbyte = ;
@@ -400,15 +431,14 @@ catch (Exception)
# Calculating fees
-
-
-Rust
-
-
When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
To calculate the fees for a channel being opened by the LSP:
+
+Rust
+
+
```rust,ignore
async fn calculate_channel_opening_fee(amount_msat: u64) -> Result {
let channel_opening_fee_needed = is_channel_opening_fee_needed(amount_msat, sdk.clone())?;
@@ -418,19 +448,239 @@ async fn calculate_channel_opening_fee(amount_msat: u64) -> Result {
}
}
```
+
+
+Swift
+
+
+```swift
+func calculateChannelOpeningFee(amountMsats: Int64) -> Int64? {
+ var channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats: amountMsats)
+ if channelOpeningFeeNeeded {
+ return calculateFeesForAmount(amountMsats: amountMsats)
+ }
+ return nil
+}
+```
+
+
+Android
+
+
+```kotlin
+fun calculateChannelOpeningFee(amountMsats: Long): Long? {
+ val channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats)
+ if (channelOpeningFeeNeeded) {
+ return calculateFeesForAmount(amountMsats)
+ }
+ return null
+}
+```
+
+
+React Native
+
+
+```typescript
+const calculateChannelOpeningFee = async (amountMsats: number): number => {
+ const channelOpeningFeeNeeded = await isChannelOpeningFeeNeeded(amountMsats)
+ if (channelOpeningFeeNeeded) {
+ return calculateFeesForAmount(amountMsats)
+ }
+ return 0
+}
+```
+
+
+Dart
+
+
+```dart
+int calculateChannelOpeningFee(int amountMsat) async {
+ bool isChannelOpeningFeeNeeded = await isChannelOpeningFeeNeeded(amountMsat);
+ return isChannelOpeningFeeNeeded ? calculateFeesForAmount(amountMsat) : 0;
+}
+```
+
+
+Python
+
+
+```python
+def calculate_channel_opening_fees(amount_msats):
+ is_channel_opening_fee_needed = is_channel_opening_fee_needed()
+
+ if is_channel_opening_fee_needed:
+ return calculate_fees_for_amount(amount_msats)
+ else:
+ return None
+```
+
+
+Go
+
+
+```go
+func CalculateChannelOpeningFee(amountMsats uint64) (uint64, error) {
+ isChannelOpeningFeeNeeded := isChannelOpeningFeeNeeded(amountMsats)
+ if !isChannelOpeningFeeNeeded {
+ return 0, fmt.Errorf("Channel not needed")
+ }
+ return calculateFeesForAmount(amountMsats), nil
+}
+```
+
+
+C#
+
+
+```cs
+ulong calculateChannelOpeningFee(ulong amountMsats)
+{
+ var channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats);
+ if (channelOpeningFeeNeeded)
+ {
+ return calculateFeesForAmount(amountMsats);
+ }
+ return 0;
+}
+```
+
+
How to detect if open channel fees are needed:
+
+
+Rust
+
+
```rust,ignore
fn is_channel_opening_fee_needed(amount_msats: u64) -> Result {
let node_info = sdk.node_info()?.ok_or(anyhow!("No node info found"))?;
Ok(node_info.inbound_liquidity_msats <= amount_msats)
}
```
+
+
+Swift
+
+
+```swift
+func isChannelOpeningFeeNeeded(amountMsats: Int64) -> Bool {
+ do {
+ let nodeInfo = try sdk.nodeInfo()
+
+ if let inboundLiquidityMsats = nodeInfo?.inboundLiquidityMsats {
+ return inboundLiquidityMsats <= amountMsats
+ }
+ } catch {
+ // Handle error
+ }
+ return false
+}
+```
+
+
+Android
+
+
+```kotlin
+fun isChannelOpeningFeeNeeded(amountMsats: Long): Boolean {
+ try {
+ val nodeInfo = sdk.nodeInfo()
+ val inboundLiquidityMsats = nodeInfo?.inboundLiquidityMsats?.toLong()
+ if (inboundLiquidityMsats != null) {
+ return inboundLiquidityMsats <= amountMsats
+ }
+ } catch (e: Exception) {
+ // Handle error
+ }
+ return false
+}
+```
+
+
+React Native
+
+
+```typescript
+const isChannelOpeningFeeNeeded = async (amountMsats: number): boolean => {
+ try {
+ const nodeInfo = await nodeInfo()
+ return nodeInfo.inboundLiquidityMsats <= amountMsats
+ } catch (error) {
+ // handle error
+ }
+ return false
+}
+```
+
+
+Dart
+
+
+```dart
+// Assumes nodeState isn't empty
+bool isChannelOpeningFeeNeeded(int amountMsat) async {
+ NodeState? nodeState = await getNodeState();
+ return amountMsat >= nodeState.inboundLiquidityMsats;
+}
+```
+
+
+Python
+
+
+```python
+def is_channel_opening_fee_needed(amount_msats):
+ return sdk_services.node_info().inbound_liquidity_msats <= amount_msats
+```
+
+
+Go
+
+
+```go
+func isChannelOpeningFeeNeeded(amountMsats uint64) bool {
+ nodeInfo, err := sdkServices.NodeInfo()
+ if err != nil {
+ // Handle error
+ }
+ return nodeInfo.InboundLiquidityMsats <= amountMsats
+}
+```
+
+
+C#
+
+
+```cs
+bool isChannelOpeningFeeNeeded(ulong amountMsats)
+{
+ try
+ {
+ var nodeInfo = sdk.NodeInfo();
+ return nodeInfo.inboundLiquidityMsats <= amountMsats;
+ }
+ catch (Exception)
+ {
+ // handle error
+ }
+
+ return false;
+}
+```
+
+
LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
This information can be retrieved for each LSP and then calculated:
+
+Rust
+
+
```rust,ignore
async fn calculate_fees_for_amount(amount_msat: u64) -> Result {
let lsp_id = sdk.lsp_id().await?.ok_or(anyhow!("No lsp id found"))?;
@@ -449,46 +699,11 @@ async fn calculate_fees_for_amount(amount_msat: u64) -> Result {
Ok(fee_msat)
}
```
-
Swift
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```swift
-func calculateChannelOpeningFee(amountMsats: Int64) -> Int64? {
- var channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats: amountMsats)
- if channelOpeningFeeNeeded {
- return calculateFeesForAmount(amountMsats: amountMsats)
- }
- return nil
-}
-```
-
-How to detect if open channel fees are needed:
-```swift
-func isChannelOpeningFeeNeeded(amountMsats: Int64) -> Bool {
- do {
- let nodeInfo = try sdk.nodeInfo()
-
- if let inboundLiquidityMsats = nodeInfo?.inboundLiquidityMsats {
- return inboundLiquidityMsats <= amountMsats
- }
- } catch {
- // Handle error
- }
- return false
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```swift
func calculateFeesForAmount(amountMsats: Int64) -> Int64? {
do {
@@ -507,45 +722,11 @@ func calculateFeesForAmount(amountMsats: Int64) -> Int64? {
return nil
}
```
-
+
Android
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```kotlin
-fun calculateChannelOpeningFee(amountMsats: Long): Long? {
- val channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats)
- if (channelOpeningFeeNeeded) {
- return calculateFeesForAmount(amountMsats)
- }
- return null
-}
-```
-
-How to detect if open channel fees are needed:
-```kotlin
-fun isChannelOpeningFeeNeeded(amountMsats: Long): Boolean {
- try {
- val nodeInfo = sdk.nodeInfo()
- val inboundLiquidityMsats = nodeInfo?.inboundLiquidityMsats?.toLong()
- if (inboundLiquidityMsats != null) {
- return inboundLiquidityMsats <= amountMsats
- }
- } catch (e: Exception) {
- // Handle error
- }
- return false
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```kotlin
fun calculateFeesForAmount(amountMsats: Long): Long? {
try {
@@ -560,42 +741,11 @@ fun calculateFeesForAmount(amountMsats: Long): Long? {
return null
}
```
-
+
React Native
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```typescript
-const calculateChannelOpeningFee = async (amountMsats: number): number => {
- const channelOpeningFeeNeeded = await isChannelOpeningFeeNeeded(amountMsats)
- if (channelOpeningFeeNeeded) {
- return calculateFeesForAmount(amountMsats)
- }
- return 0
-}
-```
-
-How to detect if open channel fees are needed:
-```typescript
-const isChannelOpeningFeeNeeded = async (amountMsats: number): boolean => {
- try {
- const nodeInfo = await nodeInfo()
- return nodeInfo.inboundLiquidityMsats <= amountMsats
- } catch (error) {
- // handle error
- }
- return false
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```typescript
const calculateFeesForAmount = async (amountMsats: number): number => {
try {
@@ -613,37 +763,11 @@ const calculateFeesForAmount = async (amountMsats: number): number => {
return 0
}
```
-
Dart
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```dart
-int calculateChannelOpeningFee(int amountMsat) async {
- bool isChannelOpeningFeeNeeded = await isChannelOpeningFeeNeeded(amountMsat);
- return isChannelOpeningFeeNeeded ? calculateFeesForAmount(amountMsat) : 0;
-}
-```
-
-How to detect if open channel fees are needed:
-
-```dart
-// Assumes nodeState isn't empty
-bool isChannelOpeningFeeNeeded(int amountMsat) async {
- NodeState? nodeState = await getNodeState();
- return amountMsat >= nodeState.inboundLiquidityMsats;
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```dart
// Assumes lspId & lspInformation isn't empty
int calculateFeesForAmount(int amountMsat) async {
@@ -657,35 +781,9 @@ int calculateFeesForAmount(int amountMsat) async {
```
-
Python
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```python
-def calculate_channel_opening_fees(amount_msats):
- is_channel_opening_fee_needed = is_channel_opening_fee_needed()
-
- if is_channel_opening_fee_needed:
- return calculate_fees_for_amount(amount_msats)
- else:
- return None
-```
-
-How to detect if open channel fees are needed:
-
-```python
-def is_channel_opening_fee_needed(amount_msats):
- return sdk_services.node_info().inbound_liquidity_msats <= amount_msats
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```python
def calculate_fees_for_amount(amount_msats):
# We need to open channel so we are calculating the fees for the LSP.
@@ -704,35 +802,6 @@ def calculate_fees_for_amount(amount_msats):
Go
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
-```go
-func CalculateChannelOpeningFee(amountMsats uint64) (uint64, error) {
- isChannelOpeningFeeNeeded := isChannelOpeningFeeNeeded(amountMsats)
- if !isChannelOpeningFeeNeeded {
- return 0, fmt.Errorf("Channel not needed")
- }
- return calculateFeesForAmount(amountMsats), nil
-}
-```
-
-How to detect if open channel fees are needed:
-```go
-func isChannelOpeningFeeNeeded(amountMsats uint64) bool {
- nodeInfo, err := sdkServices.NodeInfo()
- if err != nil {
- // Handle error
- }
- return nodeInfo.InboundLiquidityMsats <= amountMsats
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
```go
func calculateFeesForAmount(amountMsats uint64) uint64 {
lspId, err := sdkServices.LspId()
@@ -756,50 +825,12 @@ func calculateFeesForAmount(amountMsats uint64) uint64 {
return feeMsats
}
```
-
+
C#
-When the amount to be received exceeds the inbound liquidity of the node, a new channel will be opened by the LSP in order for the node to receive it. This can checked by retrieving the NodeState from the SDK and comparing the inbound liquidity to the amount to be received. If the amount is greater or equal to the inbound liquidity, a new channel opening is required.
-
-To calculate the fees for a channel being opened by the LSP:
-
```cs
-ulong calculateChannelOpeningFee(ulong amountMsats)
-{
- var channelOpeningFeeNeeded = isChannelOpeningFeeNeeded(amountMsats);
- if (channelOpeningFeeNeeded)
- {
- return calculateFeesForAmount(amountMsats);
- }
- return 0;
-}
-```
-
-How to detect if open channel fees are needed:
-```typescript
-bool isChannelOpeningFeeNeeded(ulong amountMsats)
-{
- try
- {
- var nodeInfo = sdk.NodeInfo();
- return nodeInfo.inboundLiquidityMsats <= amountMsats;
- }
- catch (Exception)
- {
- // handle error
- }
-
- return false;
-}
-```
-
-LSP fees are calculated in two ways, either by a minimum fee set by the LSP or by a fee per myriad calculated based on the amount being received. If the fee calculated from the fee per myriad is less than the minimum fee, the minimum fee is used.
-
-This information can be retrieved for each LSP and then calculated:
-
-```typescript
ulong calculateFeesForAmount(ulong amountMsats)
{
try
@@ -821,6 +852,5 @@ ulong calculateFeesForAmount(ulong amountMsats)
return 0;
}
```
-
\ No newline at end of file
diff --git a/src/guide/send_onchain.md b/src/guide/send_onchain.md
index f549320..07cab0b 100644
--- a/src/guide/send_onchain.md
+++ b/src/guide/send_onchain.md
@@ -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 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);
-}
-```
+
Swift
@@ -62,43 +31,8 @@ try {
// 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 =
-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)")
-}
-```
+
Android
@@ -112,43 +46,8 @@ try {
// 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}")
-}
-```
+
React Native
@@ -163,48 +62,8 @@ try {
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 =
-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)
-}
-```
+
Dart
@@ -219,50 +78,8 @@ try {
// 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 =
-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 swaps = await inProgressReverseSwaps();
- for (swap in swaps) {
- print(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
- }
-} catch (error) {
- // handle error
-}
-```
+
Python
@@ -275,45 +92,8 @@ try:
except Exception as 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
-```
+
Go
@@ -324,42 +104,8 @@ if currentFees, err := sdkServices.FetchReverseSwapFees(); err != nil {
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 :=
-
-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)
- }
-}
-```
+
C#
@@ -376,6 +122,8 @@ catch (Exception)
// 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
@@ -383,13 +131,188 @@ of the total costs.
Fetching the fees also tells you what is the range of amounts you can send:
+
+Rust
+
+
+```rust,ignore
+info!("Minimum amount, in sats: {}", current_fees.min);
+info!("Maximum amount, in sats: {}", current_fees.max);
+```
+
+
+Swift
+
+
+```swift
+println("Minimum amount, in sats: \(current_fees.min)")
+println("Maximum amount, in sats: \(current_fees.max)")
+```
+
+
+Android
+
+
+```kotlin
+Log.v("Breez", "Minimum amount, in sats: ${fees.min}")
+Log.v("Breez", "Maximum amount, in sats: ${fees.max}")
+```
+
+
+React Native
+
+
+```typescript
+console.log(`Minimum amount, in sats: ${currentFees.min}`);
+console.log(`Maximum amount, in sats: ${currentFees.max}`);
+```
+
+
+Dart
+
+
+```dart
+print(`Minimum amount, in sats: ${currentFees.min}`);
+print(`Maximum amount, in sats: ${currentFees.max}`);
+```
+
+
+Python
+
+
+```python
+print("Minimum amount, in sats: ", current_fees.min)
+print("Maximum amount, in sats: ", current_fees.max)
+```
+
+
+Go
+
+
+```go
+log.Printf("Minimum amount, in sats: %v", currentFees.Min)
+log.Printf("Maximum amount, in sats: %v", currentFees.Max)
+```
+
+
+C#
+
+
```cs
Console.WriteLine($"Minimum amount, in sats: {currentFees.min}");
Console.WriteLine($"Maximum amount, in sats: {currentFees.max}");
```
+
+
Once you checked the fees are acceptable, you can start the reverse swap:
+
+Rust
+
+
+```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?;
+```
+
+
+Swift
+
+
+```swift
+let destinationAddress = "bc1.."
+let amountSat = currentFees.min
+let satPerVbyte =
+try {
+ try sdk.sendOnchain(amountSat: amountSat, onchainRecipientAddress: destinationAddress, pairHash: currentFees.feesHash, satPerVbyte: satPerVbyte)
+} catch {
+ // handle error
+}
+```
+
+
+Android
+
+
+```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
+}
+```
+
+
+React Native
+
+
+```typescript
+const destinationAddress = "bc1..";
+const amountSat = currentFees.min;
+const satPerVbyte =
+try {
+ const reverseSwapInfo = sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte)
+} catch (error) {
+ console.log(error)
+}
+```
+
+
+Dart
+
+
+```dart
+String destinationAddress = "bc1..";
+int amountSat = currentFees.min;
+int satPerVbyte =
+try {
+ ReverseSwapInfo reverseSwapInfo = await sendOnchain(
+ amountSat: amountSat,
+ onchainRecipientAddress: destinationAddress,
+ pairHash: currentFees.feesHash,
+ satPerVbyte: satPerVbyte,
+ );
+} catch (error) {
+ // handle error
+}
+```
+
+
+Python
+
+
+```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
+```
+
+
+Go
+
+
+```go
+destinationAddress := "bc1.."
+amountSat := currentFees.Min
+satPerVbyte :=
+
+reverseSwapInfo, err := sdkServices.SendOnchain(amountSat, destinationAddress, currentFees.FeesHash, satPerVbyte)
+```
+
+
+C#
+
+
```cs
var destinationAddress = "bc1..";
var amountSat = currentFees.min;
@@ -403,6 +326,8 @@ catch (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
@@ -410,6 +335,95 @@ is either settled or cancelled. This will happen automatically at the end of the
You can check its status with:
+
+Rust
+
+
+```rust,ignore
+for rs in sdk.in_progress_reverse_swaps().await? {
+ info!("Reverse swap {} in progress, status is {}", rs.id, rs.status);
+}
+```
+
+
+Swift
+
+
+```swift
+for rs in sdk.inProgressReverseSwaps() {
+ println("Reverse swap \(rs.id) in progress, status is \(rs.status)")
+}
+```
+
+
+Android
+
+
+```kotlin
+for (rs in sdk.inProgressReverseSwaps()) {
+ Log.v("Breez", "Reverse swap ${rs.id} in progress, status is ${rs.status}")
+}
+```
+
+
+React Native
+
+
+```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)
+}
+```
+
+
+Dart
+
+
+```dart
+try {
+ List swaps = await inProgressReverseSwaps();
+ for (swap in swaps) {
+ print(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
+ }
+} catch (error) {
+ // handle error
+}
+```
+
+
+Python
+
+
+```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
+```
+
+
+Go
+
+
+```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)
+ }
+}
+```
+
+
+C#
+
+
```cs
try
{
@@ -425,6 +439,7 @@ catch (Exception)
```
+
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.