Use snippet anchor instead of line range

This commit is contained in:
ok300
2023-10-23 16:52:13 +02:00
parent 32c39e2543
commit 1caf35a802
28 changed files with 80 additions and 28 deletions

View File

@@ -4,11 +4,13 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn buy(sdk: Arc<BreezServices>) -> Result<()> { async fn buy(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: buy-btc
let res = sdk.buy_bitcoin( let res = sdk.buy_bitcoin(
BuyBitcoinRequest { BuyBitcoinRequest {
provider: BuyBitcoinProvider::Moonpay, provider: BuyBitcoinProvider::Moonpay,
opening_fee_params: None}) opening_fee_params: None})
.await?; .await?;
// ANCHOR_END: buy-btc
Ok(()) Ok(())
} }

View File

@@ -4,14 +4,18 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn get_lsp_info(sdk: Arc<BreezServices>) -> Result<LspInformation> { async fn get_lsp_info(sdk: Arc<BreezServices>) -> Result<LspInformation> {
// ANCHOR: get-lsp-info
let lsp_id = sdk.lsp_id().await?; let lsp_id = sdk.lsp_id().await?;
let lsp_info = sdk.lsp_info().await?; let lsp_info = sdk.lsp_info().await?;
// ANCHOR_END: get-lsp-info
Ok(lsp_info) Ok(lsp_info)
} }
async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> { async fn connect_lsp(sdk: Arc<BreezServices>, lsp_id: String) -> Result<()> {
// ANCHOR: connect-lsp
sdk.connect_lsp(lsp_id).await?; sdk.connect_lsp(lsp_id).await?;
// ANCHOR_END: connect-lsp
Ok(()) Ok(())
} }

View File

@@ -5,18 +5,23 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn list_supported_fiat_currencies(sdk: Arc<BreezServices>) -> Result<()> { async fn list_supported_fiat_currencies(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: list-fiat-currencies
let supported_fiat_currencies = sdk.list_fiat_currencies().await?; let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
// ANCHOR_END: list-fiat-currencies
Ok(()) Ok(())
} }
async fn get_current_rates(sdk: Arc<BreezServices>) -> Result<()> { async fn get_current_rates(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: fetch-fiat-rates
let fiat_rates = sdk.fetch_fiat_rates().await?; let fiat_rates = sdk.fetch_fiat_rates().await?;
// ANCHOR_END: fetch-fiat-rates
Ok(()) Ok(())
} }
async fn get_fiat_currencies_and_rates(sdk: Arc<BreezServices>) -> Result<Vec<(FiatCurrency, Rate)>> { async fn get_fiat_currencies_and_rates(sdk: Arc<BreezServices>) -> Result<Vec<(FiatCurrency, Rate)>> {
// ANCHOR: get-fiat-currencies-and-rates
let supported_fiat_currencies = sdk.list_fiat_currencies().await?; let supported_fiat_currencies = sdk.list_fiat_currencies().await?;
let fiat_rates = sdk.fetch_fiat_rates().await?; let fiat_rates = sdk.fetch_fiat_rates().await?;
@@ -37,4 +42,5 @@ async fn get_fiat_currencies_and_rates(sdk: Arc<BreezServices>) -> Result<Vec<(F
} }
Ok(result) Ok(result)
// ANCHOR_END: get-fiat-currencies-and-rates
} }

View File

@@ -6,6 +6,7 @@ use std::sync::Arc;
use crate::AppEventListener; use crate::AppEventListener;
async fn getting_started() -> Result<Arc<BreezServices>> { async fn getting_started() -> Result<Arc<BreezServices>> {
// ANCHOR: init-sdk
let mnemonic = Mnemonic::generate_in(Language::English, 12)?; let mnemonic = Mnemonic::generate_in(Language::English, 12)?;
let seed = mnemonic.to_seed(""); let seed = mnemonic.to_seed("");
let invite_code = Some("<invite code>".into()); let invite_code = Some("<invite code>".into());
@@ -33,15 +34,18 @@ async fn getting_started() -> Result<Arc<BreezServices>> {
Box::new(AppEventListener {}), Box::new(AppEventListener {}),
) )
.await?; .await?;
// ANCHOR_END: init-sdk
Ok(sdk) Ok(sdk)
} }
async fn getting_started_node_info(sdk: Arc<BreezServices>) -> Result<()> { async fn getting_started_node_info(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: fetch-balance
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;
} }
// ANCHOR_END: fetch-balance
Ok(()) Ok(())
} }

