Merge pull request #2 from breez/ok300-small-fixes

Several fixes
This commit is contained in:
ok300
2023-04-30 13:33:44 +02:00
committed by GitHub
4 changed files with 20 additions and 13 deletions

View File

@@ -4,3 +4,10 @@ language = "en"
multilingual = true multilingual = true
src = "src" src = "src"
title = "Breez SDK" title = "Breez SDK"
[output.html]
git-repository-url = "https://github.com/breez/breez-sdk-docs"
edit-url-template = "https://github.com/breez/breez-sdk-docs/edit/main/{path}"
[output.html.print]
enable = false

View File

@@ -12,13 +12,13 @@ The Breez SDK provides the following services:
Connecting to a node requires a seed (your master key) and credentials. The seed is a bip39 mnemonic and the credentials are retrieved by registering a new node or recovering an existing one. Connecting to a node requires a seed (your master key) and credentials. The seed is a bip39 mnemonic and the credentials are retrieved by registering a new node or recovering an existing one.
## Registering a new node ## Registering a new node
```rust ```rust,no_run
let seed = <your seed>; let seed = <your seed>;
let credentials = BreezServices::register_node(Network::Bitcoin, seed).await?; let credentials = BreezServices::register_node(Network::Bitcoin, seed).await?;
``` ```
## Recovering an existing node ## Recovering an existing node
```rust ```rust,no_run
let seed = <your seed>; let seed = <your seed>;
let credentials = BreezServices::register_node(Network::Bitcoin, seed).await?; let credentials = BreezServices::register_node(Network::Bitcoin, seed).await?;
``` ```
@@ -27,7 +27,7 @@ Once the credentials are retrieved they should be saved in a secured storage.
The next step is to initialize the SDK and start the node: The next step is to initialize the SDK and start the node:
## Initializing the SDK ## Initializing the SDK
```rust ```rust,no_run
// Create the default config // Create the default config
let config = BreezServices::default_config(EnvironmentType::Production) let config = BreezServices::default_config(EnvironmentType::Production)
@@ -48,10 +48,10 @@ BreezServices::start(rt(), &sdk).await?;
At any point we can fetch our balance from the Greenlight node: At any point we can fetch our balance from the Greenlight node:
```rust ```rust,no_run
if let Some(node_state) = sdk.node_info()? { if let Some(node_state) = sdk.node_info()? {
let balance_ln = node_state.channels_balance_msat; let balance_ln = node_state.channels_balance_msat;
let balance_onchain = node_state.onchain_balance_msat; let balance_onchain = node_state.onchain_balance_msat;
} }
``` ```
You are now ready to receive a Lightning [payment](guide/payments.md). You are now ready to receive a Lightning [payment](payments.md).

View File

@@ -4,18 +4,18 @@
Breez SDK doesn't require you to open a channel and set up your inbound liquidity. 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: Breez SDK automatically connects your node to the LSP peer and you can now receive payments:
```rust ```rust,no_run
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 ## Sending Lightning Payments
```rust ```rust,no_run
let bolt11 = "..."; let bolt11 = "...";
sdk.send_payment(bolt11.into(), Some(3000)).await?; sdk.send_payment(bolt11.into(), Some(3000)).await?;
``` ```
## Sending Spontaneus Lightning Payments ## Sending Spontaneous Lightning Payments
```rust ```rust,no_run
let node_id = "..."; let node_id = "...";
sdk.send_payment(node_id.into(), Some(3000)).await?; sdk.send_payment(node_id.into(), Some(3000)).await?;
``` ```

View File

@@ -1,7 +1,7 @@
# Receiving an on-chain transaction (swap-in) # Receiving an on-chain transaction (swap-in)
There are cases when you have funds in some bitcoin address and you would like to send those to your lightning node. There are cases when you have funds in some bitcoin address and you would like to send those to your lightning node.
```rust ```rust,no_run
let swap_info = sdk.receive_onchain().await?; let swap_info = sdk.receive_onchain().await?;
// Send your funds to the bellow bitcoin address // Send your funds to the bellow bitcoin address
@@ -10,7 +10,7 @@ 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: 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,no_run
let swap_info = sdk.in_progress_swap().await? let swap_info = sdk.in_progress_swap().await?
``` ```
@@ -21,13 +21,13 @@ 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: 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,no_run
let refundables = sdk.list_refundables().await? let refundables = sdk.list_refundables().await?
``` ```
Once you have a refundable swap in hand, use the follwing code to execute a refund: Once you have a refundable swap in hand, use the follwing code to execute a refund:
```rust ```rust,no_run
let destination_address = "...".into() let destination_address = "...".into()
let sat_per_byte = <efund tx fee rate> let sat_per_byte = <efund tx fee rate>
sdk.refund(refundable.bitcoin_address, destination_address, sat_per_byte).await? sdk.refund(refundable.bitcoin_address, destination_address, sat_per_byte).await?