Extract rust snippets and reference them

This commit is contained in:
ok300
2023-10-20 17:36:58 +02:00
parent c719cc4ae6
commit 32c39e2543
32 changed files with 4069 additions and 144 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,6 @@
book book
.DS_Store .DS_Store
.idea .idea
# Sub-projects with code snippets
snippets/rust/target

3622
snippets/rust/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
snippets/rust/Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
name = "sdk_docs_snippets"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1"
bip39 = { version = "2", features = ["rand"] }
breez-sdk-core = { git = "https://github.com/breez/breez-sdk", rev = "d6365dc90263f3ad3f65a113fdc016a0bf070d9d" }
log = "0.4"
tokio = "1.29"

View File

@@ -0,0 +1,14 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn buy(sdk: Arc<BreezServices>) -> Result<()> {
let res = sdk.buy_bitcoin(
BuyBitcoinRequest {
provider: BuyBitcoinProvider::Moonpay,
opening_fee_params: None})
.await?;
Ok(())
}

View File

@@ -0,0 +1,17 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn get_lsp_info(sdk: Arc<BreezServices>) -> Result<LspInformation> {
let lsp_id = sdk.lsp_id().await?;
let lsp_info = sdk.lsp_info().await?;
Ok(lsp_info)
}
async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> {
sdk.connect_lsp(lsp_id).await?;
Ok(())
}

View File

@@ -0,0 +1,40 @@
use std::collections::HashMap;
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn list_supported_fiat_currencies(sdk: Arc<BreezServices>) -> Result<()> {
let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
Ok(())
}
async fn get_current_rates(sdk: Arc<BreezServices>) -> Result<()> {
let fiat_rates = sdk.fetch_fiat_rates().await?;
Ok(())
}
async fn get_fiat_currencies_and_rates(sdk: Arc<BreezServices>) -> Result<Vec<(FiatCurrency, Rate)>> {
let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
let fiat_rates = sdk.fetch_fiat_rates().await?;
let mut rates_map : HashMap<String, Rate> = HashMap::new();
for rate in fiat_rates {
rates_map.insert(rate.coin.to_string().to_lowercase(), rate);
}
let mut sorted = supported_fiat_currencies.clone();
sorted.sort_by_key(|f| f.info.name);
let mut result : Vec<(FiatCurrency, Rate)> = Vec::new();
for currency in sorted {
let rate = rates_map.get(&currency.id.to_lowercase());
if let Some(rate) = rate.cloned() {
result.push((currency, rate));
}
}
Ok(result)
}

View File

@@ -0,0 +1,47 @@
use anyhow::Result;
use bip39::{Language, Mnemonic};
use breez_sdk_core::*;
use std::sync::Arc;
use crate::AppEventListener;
async fn getting_started() -> Result<Arc<BreezServices>> {
let mnemonic = Mnemonic::generate_in(Language::English, 12)?;
let seed = mnemonic.to_seed("");
let invite_code = Some("<invite code>".into());
let api_key = "<api key>".into();
// Create the default config
let mut config = BreezServices::default_config(
EnvironmentType::Production,
api_key,
breez_sdk_core::NodeConfig::Greenlight {
config: GreenlightNodeConfig {
partner_credentials: None,
invite_code
},
},
);
// Customize the config object according to your needs
config.working_dir = "path to an existing directory".into();
// Connect to the Breez SDK make it ready for use
let sdk = BreezServices::connect(
config,
seed.to_vec(),
Box::new(AppEventListener {}),
)
.await?;
Ok(sdk)
}
async fn getting_started_node_info(sdk: Arc<BreezServices>) -> Result<()> {
if let Some(node_state) = sdk.node_info()? {
let balance_ln = node_state.channels_balance_msat;
let balance_onchain = node_state.onchain_balance_msat;
}
Ok(())
}

View File

@@ -0,0 +1,30 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn list_payments(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
let payments = sdk.list_payments(
ListPaymentRequest {
filter: PaymentTypeFilter::All,
from_timestamp: None,
to_timestamp: None,
include_failures: None,
}
).await?;
Ok(payments)
}
async fn list_payments_filtered(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
let payments = sdk.list_payments(
ListPaymentRequest {
filter: PaymentTypeFilter::Sent,
from_timestamp: 1696880000,
to_timestamp: None,
include_failures: true,
}
).await?;
Ok(payments)
}