View File

@@ -4,6 +4,7 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn list_payments(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> { async fn list_payments(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
// ANCHOR: list-payments
let payments = sdk.list_payments( let payments = sdk.list_payments(
ListPaymentRequest { ListPaymentRequest {
filter: PaymentTypeFilter::All, filter: PaymentTypeFilter::All,
@@ -12,11 +13,13 @@ async fn list_payments(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
include_failures: None, include_failures: None,
} }
).await?; ).await?;
// ANCHOR_END: list-payments
Ok(payments) Ok(payments)
} }
async fn list_payments_filtered(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> { async fn list_payments_filtered(sdk: Arc<BreezServices>) -> Result<Vec<Payment>> {
// ANCHOR: list-payments-filtered
let payments = sdk.list_payments( let payments = sdk.list_payments(
ListPaymentRequest { ListPaymentRequest {
filter: PaymentTypeFilter::Sent, filter: PaymentTypeFilter::Sent,
@@ -25,6 +28,7 @@ async fn list_payments_filtered(sdk: Arc<BreezServices>) -> Result<Vec<Payment>>
include_failures: true, include_failures: true,
} }
).await?; ).await?;
// ANCHOR_END: list-payments-filtered
Ok(payments) Ok(payments)
} }

View File

@@ -6,6 +6,7 @@ use breez_sdk_core::InputType::LnUrlAuth;
use log::{error, info}; use log::{error, info};
async fn auth(sdk: Arc<BreezServices>) -> Result<()> { async fn auth(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: lnurl-auth
// Endpoint can also be of the form: // Endpoint can also be of the form:
// keyauth://domain.com/auth?key=val // keyauth://domain.com/auth?key=val
let lnurl_auth_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"; let lnurl_auth_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
@@ -23,6 +24,7 @@ async fn auth(sdk: Arc<BreezServices>) -> Result<()> {
} }
} }
} }
// ANCHOR_END: lnurl-auth
Ok(()) Ok(())
} }

View File

@@ -5,6 +5,7 @@ use breez_sdk_core::*;
use breez_sdk_core::InputType::LnUrlPay; use breez_sdk_core::InputType::LnUrlPay;
async fn pay(sdk: Arc<BreezServices>) -> Result<()> { async fn pay(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: lnurl-pay
// Endpoint can also be of the form: // Endpoint can also be of the form:
// lnurlp://domain.com/lnurl-pay?key=val // lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf // lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
@@ -17,6 +18,7 @@ async fn pay(sdk: Arc<BreezServices>) -> Result<()> {
sdk.lnurl_pay(amount_msat, Some(comment), pd).await?; sdk.lnurl_pay(amount_msat, Some(comment), pd).await?;
} }
// ANCHOR_END: lnurl-pay
Ok(()) Ok(())
} }

View File

@@ -4,6 +4,7 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn withdraw(sdk: Arc<BreezServices>) -> Result<()> { async fn withdraw(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: lnurl-withdraw
// Endpoint can also be of the form: // Endpoint can also be of the form:
// lnurlw://domain.com/lnurl-withdraw?key=val // lnurlw://domain.com/lnurl-withdraw?key=val
let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"; let lnurl_withdraw_url = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
@@ -14,6 +15,7 @@ async fn withdraw(sdk: Arc<BreezServices>) -> Result<()> {
sdk.lnurl_withdraw(wd, amount_msat, Some(description)).await?; sdk.lnurl_withdraw(wd, amount_msat, Some(description)).await?;
} }
// ANCHOR_END: lnurl-withdraw
Ok(()) Ok(())
} }

View File

