mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 22:04:21 +01:00
Add examples for adding extra TLVs to a spontaneous payment
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
|
||||
|
||||
fn production_node_config() -> Result<NodeConfig> {
|
||||
// ANCHOR: moving-to-production
|
||||
// Read your Greenlight credentials from secure storage
|
||||
let device_key: Vec<u8> = vec![];
|
||||
let device_cert: Vec<u8> = vec![];
|
||||
let greenlight_credentials = GreenlightCredentials {
|
||||
device_key,
|
||||
device_key,
|
||||
device_cert,
|
||||
};
|
||||
|
||||
|
||||
@@ -12,8 +12,14 @@ async fn generate_receive_onchain_address(sdk: Arc<BreezServices>) -> Result<()>
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
let address = swap_info.bitcoin_address;
|
||||
info!("Minimum amount allowed to deposit in sats: {}", swap_info.min_allowed_deposit);
|
||||
info!("Maximum amount allowed to deposit in sats: {}", swap_info.max_allowed_deposit);
|
||||
info!(
|
||||
"Minimum amount allowed to deposit in sats: {}",
|
||||
swap_info.min_allowed_deposit
|
||||
);
|
||||
info!(
|
||||
"Maximum amount allowed to deposit in sats: {}",
|
||||
swap_info.max_allowed_deposit
|
||||
);
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -32,14 +32,9 @@ async fn list_current_fees(current_fees: ReverseSwapPairInfo) -> Result<()> {
|
||||
|
||||
async fn max_reverse_swap_amount(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: max-reverse-swap-amount
|
||||
let max_amount = sdk
|
||||
.max_reverse_swap_amount()
|
||||
.await?;
|
||||
let max_amount = sdk.max_reverse_swap_amount().await?;
|
||||
|
||||
info!(
|
||||
"Max reverse swap amount: {:?}",
|
||||
max_amount.total_sat
|
||||
);
|
||||
info!("Max reverse swap amount: {:?}", max_amount.total_sat);
|
||||
// ANCHOR_END: max-reverse-swap-amount
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -10,9 +10,29 @@ async fn send_spontaneous_payment(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
sdk.send_spontaneous_payment(SendSpontaneousPaymentRequest {
|
||||
amount_msat: 3_000_000,
|
||||
node_id,
|
||||
extra_tlvs: None,
|
||||
})
|
||||
.await?;
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn send_spontaneous_payment_with_tlvs(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: send-spontaneous-payment-with-tlvs
|
||||
let node_id = "...".into();
|
||||
let extra_tlvs = vec![TlvEntry {
|
||||
field_number: 34349334,
|
||||
value: "Hello world!".as_bytes().to_vec(),
|
||||
}];
|
||||
|
||||
sdk.send_spontaneous_payment(SendSpontaneousPaymentRequest {
|
||||
amount_msat: 3_000_000,
|
||||
node_id,
|
||||
extra_tlvs: Some(extra_tlvs),
|
||||
})
|
||||
.await?;
|
||||
// ANCHOR_END: send-spontaneous-payment-with-tlvs
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
use std::sync::Arc;
|
||||
use anyhow::Result;
|
||||
use breez_sdk_core::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
async fn webhook(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: register-webook
|
||||
sdk.register_webhook("https://yourapplication.com".to_string()).await?;
|
||||
sdk.register_webhook("https://yourapplication.com".to_string())
|
||||
.await?;
|
||||
// ANCHOR_END: register-webook
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn payment_webhook(sdk: Arc<BreezServices>) -> Result<()> {
|
||||
// ANCHOR: register-payment-webook
|
||||
sdk.register_webhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string()).await?;
|
||||
// ANCHOR_END: register-payment-webook
|
||||
// ANCHOR: register-payment-webook
|
||||
sdk.register_webhook(
|
||||
"https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>".to_string(),
|
||||
)
|
||||
.await?;
|
||||
// ANCHOR_END: register-payment-webook
|
||||
|
||||
Ok(())
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user