mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 22:04:21 +01:00
Update rust examples
This commit is contained in:
@@ -7,10 +7,13 @@ This section of the Breez SDK documentation provides an example on purchasing Bi
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust
|
||||
// TODO add docs
|
||||
```rust,ignore
|
||||
let res = sdk.buy_bitcoin(
|
||||
BuyBitcoinRequest {
|
||||
provider: BuyBitcoinProvider::Moonpay,
|
||||
opening_fee_params: None})
|
||||
.await?;
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
<div slot="title">Swift</div>
|
||||
@@ -23,7 +26,6 @@ do {
|
||||
} catch {
|
||||
// handle error
|
||||
}
|
||||
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -59,7 +61,6 @@ try {
|
||||
} catch {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -93,4 +94,5 @@ buyBitcoinResponse, err := sdkService.BuyBitcoin(breez_sdk.BuyBitcoinRequest{
|
||||
```cs
|
||||
// TODO add docs
|
||||
```
|
||||
</section>
|
||||
</section>
|
||||
</custom-tabs>
|
||||
@@ -3,6 +3,15 @@
|
||||
Based on the API key provided to the Breez SDK, a default LSP is selected for your node to provide liquidity to it. To get the information about the selected LSP you can do the following:
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
let lsp_id = sdk.lsp_id().await?;
|
||||
let lsp_info = sdk.lsp_info().await?;
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Swift</div>
|
||||
<section>
|
||||
|
||||
@@ -107,6 +116,14 @@ catch (Exception)
|
||||
When you have selected an LSP you may then connect to it.
|
||||
|
||||
<custom-tabs category="lang">
|
||||
<div slot="title">Rust</div>
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
sdk.connect_lsp(lsp_id).await?;
|
||||
```
|
||||
</section>
|
||||
|
||||
<div slot="title">Swift</div>
|
||||
<section>
|
||||
|
||||
|
||||
@@ -10,7 +10,17 @@ Breez SDK automatically connects your node to the LSP peer and you can now recei
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
let invoice = sdk.receive_payment(3000, "Invoice for 3000 sats".into()).await?;
|
||||
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?;
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -122,7 +132,7 @@ catch (Exception)
|
||||
|
||||
```rust,ignore
|
||||
let bolt11 = "...";
|
||||
sdk.send_payment(bolt11.into(), Some(3000)).await?;
|
||||
sdk.send_payment(bolt11.into(), None).await?;
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ In order to receive funds you first have to be connected to an [LSP](connecting_
|
||||
<section>
|
||||
|
||||
```rust,ignore
|
||||
// Optional user-selected dynamic fees (see Connecting to LSP section for details)
|
||||
let opening_fee_params = None;
|
||||
|
||||
let swap_info = sdk.receive_onchain( ReceiveOnchainRequest { opening_fee_params } ).await?;
|
||||
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;
|
||||
|
||||
@@ -12,7 +12,6 @@ First, fetch the current reverse swap fees:
|
||||
let current_fees = sdk.fetch_reverse_swap_fees().await?;
|
||||
|
||||
info!("Total estimated fees for reverse swap: {}", current_fees.total_estimated_fees);
|
||||
|
||||
```
|
||||
</section>
|
||||
|
||||
@@ -203,8 +202,9 @@ 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;
|
||||
let satPerVbyte = <fee rate>;
|
||||
|
||||
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash).await?;
|
||||
sdk.send_onchain(amount_sat, destination_address, current_fees.fees_hash, satPerVbyte).await?;
|
||||
```
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user