@@ -4,40 +4,50 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()> { async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: generate-receive-onchain-address
let swap_info = sdk.receive_onchain( let swap_info = sdk.receive_onchain(
ReceiveOnchainRequest { opening_fee_params: None } ) ReceiveOnchainRequest { opening_fee_params: None } )
.await?; .await?;
// Send your funds to the below bitcoin address // Send your funds to the below bitcoin address
let address = swap_info.bitcoin_address; let address = swap_info.bitcoin_address;
// ANCHOR_END: generate-receive-onchain-address
Ok(()) Ok(())
} }
async fn get_in_progress_swap(sdk: Arc<BreezServices>) -> Result<()> { async fn get_in_progress_swap(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: in-progress-swap
let swap_info = sdk.in_progress_swap().await?; let swap_info = sdk.in_progress_swap().await?;
// ANCHOR_END: in-progress-swap
Ok(()) Ok(())
} }
async fn list_refundables(sdk: Arc<BreezServices>) -> Result<()> { async fn list_refundables(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: list-refundables
let refundables = sdk.list_refundables().await?; let refundables = sdk.list_refundables().await?;
// ANCHOR_END: list-refundables
Ok(()) Ok(())
} }
async fn execute_refund(sdk: Arc<BreezServices>, refund_tx_fee_rate: u32, refundable: SwapInfo) -> Result<()> { async fn execute_refund(sdk: Arc<BreezServices>, refund_tx_fee_rate: u32, refundable: SwapInfo) -> Result<()> {
// ANCHOR: execute-refund
let destination_address = "...".into(); let destination_address = "...".into();
let sat_per_vbyte = refund_tx_fee_rate; let sat_per_vbyte = refund_tx_fee_rate;
sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?; sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await?;
// ANCHOR_END: execute-refund
Ok(()) Ok(())
} }
async fn get_channel_opening_fees(sdk: Arc<BreezServices>, amount_msat: u64) -> Result<()> { async fn get_channel_opening_fees(sdk: Arc<BreezServices>, amount_msat: u64) -> Result<()> {
// ANCHOR: get-channel-opening-fees
let channel_fees = sdk.open_channel_fee( let channel_fees = sdk.open_channel_fee(
OpenChannelFeeRequest { amount_msat, expiry: None }) OpenChannelFeeRequest { amount_msat, expiry: None })
.await?; .await?;
// ANCHOR_END: get-channel-opening-fees
Ok(()) Ok(())
} }

View File

@@ -4,6 +4,7 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> { async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: receive-payment
let res = sdk.receive_payment( let res = sdk.receive_payment(
ReceivePaymentRequest { ReceivePaymentRequest {
amount_sats: 3000, amount_sats: 3000,
@@ -15,6 +16,7 @@ async fn receive_payment(sdk: Arc<BreezServices>) -> Result<()> {
use_description_hash: None use_description_hash: None
}) })
.await?; .await?;
// ANCHOR_END: receive-payment
Ok(()) Ok(())
} }

View File

@@ -5,28 +5,34 @@ use breez_sdk_core::*;
use log::info; use log::info;
async fn get_current_fees(sdk: Arc<BreezServices>) -> Result<()> { async fn get_current_fees(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: estimate-current-reverse-swap-total-fees
let current_fees = sdk.fetch_reverse_swap_fees( let current_fees = sdk.fetch_reverse_swap_fees(
ReverseSwapFeesRequest { ReverseSwapFeesRequest {
send_amount_sat: Some(50000), send_amount_sat: Some(50_000),
}) })
.await?; .await?;
info!("Total estimated fees for reverse swap: {:?}", current_fees.total_estimated_fees); info!("Total estimated fees for reverse swap: {:?}", current_fees.total_estimated_fees);
// ANCHOR_END: estimate-current-reverse-swap-total-fees
Ok(()) Ok(())
} }
async fn list_current_fees(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo) -> Result<()> { async fn list_current_fees(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo) -> Result<()> {
// ANCHOR: get-current-reverse-swap-min-max
info!("Minimum amount, in sats: {}", current_fees.min); info!("Minimum amount, in sats: {}", current_fees.min);
info!("Maximum amount, in sats: {}", current_fees.max); info!("Maximum amount, in sats: {}", current_fees.max);
// ANCHOR_END: get-current-reverse-swap-min-max
Ok(()) Ok(())
} }
async fn start_reverse_swap(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo, fee_rate: u64) -> Result<()> { async fn start_reverse_swap(sdk: Arc<BreezServices>, current_fees: ReverseSwapPairInfo, fee_rate: u64) -> Result<()> {
// ANCHOR: start-reverse-swap
let destination_address = String::from("bc1.."); let destination_address = String::from("bc1..");
let amount_sat = current_fees.min; let amount_sat = current_fees.min;
let satPerVbyte = fee_rate; let satPerVbyte = fee_rate;
// ANCHOR_END: start-reverse-swap
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash, satPerVbyte).await?; sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash, satPerVbyte).await?;
@@ -34,9 +40,11 @@ async fn start_reverse_swap(sdk: Arc<BreezServices>, current_fees: ReverseSwapPa
} }
async fn check_reverse_swap_status(sdk: Arc<BreezServices>) -> Result<()> { async fn check_reverse_swap_status(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: check-reverse-swaps-status
for rs in sdk.in_progress_reverse_swaps().await? { for rs in sdk.in_progress_reverse_swaps().await? {
info!("Reverse swap {} in progress, status is {:?}", rs.id, rs.status); info!("Reverse swap {} in progress, status is {:?}", rs.id, rs.status);
} }
// ANCHOR_END: check-reverse-swaps-status
Ok(()) Ok(())
} }