View File

@@ -0,0 +1,28 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
use breez_sdk_core::InputType::LnUrlAuth;
use log::{error, info};
async fn auth(sdk: Arc<BreezServices>) -> Result<()> {
// Endpoint can also be of the form:
// keyauth://domain.com/auth?key=val
let lnurl_auth_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await {
match sdk.lnurl_auth(ad).await {
Ok(LnUrlCallbackStatus::Ok) => {
info!("Successfully authenticated")
}
Ok(LnUrlCallbackStatus::ErrorStatus { data }) => {
error!("Failed to authenticate: {}", data.reason)
}
Err(e) => {
error!("Failed to connect: {e}")
}
}
}
Ok(())
}

View File

@@ -0,0 +1,22 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
use breez_sdk_core::InputType::LnUrlPay;
async fn pay(sdk: Arc<BreezServices>) -> Result<()> {
// Endpoint can also be of the form:
// lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
let lnurl_pay_url = "lightning@address.com";
if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await {
// TODO Show payment details in UI, read user input
let amount_msat = pd.min_sendable;
let comment = "Test payment".to_string();
sdk.lnurl_pay(amount_msat, Some(comment), pd).await?;
}
Ok(())
}

View File

@@ -0,0 +1,19 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn withdraw(sdk: Arc<BreezServices>) -> Result<()> {
// Endpoint can also be of the form:
// lnurlw://domain.com/lnurl-withdraw?key=val
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
let amount_msat = wd.min_withdrawable;
let description = "Test withdraw".to_string();
sdk.lnurl_withdraw(wd, amount_msat, Some(description)).await?;
}
Ok(())
}

32
snippets/rust/src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
mod getting_started;
mod receive_payment;
mod send_payment;
mod send_spontaneous_payment;
mod list_payments;
mod connecting_lsp;
mod receive_onchain;
mod send_onchain;
mod lnurl_pay;
mod lnurl_withdraw;
mod lnurl_auth;
mod fiat_currencies;
mod buy_btc;
mod static_channel_backup;
use std::str::FromStr;
use anyhow::Result;
use breez_sdk_core::*;
use log::info;
struct AppEventListener {}
impl EventListener for AppEventListener {
fn on_event(&self, e: BreezEvent) {
info!("Received Breez event: {e:?}");
}
}
#[tokio::main]
async fn main() -> Result<()> {
Ok(())
}

View File

@@ -0,0 +1,43 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()> {
let swap_info = sdk.receive_onchain(
ReceiveOnchainRequest { opening_fee_params: None } )
.await?;
// Send your funds to the below bitcoin address
let address = swap_info.bitcoin_address;
Ok(())
}
async fn get_in_progress_swap(sdk: Arc<BreezServices>) -> Result<()> {
let swap_info = sdk.in_progress_swap().await?;
Ok(())
}
async fn list_refundables(sdk: Arc<BreezServices>) -> Result<()> {
let refundables = sdk.list_refundables().await?;
Ok(())
}
async fn execute_refund(sdk: Arc<BreezServices>, refund_tx_fee_rate: u32, refundable: SwapInfo) -> Result<()> {
let destination_address = "...".into();
let sat_per_vbyte = refund_tx_fee_rate;
sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?;
Ok(())
}
async fn get_channel_opening_fees(sdk: Arc<BreezServices>, amount_msat: u64) -> Result<()> {
let channel_fees = sdk.open_channel_fee(
OpenChannelFeeRequest { amount_msat, expiry: None })
.await?;
Ok(())
}

View File

@@ -0,0 +1,20 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
let res = sdk.receive_payment(
ReceivePaymentRequest {
amount_sats: 3000,
description: "Invoice for 3000 sats".into(),
cltv: None,
expiry: None,
opening_fee_params: None,
preimage: None,
use_description_hash: None
})
.await?;
Ok(())
}

View File