View File

@@ -4,8 +4,10 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn send_payment(sdk: Arc<BreezServices>) -> Result<()> { async fn send_payment(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: send-payment
let bolt11 = "..."; let bolt11 = "...";
sdk.send_payment(bolt11.into(), None).await?; sdk.send_payment(bolt11.into(), None).await?;
// ANCHOR_END: send-payment
Ok(()) Ok(())
} }

View File

@@ -4,8 +4,10 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> { async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: send-spontaneous-payment
let node_id = "..."; let node_id = "...";
sdk.send_spontaneous_payment(node_id.into(), 3000).await?; sdk.send_spontaneous_payment(node_id.into(), 3000).await?;
// ANCHOR_END: send-spontaneous-payment
Ok(()) Ok(())
} }

View File

@@ -2,9 +2,11 @@ use anyhow::Result;
use breez_sdk_core::*; use breez_sdk_core::*;
async fn retrieve_backup_files() -> Result<()> { async fn retrieve_backup_files() -> Result<()> {
// ANCHOR: static-channel-backup
let backup_data = BreezServices::static_backup(StaticBackupRequest { let backup_data = BreezServices::static_backup(StaticBackupRequest {
working_dir: "<working directory>".into(), working_dir: "<working directory>".into(),
})?; })?;
// ANCHOR_END: static-channel-backup
Ok(()) Ok(())
} }

View File