@@ -0,0 +1,42 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
use log::info;
async fn get_current_fees(sdk: Arc<BreezServices>) -> Result<()> {
let current_fees = sdk.fetch_reverse_swap_fees(
ReverseSwapFeesRequest {
send_amount_sat: Some(50000),
})
.await?;
info!("Total estimated fees for reverse swap: {:?}", current_fees.total_estimated_fees);
Ok(())
}
async fn list_current_fees(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo) -> Result<()> {
info!("Minimum amount, in sats: {}", current_fees.min);
info!("Maximum amount, in sats: {}", current_fees.max);
Ok(())
}
async fn start_reverse_swap(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo, fee_rate: u64) -> Result<()> {
let destination_address = String::from("bc1..");
let amount_sat = current_fees.min;
let satPerVbyte = fee_rate;
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash, satPerVbyte).await?;
Ok(())
}
async fn check_reverse_swap_status(sdk: Arc<BreezServices>) -> Result<()> {
for rs in sdk.in_progress_reverse_swaps().await? {
info!("Reverse swap {} in progress, status is {:?}", rs.id, rs.status);
}
Ok(())
}

View File

@@ -0,0 +1,11 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn send_payment(sdk: Arc<BreezServices>) -> Result<()> {
let bolt11 = "...";
sdk.send_payment(bolt11.into(), None).await?;
Ok(())
}

View File

@@ -0,0 +1,11 @@
use std::sync::Arc;
use anyhow::Result;
use breez_sdk_core::*;
async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> {
let node_id = "...";
sdk.send_spontaneous_payment(node_id.into(), 3000).await?;
Ok(())
}

View File

@@ -0,0 +1,10 @@
use anyhow::Result;
use breez_sdk_core::*;
async fn retrieve_backup_files() -> Result<()> {
let backup_data = BreezServices::static_backup(StaticBackupRequest {
working_dir: "<working directory>".into(),
})?;
Ok(())
}

View File