@@ -12,7 +12,7 @@ Once the buy is completed, the provider will transfer the Bitcoin to the generat
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/buy_btc.rs:7:11}} {{#include ../../snippets/rust/src/buy_btc.rs:buy-btc}}
``` ```
</section> </section>

View File

@@ -7,7 +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
{{#include ../../snippets/rust/src/connecting_lsp.rs:7:8}} {{#include ../../snippets/rust/src/connecting_lsp.rs:get-lsp-info}}
``` ```
</section> </section>
@@ -117,7 +117,7 @@ When you have selected an LSP you may then connect to it.
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/connecting_lsp.rs:14}} {{#include ../../snippets/rust/src/connecting_lsp.rs:connect-lsp}}
``` ```
</section> </section>

View File

@@ -7,7 +7,7 @@ In order to list the available fiat currencies:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:8}} {{#include ../../snippets/rust/src/fiat_currencies.rs:list-fiat-currencies}}
``` ```
</section> </section>
@@ -92,7 +92,7 @@ To get the current BTC rate for the currencies:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:14}} {{#include ../../snippets/rust/src/fiat_currencies.rs:fetch-fiat-rates}}
``` ```
</section> </section>
@@ -179,7 +179,7 @@ At the example project you can see these methods combined:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/fiat_currencies.rs:20:39}} {{#include ../../snippets/rust/src/fiat_currencies.rs:get-fiat-currencies-and-rates}}
``` ```
</section> </section>

View File

@@ -38,7 +38,7 @@ Now your SDK is ready to be used.
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/getting_started.rs:9:35}} {{#include ../../snippets/rust/src/getting_started.rs:init-sdk}}
``` ```
</section> </section>
@@ -296,7 +296,7 @@ At any point we can fetch our balance from the Greenlight node:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/getting_started.rs:41:44}} {{#include ../../snippets/rust/src/getting_started.rs:fetch-balance}}
``` ```
</section> </section>

View File

@@ -7,7 +7,7 @@ To view your payment history you can list and filter all the sent and received p
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/list_payments.rs:7:14}} {{#include ../../snippets/rust/src/list_payments.rs:list-payments}}
``` ```
</section> </section>
@@ -105,7 +105,7 @@ You can optionally filter payments by timestamp and include failed payments.
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/list_payments.rs:20:27}} {{#include ../../snippets/rust/src/list_payments.rs:list-payments-filtered}}
``` ```
</section> </section>

View File

@@ -6,7 +6,7 @@
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/lnurl_auth.rs:9:25}} {{#include ../../snippets/rust/src/lnurl_auth.rs:lnurl-auth}}
``` ```
</section> </section>

View File

@@ -7,7 +7,7 @@
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/lnurl_pay.rs:8:19}} {{#include ../../snippets/rust/src/lnurl_pay.rs:lnurl-pay}}
``` ```
</section> </section>

View File

@@ -8,7 +8,7 @@
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/lnurl_withdraw.rs:7:17}} {{#include ../../snippets/rust/src/lnurl_withdraw.rs:lnurl-withdraw}}
``` ```
</section> </section>

View File

@@ -10,7 +10,7 @@ In order to receive funds you first have to be connected to an [LSP](connecting_
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/receive_onchain.rs:7:12}} {{#include ../../snippets/rust/src/receive_onchain.rs:generate-receive-onchain-address}}
``` ```
</section> </section>
@@ -127,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
{{#include ../../snippets/rust/src/receive_onchain.rs:18}} {{#include ../../snippets/rust/src/receive_onchain.rs:in-progress-swap}}
``` ```
</section> </section>
@@ -228,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
{{#include ../../snippets/rust/src/receive_onchain.rs:24}} {{#include ../../snippets/rust/src/receive_onchain.rs:list-refundables}}
``` ```
</section> </section>
@@ -324,7 +324,7 @@ Once you have a refundable swap in hand, use the following code to execute a ref
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/receive_onchain.rs:30:32}} {{#include ../../snippets/rust/src/receive_onchain.rs:execute-refund}}
``` ```
</section> </section>
@@ -453,7 +453,7 @@ To calculate the fees for a channel being opened by the LSP:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/receive_onchain.rs:38:40}} {{#include ../../snippets/rust/src/receive_onchain.rs:get-channel-opening-fees}}
``` ```
</section> </section>

View File

@@ -1,6 +1,6 @@
# Receiving Lightning Payments # Receiving Lightning Payments
With the Breez SDK you arn't required to open a channel and set up your inbound liquidity. With the Breez SDK you aren't required to open a channel and set up your inbound liquidity.
The Breez SDK automatically connects your node to the LSP peer and you can now receive payments. The Breez SDK automatically connects your node to the LSP peer and you can now receive payments.
<custom-tabs category="lang"> <custom-tabs category="lang">
@@ -8,7 +8,7 @@ The Breez SDK automatically connects your node to the LSP peer and you can now r
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/receive_payment.rs:7:17}} {{#include ../../snippets/rust/src/receive_payment.rs:receive-payment}}
``` ```
</section> </section>

View File

@@ -9,7 +9,7 @@ First, fetch the current reverse swap fees:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_onchain.rs:8:14}} {{#include ../../snippets/rust/src/send_onchain.rs:estimate-current-reverse-swap-total-fees}}
``` ```
</section> </section>
@@ -129,7 +129,7 @@ Fetching the fees also tells you what is the range of amounts you can send:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_onchain.rs:20:21}} {{#include ../../snippets/rust/src/send_onchain.rs:get-current-reverse-swap-min-max}}
``` ```
</section> </section>
@@ -204,7 +204,7 @@ Once you checked the fees are acceptable, you can start the reverse swap:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_onchain.rs:27:31}} {{#include ../../snippets/rust/src/send_onchain.rs:start-reverse-swap}}
``` ```
</section> </section>
@@ -341,7 +341,7 @@ You can check its status with:
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_onchain.rs:37:40}} {{#include ../../snippets/rust/src/send_onchain.rs:check-reverse-swaps-status}}
``` ```
</section> </section>

View File

@@ -7,7 +7,7 @@ Once you have outbound liquidity you can start sending payments too.
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_payment.rs:7:8}} {{#include ../../snippets/rust/src/send_payment.rs:send-payment}}
``` ```
</section> </section>

View File

@@ -7,7 +7,7 @@ They can even be spontaneous payments to a node without a bolt11 invoice.
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/send_spontaneous_payment.rs:7:8}} {{#include ../../snippets/rust/src/send_spontaneous_payment.rs:send-spontaneous-payment}}
``` ```
</section> </section>

View File

@@ -12,7 +12,7 @@ In order to use the recoverchannel method, the user needs to provide the static
<section> <section>
```rust,ignore ```rust,ignore
{{#include ../../snippets/rust/src/static_channel_backup.rs:5:7}} {{#include ../../snippets/rust/src/static_channel_backup.rs:static-channel-backup}}
``` ```
</section> </section>