@@ -12,11 +12,7 @@ Once the buy is completed, the provider will transfer the Bitcoin to the generat
<section> <section>
```rust,ignore ```rust,ignore
let res = sdk.buy_bitcoin( {{#include ../../snippets/rust/src/buy_btc.rs:7:11}}
BuyBitcoinRequest {
provider: BuyBitcoinProvider::Moonpay,
opening_fee_params: None})
.await?;
``` ```
</section> </section>

View File

@@ -7,8 +7,7 @@ Based on the API key provided to the Breez SDK, a default LSP is selected for yo
<section> <section>
```rust,ignore ```rust,ignore
let lsp_id = sdk.lsp_id().await?; {{#include ../../snippets/rust/src/connecting_lsp.rs:7:8}}
let lsp_info = sdk.lsp_info().await?;
``` ```
</section> </section>
@@ -118,7 +117,7 @@ When you have selected an LSP you may then connect to it.
<section> <section>
```rust,ignore ```rust,ignore
sdk.connect_lsp(lsp_id).await?; {{#include ../../snippets/rust/src/connecting_lsp.rs:14}}
``` ```
</section> </section>

View File

@@ -3,6 +3,14 @@
In order to list the available fiat currencies: In order to list the available fiat currencies:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:8}}
```
</section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
@@ -80,6 +88,14 @@ catch (Exception)
To get the current BTC rate for the currencies: To get the current BTC rate for the currencies:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:14}}
```
</section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>
@@ -159,6 +175,14 @@ catch (Exception)
At the example project you can see these methods combined: At the example project you can see these methods combined:
<custom-tabs category="lang"> <custom-tabs category="lang">
<div slot="title">Rust</div>
<section>
```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:20:39}}
```
</section>
<div slot="title">Android</div> <div slot="title">Android</div>
<section> <section>

View File

@@ -38,33 +38,7 @@ Now your SDK is ready to be used.
<section> <section>
```rust,ignore ```rust,ignore
let mnemonic = Mnemonic::generate_in(Language::English, 12)?; {{#include ../../snippets/rust/src/getting_started.rs:9:35}}
let seed = mnemonic.to_seed("");
let invite_code = Some("<invite code>".into());
let api_key = "<api key>".into()
// Create the default config
let mut config = BreezServices::default_config(
EnvironmentType::Production,
api_key,
breez_sdk_core::NodeConfig::Greenlight {
config: GreenlightNodeConfig {
partner_credentials: None,
invite_code
},
},
);
// Customize the config object according to your needs
config.working_dir = "path to an existing directory".into();
// Connect to the Breez SDK make it ready for use
let sdk = BreezServices::connect(
config,
seed.to_vec(),
Box::new(AppEventListener {}),
)
.await?;
``` ```
</section> </section>
@@ -322,10 +296,7 @@ At any point we can fetch our balance from the Greenlight node:
<section> <section>
```rust,ignore ```rust,ignore
if let Some(node_state) = sdk.node_info()? { {{#include ../../snippets/rust/src/getting_started.rs:41:44}}
let balance_ln = node_state.channels_balance_msat;
let balance_onchain = node_state.onchain_balance_msat;
}
``` ```
</section> </section>

View File

@@ -7,14 +7,7 @@ To view your payment history you can list and filter all the sent and received p
<section> <section>
```rust,ignore ```rust,ignore
let payments = sdk.list_payments( {{#include ../../snippets/rust/src/list_payments.rs:7:14}}
ListPaymentRequest {
filter: PaymentTypeFilter::All,
from_timestamp: None,
to_timestamp: None,
include_failures: None,
}
).await?;
``` ```
</section> </section>
@@ -112,14 +105,7 @@ You can optionally filter payments by timestamp and include failed payments.
<section> <section>
```rust,ignore ```rust,ignore
let payments = sdk.list_payments( {{#include ../../snippets/rust/src/list_payments.rs:20:27}}
ListPaymentRequest {
filter: PaymentTypeFilter::Sent,
from_timestamp: 1696880000,
to_timestamp: None,
include_failures: true,
}
).await?;
``` ```
</section> </section>

View File

@@ -6,23 +6,7 @@
<section> <section>
```rust,ignore ```rust,ignore
// Endpoint can also be of the form: {{#include ../../snippets/rust/src/lnurl_auth.rs:9:25}}
// keyauth://domain.com/auth?key=val
let lnurl_auth_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await {
match sdk.lnurl_auth(ad).await {
Ok(LnUrlCallbackStatus::Ok) => {
info!("Successfully authenticated")
}
Ok(LnUrlCallbackStatus::ErrorStatus { data }) => {
error!("Failed to authenticate: {}", data.reason)
}
Err(e) => {
error!("Failed to connect: {e}")
}
}
}
``` ```
</section> </section>

View File

@@ -7,18 +7,7 @@
<section> <section>
```rust,ignore ```rust,ignore
// Endpoint can also be of the form: {{#include ../../snippets/rust/src/lnurl_pay.rs:8:19}}
// lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
let lnurl_pay_url = "lightning@address.com";
if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await {
// TODO Show payment details in UI, read user input
let amount_msat = pd.min_sendable;
let comment = "Test payment".to_string();
sdk.lnurl_pay(amount_msat, Some(comment), pd).await?;
}
``` ```
</section> </section>

View File

@@ -8,16 +8,7 @@
<section> <section>
```rust,ignore ```rust,ignore
// Endpoint can also be of the form: {{#include ../../snippets/rust/src/lnurl_withdraw.rs:7:17}}
// lnurlw://domain.com/lnurl-withdraw?key=val
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await {
let amount_msat = wd.min_withdrawable;
let description = "Test withdraw".to_string();
sdk.lnurl_withdraw(wd, amount_msat, Some(description)).await?;
}
``` ```
</section> </section>

View File

@@ -10,12 +10,7 @@ In order to receive funds you first have to be connected to an [LSP](connecting_
<section> <section>
```rust,ignore ```rust,ignore
let swap_info = sdk.receive_onchain( {{#include ../../snippets/rust/src/receive_onchain.rs:7:12}}
ReceiveOnchainRequest { opening_fee_params: None } )
.await?;
// Send your funds to the below bitcoin address
let address = swap_info.bitcoin_address;
``` ```
</section> </section>
@@ -132,7 +127,7 @@ Once you've sent the funds to the above address, the SDK will monitor this addre
<section> <section>
```rust,ignore ```rust,ignore
let swap_info = sdk.in_progress_swap().await? {{#include ../../snippets/rust/src/receive_onchain.rs:18}}
``` ```
</section> </section>
@@ -233,7 +228,7 @@ In order to execute a refund, you need to supply an on-chain address to where th
<section> <section>
```rust,ignore ```rust,ignore
let refundables = sdk.list_refundables().await? {{#include ../../snippets/rust/src/receive_onchain.rs:24}}
``` ```
</section> </section>
@@ -329,9 +324,7 @@ Once you have a refundable swap in hand, use the following code to execute a ref
<section> <section>
```rust,ignore ```rust,ignore
let destination_address = "...".into() {{#include ../../snippets/rust/src/receive_onchain.rs:30:32}}
let sat_per_vbyte = <refund tx fee rate>
sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?
``` ```
</section> </section>
@@ -460,10 +453,7 @@ To calculate the fees for a channel being opened by the LSP:
<section> <section>
```rust,ignore ```rust,ignore
let amount_msat = <amount msat>; {{#include ../../snippets/rust/src/receive_onchain.rs:38:40}}
let channel_fees = sdk.open_channel_fee(
OpenChannelFeeRequest { amount_msat, expiry: None })
.await?;
``` ```
</section> </section>

View File

@@ -8,17 +8,7 @@ The Breez SDK automatically connects your node to the LSP peer and you can now r
<section> <section>
```rust,ignore ```rust,ignore
let res = sdk.receive_payment( {{#include ../../snippets/rust/src/receive_payment.rs:7:17}}
ReceivePaymentRequest {
amount_sats: 3000,
description: "Invoice for 3000 sats".into(),
cltv: None,
expiry: None,
opening_fee_params: None,
preimage: None,
use_description_hash: None
})
.await?;
``` ```
</section> </section>

View File

@@ -9,13 +9,7 @@ First, fetch the current reverse swap fees:
<section> <section>
```rust,ignore ```rust,ignore
let current_fees = sdk.fetch_reverse_swap_fees( {{#include ../../snippets/rust/src/send_onchain.rs:8:14}}
ReverseSwapFeesRequest {
send_amount_sat: Some(50000),
})
.await?;
info!("Total estimated fees for reverse swap: {}", current_fees.total_estimated_fees);
``` ```
</section> </section>
@@ -135,8 +129,7 @@ Fetching the fees also tells you what is the range of amounts you can send:
<section> <section>
```rust,ignore ```rust,ignore
info!("Minimum amount, in sats: {}", current_fees.min); {{#include ../../snippets/rust/src/send_onchain.rs:20:21}}
info!("Maximum amount, in sats: {}", current_fees.max);
``` ```
</section> </section>
@@ -211,11 +204,7 @@ Once you checked the fees are acceptable, you can start the reverse swap:
<section> <section>
```rust,ignore ```rust,ignore
let destination_address = String::from("bc1.."); {{#include ../../snippets/rust/src/send_onchain.rs:27:31}}
let amount_sat = current_fees.min;
let satPerVbyte = <fee rate>;
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash, satPerVbyte).await?;
``` ```
</section> </section>
@@ -352,9 +341,7 @@ You can check its status with:
<section> <section>
```rust,ignore ```rust,ignore
for rs in sdk.in_progress_reverse_swaps().await? { {{#include ../../snippets/rust/src/send_onchain.rs:37:40}}
info!("Reverse swap {} in progress, status is {}", rs.id, rs.status);
}
``` ```
</section> </section>

View File

@@ -7,8 +7,7 @@ Once you have outbound liquidity you can start sending payments too.
<section> <section>
```rust,ignore ```rust,ignore
let bolt11 = "..."; {{#include ../../snippets/rust/src/send_payment.rs:7:8}}
sdk.send_payment(bolt11.into(), None).await?;
``` ```
</section> </section>

View File

@@ -7,8 +7,7 @@ They can even be spontaneous payments to a node without a bolt11 invoice.
<section> <section>
```rust,ignore ```rust,ignore
let node_id = "..."; {{#include ../../snippets/rust/src/send_spontaneous_payment.rs:7:8}}
sdk.send_spontaneous_payment(node_id.into(), 3000).await?;
``` ```
</section> </section>

View File

@@ -12,9 +12,7 @@ In order to use the recoverchannel method, the user needs to provide the static
<section> <section>
```rust,ignore ```rust,ignore
let backup_data = BreezServices::static_backup(StaticBackupRequest { {{#include ../../snippets/rust/src/static_channel_backup.rs:5:7}}
working_dir: "<working directory>".into(),
})?;
``` ```
</section> </section>