diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index bc1607c1d..fae0b2608 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -602,7 +602,7 @@ dictionary PrepareOnchainPaymentResponse { f64 fees_percentage; u64 fees_lockup; u64 fees_claim; - + u64 fees_service; u64 sender_amount_sat; u64 recipient_amount_sat; u64 total_fees; @@ -615,6 +615,10 @@ dictionary ReverseSwapInfo { string? claim_txid; u64 onchain_amount_sat; ReverseSwapStatus status; + u64 fees_lockup; + u64 fees_claim; + u64 fees_service; + u64 total_fees; }; dictionary BitcoinAddressData { @@ -791,26 +795,11 @@ dictionary SendPaymentResponse { Payment payment; }; -dictionary MaxReverseSwapAmountResponse { - u64 total_sat; -}; - -dictionary SendOnchainRequest { - u64 amount_sat; - string onchain_recipient_address; - string pair_hash; - u32 sat_per_vbyte; -}; - dictionary PayOnchainRequest { string recipient_address; PrepareOnchainPaymentResponse prepare_res; }; -dictionary SendOnchainResponse { - ReverseSwapInfo reverse_swap_info; -}; - dictionary PayOnchainResponse { ReverseSwapInfo reverse_swap_info; }; @@ -964,18 +953,9 @@ interface BlockingBreezServices { [Throws=SdkError] sequence in_progress_onchain_payments(); - [Throws=SdkError] - sequence in_progress_reverse_swaps(); - [Throws=SdkError] void claim_reverse_swap(string lockup_address); - [Throws=SdkError] - MaxReverseSwapAmountResponse max_reverse_swap_amount(); - - [Throws=SendOnchainError] - SendOnchainResponse send_onchain(SendOnchainRequest req); - [Throws=SendOnchainError] PayOnchainResponse pay_onchain(PayOnchainRequest req); diff --git a/libs/sdk-bindings/src/uniffi_binding.rs b/libs/sdk-bindings/src/uniffi_binding.rs index ad6ac66ec..bcf0e11be 100644 --- a/libs/sdk-bindings/src/uniffi_binding.rs +++ b/libs/sdk-bindings/src/uniffi_binding.rs @@ -14,22 +14,21 @@ use breez_sdk_core::{ LnPaymentDetails, LnUrlAuthError, LnUrlAuthRequestData, LnUrlCallbackStatus, LnUrlErrorData, LnUrlPayError, LnUrlPayErrorData, LnUrlPayRequest, LnUrlPayRequestData, LnUrlWithdrawError, LnUrlWithdrawRequest, LnUrlWithdrawRequestData, LnUrlWithdrawResult, LnUrlWithdrawSuccessData, - LocaleOverrides, LocalizedName, LogEntry, LogStream, LspInformation, - MaxReverseSwapAmountResponse, MessageSuccessActionData, MetadataFilter, MetadataItem, Network, - NodeConfig, NodeCredentials, NodeState, OnchainPaymentLimitsResponse, OpenChannelFeeRequest, - OpenChannelFeeResponse, OpeningFeeParams, OpeningFeeParamsMenu, PayOnchainRequest, - PayOnchainResponse, Payment, PaymentDetails, PaymentFailedData, PaymentStatus, PaymentType, - PaymentTypeFilter, PrepareOnchainPaymentRequest, PrepareOnchainPaymentResponse, - PrepareRedeemOnchainFundsRequest, PrepareRedeemOnchainFundsResponse, PrepareRefundRequest, - PrepareRefundResponse, Rate, ReceiveOnchainRequest, ReceivePaymentRequest, - ReceivePaymentResponse, RecommendedFees, RedeemOnchainFundsRequest, RedeemOnchainFundsResponse, - RefundRequest, RefundResponse, ReportIssueRequest, ReportPaymentFailureDetails, - ReverseSwapFeesRequest, ReverseSwapInfo, ReverseSwapPairInfo, ReverseSwapStatus, RouteHint, - RouteHintHop, SendOnchainRequest, SendOnchainResponse, SendPaymentRequest, SendPaymentResponse, - SendSpontaneousPaymentRequest, ServiceHealthCheckResponse, SignMessageRequest, - SignMessageResponse, StaticBackupRequest, StaticBackupResponse, SuccessActionProcessed, - SwapAmountType, SwapInfo, SwapStatus, Symbol, TlvEntry, UnspentTransactionOutput, - UrlSuccessActionData, + LocaleOverrides, LocalizedName, LogEntry, LogStream, LspInformation, MessageSuccessActionData, + MetadataFilter, MetadataItem, Network, NodeConfig, NodeCredentials, NodeState, + OnchainPaymentLimitsResponse, OpenChannelFeeRequest, OpenChannelFeeResponse, OpeningFeeParams, + OpeningFeeParamsMenu, PayOnchainRequest, PayOnchainResponse, Payment, PaymentDetails, + PaymentFailedData, PaymentStatus, PaymentType, PaymentTypeFilter, PrepareOnchainPaymentRequest, + PrepareOnchainPaymentResponse, PrepareRedeemOnchainFundsRequest, + PrepareRedeemOnchainFundsResponse, PrepareRefundRequest, PrepareRefundResponse, Rate, + ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, RecommendedFees, + RedeemOnchainFundsRequest, RedeemOnchainFundsResponse, RefundRequest, RefundResponse, + ReportIssueRequest, ReportPaymentFailureDetails, ReverseSwapFeesRequest, ReverseSwapInfo, + ReverseSwapPairInfo, ReverseSwapStatus, RouteHint, RouteHintHop, SendPaymentRequest, + SendPaymentResponse, SendSpontaneousPaymentRequest, ServiceHealthCheckResponse, + SignMessageRequest, SignMessageResponse, StaticBackupRequest, StaticBackupResponse, + SuccessActionProcessed, SwapAmountType, SwapInfo, SwapStatus, Symbol, TlvEntry, + UnspentTransactionOutput, UrlSuccessActionData, }; use log::{Level, LevelFilter, Metadata, Record}; use once_cell::sync::{Lazy, OnceCell}; @@ -332,28 +331,10 @@ impl BlockingBreezServices { rt().block_on(self.breez_services.in_progress_onchain_payments()) } - pub fn in_progress_reverse_swaps(&self) -> SdkResult> { - #[allow(deprecated)] - rt().block_on(self.breez_services.in_progress_reverse_swaps()) - } - pub fn claim_reverse_swap(&self, lockup_address: String) -> SdkResult<()> { rt().block_on(self.breez_services.claim_reverse_swap(lockup_address)) } - pub fn max_reverse_swap_amount(&self) -> SdkResult { - #[allow(deprecated)] - rt().block_on(self.breez_services.max_reverse_swap_amount()) - } - - pub fn send_onchain( - &self, - req: SendOnchainRequest, - ) -> Result { - #[allow(deprecated)] - rt().block_on(self.breez_services.send_onchain(req)) - } - pub fn pay_onchain( &self, req: PayOnchainRequest, diff --git a/libs/sdk-core/src/binding.rs b/libs/sdk-core/src/binding.rs index d3323881c..0ae224d5b 100644 --- a/libs/sdk-core/src/binding.rs +++ b/libs/sdk-core/src/binding.rs @@ -39,16 +39,16 @@ use crate::models::{Config, LogEntry, NodeState, Payment, SwapInfo}; use crate::{ BackupStatus, BuyBitcoinRequest, BuyBitcoinResponse, CheckMessageRequest, CheckMessageResponse, ConfigureNodeRequest, ConnectRequest, EnvironmentType, ListPaymentsRequest, ListSwapsRequest, - LnUrlAuthError, MaxReverseSwapAmountResponse, NodeConfig, NodeCredentials, - OnchainPaymentLimitsResponse, OpenChannelFeeRequest, OpenChannelFeeResponse, PayOnchainRequest, - PayOnchainResponse, PrepareOnchainPaymentRequest, PrepareOnchainPaymentResponse, - PrepareRedeemOnchainFundsRequest, PrepareRedeemOnchainFundsResponse, PrepareRefundRequest, - PrepareRefundResponse, ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, + LnUrlAuthError, NodeConfig, NodeCredentials, OnchainPaymentLimitsResponse, + OpenChannelFeeRequest, OpenChannelFeeResponse, PayOnchainRequest, PayOnchainResponse, + PrepareOnchainPaymentRequest, PrepareOnchainPaymentResponse, PrepareRedeemOnchainFundsRequest, + PrepareRedeemOnchainFundsResponse, PrepareRefundRequest, PrepareRefundResponse, + ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, RedeemOnchainFundsRequest, RedeemOnchainFundsResponse, RefundRequest, RefundResponse, ReportIssueRequest, ReverseSwapFeesRequest, ReverseSwapInfo, ReverseSwapPairInfo, - SendOnchainRequest, SendOnchainResponse, SendPaymentRequest, SendPaymentResponse, - SendSpontaneousPaymentRequest, ServiceHealthCheckResponse, SignMessageRequest, - SignMessageResponse, StaticBackupRequest, StaticBackupResponse, + SendPaymentRequest, SendPaymentResponse, SendSpontaneousPaymentRequest, + ServiceHealthCheckResponse, SignMessageRequest, SignMessageResponse, StaticBackupRequest, + StaticBackupResponse, }; // === FRB mirroring @@ -601,20 +601,6 @@ pub fn list_fiat_currencies() -> Result> { /* On-Chain Swap API's */ -/// See [BreezServices::max_reverse_swap_amount] -pub fn max_reverse_swap_amount() -> Result { - #[allow(deprecated)] - block_on(async { get_breez_services().await?.max_reverse_swap_amount().await }) - .map_err(anyhow::Error::new::) -} - -/// See [BreezServices::send_onchain] -pub fn send_onchain(req: SendOnchainRequest) -> Result { - #[allow(deprecated)] - block_on(async { get_breez_services().await?.send_onchain(req).await }) - .map_err(anyhow::Error::new::) -} - /// See [BreezServices::pay_onchain] pub fn pay_onchain(req: PayOnchainRequest) -> Result { block_on(async { get_breez_services().await?.pay_onchain(req).await }) @@ -698,18 +684,6 @@ pub fn list_swaps(req: ListSwapsRequest) -> Result> { .map_err(anyhow::Error::new::) } -/// See [BreezServices::in_progress_reverse_swaps] -pub fn in_progress_reverse_swaps() -> Result> { - #[allow(deprecated)] - block_on(async { - get_breez_services() - .await? - .in_progress_reverse_swaps() - .await - }) - .map_err(anyhow::Error::new::) -} - /// See [BreezServices::claim_reverse_swap] pub fn claim_reverse_swap(lockup_address: String) -> Result<()> { block_on(async { diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index 4c8e9eede..14e464b9b 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -45,7 +45,7 @@ use crate::node_api::{CreateInvoiceRequest, NodeAPI}; use crate::persist::db::SqliteStorage; use crate::swap_in::swap::BTCReceiveSwap; use crate::swap_out::boltzswap::BoltzApi; -use crate::swap_out::reverseswap::{BTCSendSwap, CreateReverseSwapArg}; +use crate::swap_out::reverseswap::BTCSendSwap; use crate::*; const DETECT_HIBERNATE_SLEEP_DURATION: Duration = Duration::from_secs(1); @@ -935,14 +935,12 @@ impl BreezServices { Ok(res) } - /// Returns the max amount that can be sent on-chain using the send_onchain method. /// The returned amount is the sum of the max amount that can be sent on each channel /// minus the expected fees. /// This is possible since the route to the swapper node is known in advance and is expected /// to consist of maximum 3 hops. - #[deprecated(note = "use onchain_payment_limits instead")] - pub async fn max_reverse_swap_amount(&self) -> SdkResult { + async fn max_reverse_swap_amount(&self) -> SdkResult { // fetch the last hop hints from the swapper let last_hop = self.btc_send_swapper.last_hop_for_payment().await?; info!("max_reverse_swap_amount last_hop={:?}", last_hop); @@ -965,36 +963,7 @@ impl BreezServices { // Sum the max amount per channel and return the result let total_msat: u64 = max_to_pay.into_iter().map(|m| m.amount_msat).sum(); let total_sat = total_msat / 1000; - Ok(MaxReverseSwapAmountResponse { total_sat }) - } - - /// Creates a reverse swap and attempts to pay the HODL invoice - #[deprecated(note = "use pay_onchain instead")] - pub async fn send_onchain( - &self, - req: SendOnchainRequest, - ) -> Result { - let reverse_swap_info = self - .pay_onchain_common(CreateReverseSwapArg::V1(req)) - .await?; - Ok(SendOnchainResponse { reverse_swap_info }) - } - - /// Returns the blocking [ReverseSwapInfo]s that are in progress - #[deprecated(note = "use in_progress_onchain_payments instead")] - pub async fn in_progress_reverse_swaps(&self) -> SdkResult> { - let full_rsis = self.btc_send_swapper.list_blocking().await?; - - let mut rsis = vec![]; - for full_rsi in full_rsis { - let rsi = self - .btc_send_swapper - .convert_reverse_swap_info(full_rsi) - .await?; - rsis.push(rsi); - } - - Ok(rsis) + Ok(total_sat) } /// list non-completed expired swaps that should be refunded by calling [BreezServices::refund] @@ -1023,14 +992,13 @@ impl BreezServices { pub async fn onchain_payment_limits(&self) -> SdkResult { let fee_info = self.btc_send_swapper.fetch_reverse_swap_fees().await?; debug!("Reverse swap pair info: {fee_info:?}"); - #[allow(deprecated)] let max_amt_current_channels = self.max_reverse_swap_amount().await?; debug!("Max send amount possible with current channels: {max_amt_current_channels:?}"); Ok(OnchainPaymentLimitsResponse { min_sat: fee_info.min, max_sat: fee_info.max, - max_payable_sat: max_amt_current_channels.total_sat, + max_payable_sat: max_amt_current_channels, }) } @@ -1053,8 +1021,7 @@ impl BreezServices { // Calculate (send_amt, recv_amt) from the inputs and fees let fees_lockup = fee_info.fees_lockup; let p = fee_info.fees_percentage; - let fees_claim = BTCSendSwap::calculate_claim_tx_fee(req.claim_tx_feerate)?; - let (send_amt, recv_amt) = match req.amount_type { + let (send_amt, recv_amt, fees_service) = match req.amount_type { SwapAmountType::Send => { let temp_send_amt = req.amount_sat; let service_fees = swap_out::get_service_fee_sat(temp_send_amt, p); @@ -1066,14 +1033,14 @@ impl BreezServices { ) ); - (temp_send_amt, temp_send_amt - total_fees) + (temp_send_amt, temp_send_amt - total_fees, service_fees) } SwapAmountType::Receive => { let temp_recv_amt = req.amount_sat; let send_amt_minus_service_fee = temp_recv_amt + fees_lockup + fees_claim; let temp_send_amt = swap_out::get_invoice_amount_sat(send_amt_minus_service_fee, p); - - (temp_send_amt, temp_recv_amt) + let service_fees = temp_send_amt - send_amt_minus_service_fee; + (temp_send_amt, temp_recv_amt, service_fees) } }; @@ -1085,6 +1052,7 @@ impl BreezServices { fees_percentage: p, fees_lockup, fees_claim, + fees_service, sender_amount_sat: send_amt, recipient_amount_sat: recv_amt, total_fees: send_amt - recv_amt, @@ -1092,8 +1060,6 @@ impl BreezServices { } /// Creates a reverse swap and attempts to pay the HODL invoice - /// - /// Supersedes [BreezServices::send_onchain] pub async fn pay_onchain( &self, req: PayOnchainRequest, @@ -1103,16 +1069,9 @@ impl BreezServices { SendOnchainError::generic("Send amount must be bigger than receive amount") ); - let reverse_swap_info = self - .pay_onchain_common(CreateReverseSwapArg::V2(req)) - .await?; - Ok(PayOnchainResponse { reverse_swap_info }) - } - - async fn pay_onchain_common(&self, req: CreateReverseSwapArg) -> SdkResult { - ensure_sdk!(self.in_progress_onchain_payments().await?.is_empty(), SdkError::Generic { err: + ensure_sdk!(self.in_progress_onchain_payments().await?.is_empty(), SendOnchainError::Generic { err: "You can only start a new one after after the ongoing ones finish. \ - Use the in_progress_reverse_swaps method to get an overview of currently ongoing reverse swaps".into(), + Use the in_progress_onchain_payments method to get an overview of currently ongoing reverse swaps".into(), }); let full_rsi = self.btc_send_swapper.create_reverse_swap(req).await?; @@ -1130,15 +1089,23 @@ impl BreezServices { self.register_onchain_tx_notification(address, &webhook_url) .await?; } - Ok(reverse_swap_info) + Ok(PayOnchainResponse { reverse_swap_info }) } /// Returns the blocking [ReverseSwapInfo]s that are in progress. - /// - /// Supersedes [BreezServices::in_progress_reverse_swaps] pub async fn in_progress_onchain_payments(&self) -> SdkResult> { - #[allow(deprecated)] - self.in_progress_reverse_swaps().await + let full_rsis = self.btc_send_swapper.list_blocking().await?; + + let mut rsis = vec![]; + for full_rsi in full_rsis { + let rsi = self + .btc_send_swapper + .convert_reverse_swap_info(full_rsi) + .await?; + rsis.push(rsi); + } + + Ok(rsis) } /// Execute a command directly on the NodeAPI interface. @@ -3054,6 +3021,10 @@ pub(crate) mod tests { lockup_txid: Some("lockup_txid".to_string()), claim_txid: Some("claim_txid".to_string()), }, + fees_lockup: 0, + fees_claim: 0, + fees_service: 0, + total_fees: 0, }; let rev_swap_info = ReverseSwapInfo { id: "rev_swap_id".to_string(), @@ -3062,6 +3033,10 @@ pub(crate) mod tests { claim_txid: Some("claim_txid".to_string()), onchain_amount_sat: 250, status: ReverseSwapStatus::CompletedConfirmed, + fees_claim: 0, + fees_lockup: 0, + fees_service: 0, + total_fees: 0, }; let dummy_transactions = vec![ Payment { diff --git a/libs/sdk-core/src/bridge_generated.io.rs b/libs/sdk-core/src/bridge_generated.io.rs index f1e3bdc59..88185b87b 100644 --- a/libs/sdk-core/src/bridge_generated.io.rs +++ b/libs/sdk-core/src/bridge_generated.io.rs @@ -208,16 +208,6 @@ pub extern "C" fn wire_list_fiat_currencies(port_: i64) { wire_list_fiat_currencies_impl(port_) } -#[no_mangle] -pub extern "C" fn wire_max_reverse_swap_amount(port_: i64) { - wire_max_reverse_swap_amount_impl(port_) -} - -#[no_mangle] -pub extern "C" fn wire_send_onchain(port_: i64, req: *mut wire_SendOnchainRequest) { - wire_send_onchain_impl(port_, req) -} - #[no_mangle] pub extern "C" fn wire_pay_onchain(port_: i64, req: *mut wire_PayOnchainRequest) { wire_pay_onchain_impl(port_, req) @@ -281,11 +271,6 @@ pub extern "C" fn wire_list_swaps(port_: i64, req: *mut wire_ListSwapsRequest) { wire_list_swaps_impl(port_, req) } -#[no_mangle] -pub extern "C" fn wire_in_progress_reverse_swaps(port_: i64) { - wire_in_progress_reverse_swaps_impl(port_) -} - #[no_mangle] pub extern "C" fn wire_claim_reverse_swap(port_: i64, lockup_address: *mut wire_uint_8_list) { wire_claim_reverse_swap_impl(port_, lockup_address) @@ -476,11 +461,6 @@ pub extern "C" fn new_box_autoadd_reverse_swap_fees_request_0() -> *mut wire_Rev support::new_leak_box_ptr(wire_ReverseSwapFeesRequest::new_with_null_ptr()) } -#[no_mangle] -pub extern "C" fn new_box_autoadd_send_onchain_request_0() -> *mut wire_SendOnchainRequest { - support::new_leak_box_ptr(wire_SendOnchainRequest::new_with_null_ptr()) -} - #[no_mangle] pub extern "C" fn new_box_autoadd_send_payment_request_0() -> *mut wire_SendPaymentRequest { support::new_leak_box_ptr(wire_SendPaymentRequest::new_with_null_ptr()) @@ -728,12 +708,6 @@ impl Wire2Api for *mut wire_ReverseSwapFeesRequest { Wire2Api::::wire2api(*wrap).into() } } -impl Wire2Api for *mut wire_SendOnchainRequest { - fn wire2api(self) -> SendOnchainRequest { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } -} impl Wire2Api for *mut wire_SendPaymentRequest { fn wire2api(self) -> SendPaymentRequest { let wrap = unsafe { support::box_from_leak_ptr(self) }; @@ -1024,6 +998,7 @@ impl Wire2Api for wire_PrepareOnchainPaymentRespo fees_percentage: self.fees_percentage.wire2api(), fees_lockup: self.fees_lockup.wire2api(), fees_claim: self.fees_claim.wire2api(), + fees_service: self.fees_service.wire2api(), sender_amount_sat: self.sender_amount_sat.wire2api(), recipient_amount_sat: self.recipient_amount_sat.wire2api(), total_fees: self.total_fees.wire2api(), @@ -1114,16 +1089,6 @@ impl Wire2Api for wire_ReverseSwapFeesRequest { } } } -impl Wire2Api for wire_SendOnchainRequest { - fn wire2api(self) -> SendOnchainRequest { - SendOnchainRequest { - amount_sat: self.amount_sat.wire2api(), - onchain_recipient_address: self.onchain_recipient_address.wire2api(), - pair_hash: self.pair_hash.wire2api(), - sat_per_vbyte: self.sat_per_vbyte.wire2api(), - } - } -} impl Wire2Api for wire_SendPaymentRequest { fn wire2api(self) -> SendPaymentRequest { SendPaymentRequest { @@ -1387,6 +1352,7 @@ pub struct wire_PrepareOnchainPaymentResponse { fees_percentage: f64, fees_lockup: u64, fees_claim: u64, + fees_service: u64, sender_amount_sat: u64, recipient_amount_sat: u64, total_fees: u64, @@ -1454,15 +1420,6 @@ pub struct wire_ReverseSwapFeesRequest { claim_tx_feerate: *mut u32, } -#[repr(C)] -#[derive(Clone)] -pub struct wire_SendOnchainRequest { - amount_sat: u64, - onchain_recipient_address: *mut wire_uint_8_list, - pair_hash: *mut wire_uint_8_list, - sat_per_vbyte: u32, -} - #[repr(C)] #[derive(Clone)] pub struct wire_SendPaymentRequest { @@ -1912,6 +1869,7 @@ impl NewWithNullPtr for wire_PrepareOnchainPaymentResponse { fees_percentage: Default::default(), fees_lockup: Default::default(), fees_claim: Default::default(), + fees_service: Default::default(), sender_amount_sat: Default::default(), recipient_amount_sat: Default::default(), total_fees: Default::default(), @@ -2075,23 +2033,6 @@ impl Default for wire_ReverseSwapFeesRequest { } } -impl NewWithNullPtr for wire_SendOnchainRequest { - fn new_with_null_ptr() -> Self { - Self { - amount_sat: Default::default(), - onchain_recipient_address: core::ptr::null_mut(), - pair_hash: core::ptr::null_mut(), - sat_per_vbyte: Default::default(), - } - } -} - -impl Default for wire_SendOnchainRequest { - fn default() -> Self { - Self::new_with_null_ptr() - } -} - impl NewWithNullPtr for wire_SendPaymentRequest { fn new_with_null_ptr() -> Self { Self { diff --git a/libs/sdk-core/src/bridge_generated.rs b/libs/sdk-core/src/bridge_generated.rs index c857f34a8..9885fece4 100644 --- a/libs/sdk-core/src/bridge_generated.rs +++ b/libs/sdk-core/src/bridge_generated.rs @@ -50,7 +50,6 @@ use crate::models::ListPaymentsRequest; use crate::models::ListSwapsRequest; use crate::models::LnPaymentDetails; use crate::models::LogEntry; -use crate::models::MaxReverseSwapAmountResponse; use crate::models::MetadataFilter; use crate::models::NodeConfig; use crate::models::NodeCredentials; @@ -86,8 +85,6 @@ use crate::models::ReverseSwapFeesRequest; use crate::models::ReverseSwapInfo; use crate::models::ReverseSwapPairInfo; use crate::models::ReverseSwapStatus; -use crate::models::SendOnchainRequest; -use crate::models::SendOnchainResponse; use crate::models::SendPaymentRequest; use crate::models::SendPaymentResponse; use crate::models::SendSpontaneousPaymentRequest; @@ -607,29 +604,6 @@ fn wire_list_fiat_currencies_impl(port_: MessagePort) { move || move |task_callback| list_fiat_currencies(), ) } -fn wire_max_reverse_swap_amount_impl(port_: MessagePort) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, MaxReverseSwapAmountResponse, _>( - WrapInfo { - debug_name: "max_reverse_swap_amount", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| max_reverse_swap_amount(), - ) -} -fn wire_send_onchain_impl(port_: MessagePort, req: impl Wire2Api + UnwindSafe) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, SendOnchainResponse, _>( - WrapInfo { - debug_name: "send_onchain", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_req = req.wire2api(); - move |task_callback| send_onchain(api_req) - }, - ) -} fn wire_pay_onchain_impl(port_: MessagePort, req: impl Wire2Api + UnwindSafe) { FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, PayOnchainResponse, _>( WrapInfo { @@ -789,16 +763,6 @@ fn wire_list_swaps_impl(port_: MessagePort, req: impl Wire2Api }, ) } -fn wire_in_progress_reverse_swaps_impl(port_: MessagePort) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Vec, _>( - WrapInfo { - debug_name: "in_progress_reverse_swaps", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| in_progress_reverse_swaps(), - ) -} fn wire_claim_reverse_swap_impl( port_: MessagePort, lockup_address: impl Wire2Api + UnwindSafe, @@ -1993,18 +1957,6 @@ impl rust2dart::IntoIntoDart for LspInformation { } } -impl support::IntoDart for MaxReverseSwapAmountResponse { - fn into_dart(self) -> support::DartAbi { - vec![self.total_sat.into_into_dart().into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for MaxReverseSwapAmountResponse {} -impl rust2dart::IntoIntoDart for MaxReverseSwapAmountResponse { - fn into_into_dart(self) -> Self { - self - } -} - impl support::IntoDart for mirror_MessageSuccessActionData { fn into_dart(self) -> support::DartAbi { vec![self.0.message.into_into_dart().into_dart()].into_dart() @@ -2278,6 +2230,7 @@ impl support::IntoDart for PrepareOnchainPaymentResponse { self.fees_percentage.into_into_dart().into_dart(), self.fees_lockup.into_into_dart().into_dart(), self.fees_claim.into_into_dart().into_dart(), + self.fees_service.into_into_dart().into_dart(), self.sender_amount_sat.into_into_dart().into_dart(), self.recipient_amount_sat.into_into_dart().into_dart(), self.total_fees.into_into_dart().into_dart(), @@ -2411,6 +2364,10 @@ impl support::IntoDart for ReverseSwapInfo { self.claim_txid.into_dart(), self.onchain_amount_sat.into_into_dart().into_dart(), self.status.into_into_dart().into_dart(), + self.fees_lockup.into_into_dart().into_dart(), + self.fees_claim.into_into_dart().into_dart(), + self.fees_service.into_into_dart().into_dart(), + self.total_fees.into_into_dart().into_dart(), ] .into_dart() } @@ -2498,18 +2455,6 @@ impl rust2dart::IntoIntoDart for RouteHintHop { } } -impl support::IntoDart for SendOnchainResponse { - fn into_dart(self) -> support::DartAbi { - vec![self.reverse_swap_info.into_into_dart().into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for SendOnchainResponse {} -impl rust2dart::IntoIntoDart for SendOnchainResponse { - fn into_into_dart(self) -> Self { - self - } -} - impl support::IntoDart for SendPaymentResponse { fn into_dart(self) -> support::DartAbi { vec![self.payment.into_into_dart().into_dart()].into_dart() diff --git a/libs/sdk-core/src/error.rs b/libs/sdk-core/src/error.rs index a398d5faa..47f3105de 100644 --- a/libs/sdk-core/src/error.rs +++ b/libs/sdk-core/src/error.rs @@ -562,6 +562,14 @@ impl From for SendOnchainError { } } +impl From for SendOnchainError { + fn from(err: PersistError) -> Self { + Self::Generic { + err: err.to_string(), + } + } +} + /// Error returned by [crate::breez_services::BreezServices::send_payment] and [crate::breez_services::BreezServices::send_spontaneous_payment] #[derive(Clone, Debug, Error)] pub enum SendPaymentError { diff --git a/libs/sdk-core/src/lib.rs b/libs/sdk-core/src/lib.rs index ef4583bb0..9223386aa 100644 --- a/libs/sdk-core/src/lib.rs +++ b/libs/sdk-core/src/lib.rs @@ -106,8 +106,9 @@ //! ### D. Sending to an on-chain address (swap-out) //! //! * [BreezServices::fetch_reverse_swap_fees] to get the current swap-out fees -//! * [BreezServices::send_onchain] to start the swap-out -//! * [BreezServices::in_progress_reverse_swaps] to see any in-progress swaps +//! * [BreezServices::prepare_onchain_payment] to prepare the swap-out +//! * [BreezServices::pay_onchain] to start the swap-out +//! * [BreezServices::in_progress_onchain_payments] to see any in-progress swaps //! //! ### E. Using LNURL //! diff --git a/libs/sdk-core/src/models.rs b/libs/sdk-core/src/models.rs index 7d6b28c30..7d61e1c63 100644 --- a/libs/sdk-core/src/models.rs +++ b/libs/sdk-core/src/models.rs @@ -168,6 +168,11 @@ pub struct FullReverseSwapInfo { pub receive_amount_sat: Option, pub cache: ReverseSwapInfoCached, + + pub fees_lockup: u64, + pub fees_claim: u64, + pub fees_service: u64, + pub total_fees: u64, } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] @@ -316,6 +321,10 @@ impl FullReverseSwapInfo { claim_txid: self.cache.claim_txid.clone(), onchain_amount_sat: self.onchain_amount_sat, status: self.cache.status, + fees_lockup: self.fees_lockup, + fees_claim: self.fees_claim, + fees_service: self.fees_service, + total_fees: self.total_fees, } } } @@ -331,6 +340,10 @@ pub struct ReverseSwapInfo { pub claim_txid: Option, pub onchain_amount_sat: u64, pub status: ReverseSwapStatus, + pub fees_lockup: u64, + pub fees_claim: u64, + pub fees_service: u64, + pub total_fees: u64, } /// The possible statuses of a reverse swap, from the Breez SDK perspective. @@ -792,12 +805,6 @@ pub struct ReverseSwapFeesRequest { pub claim_tx_feerate: Option, } -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct MaxReverseSwapAmountResponse { - /// The total sats that can be sent onchain. - pub total_sat: u64, -} - #[derive(Clone, Debug, Serialize, Deserialize)] pub struct MaxChannelAmount { /// The channel id. @@ -997,18 +1004,6 @@ pub struct RedeemOnchainFundsResponse { pub txid: Vec, } -#[derive(Clone)] -pub struct SendOnchainRequest { - pub amount_sat: u64, - pub onchain_recipient_address: String, - pub pair_hash: String, - pub sat_per_vbyte: u32, -} - -pub struct SendOnchainResponse { - pub reverse_swap_info: ReverseSwapInfo, -} - pub enum SwapAmountType { Send, Receive, @@ -1042,7 +1037,7 @@ pub struct PrepareOnchainPaymentResponse { pub fees_percentage: f64, pub fees_lockup: u64, pub fees_claim: u64, - + pub fees_service: u64, pub sender_amount_sat: u64, pub recipient_amount_sat: u64, pub total_fees: u64, @@ -1835,6 +1830,10 @@ mod tests { lockup_txid: Some("lockup_txid".to_string()), claim_txid: Some("claim_txid".to_string()), }, + fees_lockup: 0, + fees_claim: 0, + fees_service: 0, + total_fees: 0, } .sanitize(); assert_eq!(rev_swap_info_sanitized.preimage, Vec::::new()); diff --git a/libs/sdk-core/src/persist/migrations.rs b/libs/sdk-core/src/persist/migrations.rs index 75f4d4fc4..c3a47b930 100644 --- a/libs/sdk-core/src/persist/migrations.rs +++ b/libs/sdk-core/src/persist/migrations.rs @@ -642,5 +642,11 @@ pub(crate) fn current_sync_migrations() -> Vec<&'static str> { UPDATE swaps SET max_swapper_payable = max_allowed_deposit; ", "ALTER TABLE payments_external_info ADD COLUMN lnurl_pay_comment TEXT;", + " + ALTER TABLE reverse_swaps ADD column fees_lockup INTEGER DEFAULT 0; + ALTER TABLE reverse_swaps ADD column fees_claim INTEGER DEFAULT 0; + ALTER TABLE reverse_swaps ADD column fees_service INTEGER DEFAULT 0; + ALTER TABLE reverse_swaps ADD column total_fees INTEGER DEFAULT 0; + " ] } diff --git a/libs/sdk-core/src/persist/reverseswap.rs b/libs/sdk-core/src/persist/reverseswap.rs index 88abb4616..c930caa6c 100644 --- a/libs/sdk-core/src/persist/reverseswap.rs +++ b/libs/sdk-core/src/persist/reverseswap.rs @@ -8,8 +8,15 @@ impl SqliteStorage { let tx = con.transaction_with_behavior(TransactionBehavior::Immediate)?; tx.execute( - "INSERT INTO sync.reverse_swaps (id, created_at_block_height, preimage, private_key, claim_pubkey, timeout_block_height, invoice, onchain_amount_sat, sat_per_vbyte, receive_amount_sat, redeem_script)\ - VALUES (:id, :created_at_block_height, :preimage, :private_key, :claim_pubkey, :timeout_block_height, :invoice, :onchain_amount_sat, :sat_per_vbyte, :receive_amount_sat, :redeem_script)", + r#"INSERT INTO sync.reverse_swaps (id, created_at_block_height, + preimage, private_key, claim_pubkey, timeout_block_height, + invoice, onchain_amount_sat, sat_per_vbyte, receive_amount_sat, + redeem_script, fees_lockup, fees_claim, fees_service, total_fees) + VALUES (:id, :created_at_block_height, :preimage, :private_key, + :claim_pubkey, :timeout_block_height, :invoice, + :onchain_amount_sat, :sat_per_vbyte, :receive_amount_sat, + :redeem_script, :fees_lockup, :fees_claim, :fees_service, + :total_fees)"#, named_params! { ":id": rsi.id, ":created_at_block_height": rsi.created_at_block_height, @@ -21,7 +28,11 @@ impl SqliteStorage { ":onchain_amount_sat": rsi.onchain_amount_sat, ":sat_per_vbyte": rsi.sat_per_vbyte, ":receive_amount_sat": rsi.receive_amount_sat, - ":redeem_script": rsi.redeem_script + ":redeem_script": rsi.redeem_script, + ":fees_lockup": rsi.fees_lockup, + ":fees_claim": rsi.fees_claim, + ":fees_service": rsi.fees_service, + ":total_fees": rsi.total_fees, }, )?; @@ -131,7 +142,11 @@ impl SqliteStorage { {prefix}redeem_script, {prefix}status, {prefix}lockup_txid, - {prefix}claim_txid + {prefix}claim_txid, + {prefix}fees_lockup, + {prefix}fees_claim, + {prefix}fees_service, + {prefix}total_fees, " ) } @@ -162,6 +177,10 @@ impl SqliteStorage { lockup_txid: row.get(format!("{prefix}lockup_txid").as_str())?, claim_txid: row.get(format!("{prefix}claim_txid").as_str())?, }, + fees_lockup: row.get(format!("{prefix}fees_lockup").as_str())?, + fees_claim: row.get(format!("{prefix}fees_claim").as_str())?, + fees_service: row.get(format!("{prefix}fees_service").as_str())?, + total_fees: row.get(format!("{prefix}total_fees").as_str())?, }) } @@ -181,7 +200,11 @@ impl SqliteStorage { redeem_script as {prefix}redeem_script, status as {prefix}status, lockup_txid as {prefix}lockup_txid, - claim_txid as {prefix}claim_txid + claim_txid as {prefix}claim_txid, + fees_lockup as {prefix}fees_lockup, + fees_claim as {prefix}fees_claim, + fees_service as {prefix}fees_service, + total_fees as {prefix}total_fees, " ); diff --git a/libs/sdk-core/src/persist/transactions.rs b/libs/sdk-core/src/persist/transactions.rs index 9d3cbec06..f274d9e7b 100644 --- a/libs/sdk-core/src/persist/transactions.rs +++ b/libs/sdk-core/src/persist/transactions.rs @@ -560,6 +560,10 @@ fn test_ln_transactions() -> PersistResult<(), Box> { lockup_txid: Some("lockup_txid".to_string()), claim_txid: Some("claim_txid".to_string()), }, + fees_lockup: 0, + fees_claim: 0, + fees_service: 0, + total_fees: 0, }; let rev_swap_info = ReverseSwapInfo { id: "rev_swap_id".to_string(), @@ -568,6 +572,10 @@ fn test_ln_transactions() -> PersistResult<(), Box> { claim_txid: Some("claim_txid".to_string()), onchain_amount_sat: 250, status: ReverseSwapStatus::CompletedConfirmed, + fees_lockup: 0, + fees_claim: 0, + fees_service: 0, + total_fees: 0, }; let txs = [ Payment { diff --git a/libs/sdk-core/src/swap_out/reverseswap.rs b/libs/sdk-core/src/swap_out/reverseswap.rs index 4d725e346..7a82e7c26 100644 --- a/libs/sdk-core/src/swap_out/reverseswap.rs +++ b/libs/sdk-core/src/swap_out/reverseswap.rs @@ -28,7 +28,7 @@ use crate::swap_in::swap::create_swap_keys; use crate::{ ensure_sdk, BreezEvent, Config, FullReverseSwapInfo, PayOnchainRequest, PaymentStatus, ReverseSwapInfo, ReverseSwapInfoCached, ReverseSwapPairInfo, ReverseSwapStatus, - ReverseSwapStatus::*, RouteHintHop, SendOnchainRequest, + ReverseSwapStatus::*, RouteHintHop, }; // Estimates based on https://github.com/BoltzExchange/boltz-backend/blob/master/lib/rates/FeeProvider.ts#L31-L42 @@ -77,34 +77,6 @@ impl From<&Option> for TxStatus { } } -#[derive(Clone)] -pub(crate) enum CreateReverseSwapArg { - /// Used for backward compatibility with older SDK nodes. Works with the [FullReverseSwapInfo] - /// `sat_per_vbyte` instead of the newer `receive_amount_sat`. - V1(SendOnchainRequest), - V2(PayOnchainRequest), -} -impl CreateReverseSwapArg { - fn pair_hash(&self) -> String { - match self { - CreateReverseSwapArg::V1(s) => s.pair_hash.clone(), - CreateReverseSwapArg::V2(s) => s.prepare_res.fees_hash.clone(), - } - } - fn send_amount_sat(&self) -> u64 { - match self { - CreateReverseSwapArg::V1(s) => s.amount_sat, - CreateReverseSwapArg::V2(s) => s.prepare_res.sender_amount_sat, - } - } - fn onchain_recipient_address(&self) -> String { - match self { - CreateReverseSwapArg::V1(s) => s.onchain_recipient_address.clone(), - CreateReverseSwapArg::V2(s) => s.recipient_address.clone(), - } - } -} - /// This struct is responsible for sending to an onchain address using lightning payments. /// It uses internally an implementation of [ReverseSwapServiceAPI] that represents Boltz reverse swapper service. pub(crate) struct BTCSendSwap { @@ -213,9 +185,9 @@ impl BTCSendSwap { /// status persisted. pub(crate) async fn create_reverse_swap( &self, - req: CreateReverseSwapArg, + req: PayOnchainRequest, ) -> ReverseSwapResult { - Self::validate_recipient_address(&req.onchain_recipient_address())?; + Self::validate_recipient_address(&req.recipient_address)?; let routing_node = self .reverse_swapper_api @@ -226,38 +198,35 @@ impl BTCSendSwap { .create_and_validate_rev_swap_on_remote(req.clone(), routing_node) .await?; - // For v2 reverse swaps, we perform validation on the created swap - if let CreateReverseSwapArg::V2(req) = req { - trace!("create_rev_swap v2 request: {req:?}"); - trace!("create_rev_swap v2 created_rsi: {created_rsi:?}"); + // Perform validation on the created swap + trace!("create_rev_swap v2 request: {req:?}"); + trace!("create_rev_swap v2 created_rsi: {created_rsi:?}"); - // Validate send_amount - let request_send_amount_sat = req.prepare_res.sender_amount_sat; - let request_send_amount_msat = request_send_amount_sat * 1_000; - created_rsi.validate_invoice_amount(request_send_amount_msat)?; + // Validate send_amount + let request_send_amount_sat = req.prepare_res.sender_amount_sat; + let request_send_amount_msat = request_send_amount_sat * 1_000; + created_rsi.validate_invoice_amount(request_send_amount_msat)?; - // Validate onchain_amount - let lockup_fee_sat = req.prepare_res.fees_lockup; - let service_fee_sat = super::get_service_fee_sat( - req.prepare_res.sender_amount_sat, - req.prepare_res.fees_percentage, - ); - trace!("create_rev_swap v2 service_fee_sat: {service_fee_sat} sat"); - let expected_onchain_amount = - request_send_amount_sat - service_fee_sat - lockup_fee_sat; - ensure_sdk!( - created_rsi.onchain_amount_sat == expected_onchain_amount, - ReverseSwapError::generic("Unexpected onchain amount (lockup fee or service fee)") - ); - - // Validate claim_fee. If onchain_amount and claim_fee are both valid, receive_amount is also valid. - ensure_sdk!( - created_rsi.onchain_amount_sat > req.prepare_res.recipient_amount_sat, - ReverseSwapError::generic("Unexpected receive amount") - ); - let claim_fee = created_rsi.onchain_amount_sat - req.prepare_res.recipient_amount_sat; - Self::validate_claim_tx_fee(claim_fee)?; - } + // Validate onchain_amount + let lockup_fee_sat = req.prepare_res.fees_lockup; + let service_fee_sat = super::get_service_fee_sat( + req.prepare_res.sender_amount_sat, + req.prepare_res.fees_percentage, + ); + trace!("create_rev_swap v2 service_fee_sat: {service_fee_sat} sat"); + let expected_onchain_amount = request_send_amount_sat - service_fee_sat - lockup_fee_sat; + ensure_sdk!( + created_rsi.onchain_amount_sat == expected_onchain_amount, + ReverseSwapError::generic("Unexpected onchain amount (lockup fee or service fee)") + ); + + // Validate claim_fee. If onchain_amount and claim_fee are both valid, receive_amount is also valid. + ensure_sdk!( + created_rsi.onchain_amount_sat > req.prepare_res.recipient_amount_sat, + ReverseSwapError::generic("Unexpected receive amount") + ); + let claim_fee = created_rsi.onchain_amount_sat - req.prepare_res.recipient_amount_sat; + Self::validate_claim_tx_fee(claim_fee)?; self.persister.insert_reverse_swap(&created_rsi)?; info!("Created and persisted reverse swap {}", created_rsi.id); @@ -343,7 +312,7 @@ impl BTCSendSwap { /// before returning it async fn create_and_validate_rev_swap_on_remote( &self, - req: CreateReverseSwapArg, + req: PayOnchainRequest, routing_node: String, ) -> ReverseSwapResult { let reverse_swap_keys = create_swap_keys()?; @@ -351,39 +320,39 @@ impl BTCSendSwap { let boltz_response = self .reverse_swap_service_api .create_reverse_swap_on_remote( - req.send_amount_sat(), + req.prepare_res.sender_amount_sat, reverse_swap_keys.preimage_hash_bytes().to_hex(), reverse_swap_keys.public_key()?.to_hex(), - req.pair_hash(), + req.prepare_res.fees_hash, routing_node, ) .await?; - let (sat_per_vbyte, receive_amount_sat) = match &req { - CreateReverseSwapArg::V1(req) => (Some(req.sat_per_vbyte), None), - CreateReverseSwapArg::V2(req) => (None, Some(req.prepare_res.recipient_amount_sat)), - }; match boltz_response { BoltzApiCreateReverseSwapResponse::BoltzApiSuccess(response) => { let res = FullReverseSwapInfo { created_at_block_height: self.chain_service.current_tip().await?, - claim_pubkey: req.onchain_recipient_address(), + claim_pubkey: req.recipient_address, invoice: response.invoice, preimage: reverse_swap_keys.preimage, private_key: reverse_swap_keys.priv_key, timeout_block_height: response.timeout_block_height, id: response.id, onchain_amount_sat: response.onchain_amount, - sat_per_vbyte, - receive_amount_sat, + sat_per_vbyte: None, + receive_amount_sat: Some(req.prepare_res.recipient_amount_sat), redeem_script: response.redeem_script, cache: ReverseSwapInfoCached { status: Initial, lockup_txid: None, claim_txid: None, }, + fees_lockup: req.prepare_res.fees_lockup, + fees_claim: req.prepare_res.fees_claim, + fees_service: req.prepare_res.fees_service, + total_fees: req.prepare_res.total_fees, }; - res.validate_invoice(req.send_amount_sat() * 1_000)?; + res.validate_invoice(req.prepare_res.sender_amount_sat * 1_000)?; res.validate_redeem_script(response.lockup_address, self.config.network)?; Ok(res) } @@ -778,6 +747,10 @@ impl BTCSendSwap { }, onchain_amount_sat: full_rsi.onchain_amount_sat, status: full_rsi.cache.status, + fees_lockup: full_rsi.fees_lockup, + fees_claim: full_rsi.fees_claim, + fees_service: full_rsi.fees_service, + total_fees: full_rsi.total_fees, }) } } diff --git a/libs/sdk-flutter/ios/Classes/bridge_generated.h b/libs/sdk-flutter/ios/Classes/bridge_generated.h index 4f1812649..507c72c7e 100644 --- a/libs/sdk-flutter/ios/Classes/bridge_generated.h +++ b/libs/sdk-flutter/ios/Classes/bridge_generated.h @@ -215,18 +215,12 @@ typedef struct wire_ReportIssueRequest { union ReportIssueRequestKind *kind; } wire_ReportIssueRequest; -typedef struct wire_SendOnchainRequest { - uint64_t amount_sat; - struct wire_uint_8_list *onchain_recipient_address; - struct wire_uint_8_list *pair_hash; - uint32_t sat_per_vbyte; -} wire_SendOnchainRequest; - typedef struct wire_PrepareOnchainPaymentResponse { struct wire_uint_8_list *fees_hash; double fees_percentage; uint64_t fees_lockup; uint64_t fees_claim; + uint64_t fees_service; uint64_t sender_amount_sat; uint64_t recipient_amount_sat; uint64_t total_fees; @@ -393,10 +387,6 @@ void wire_fetch_fiat_rates(int64_t port_); void wire_list_fiat_currencies(int64_t port_); -void wire_max_reverse_swap_amount(int64_t port_); - -void wire_send_onchain(int64_t port_, struct wire_SendOnchainRequest *req); - void wire_pay_onchain(int64_t port_, struct wire_PayOnchainRequest *req); void wire_receive_onchain(int64_t port_, struct wire_ReceiveOnchainRequest *req); @@ -422,8 +412,6 @@ void wire_in_progress_swap(int64_t port_); void wire_list_swaps(int64_t port_, struct wire_ListSwapsRequest *req); -void wire_in_progress_reverse_swaps(int64_t port_); - void wire_claim_reverse_swap(int64_t port_, struct wire_uint_8_list *lockup_address); void wire_open_channel_fee(int64_t port_, struct wire_OpenChannelFeeRequest *req); @@ -496,8 +484,6 @@ struct wire_ReportPaymentFailureDetails *new_box_autoadd_report_payment_failure_ struct wire_ReverseSwapFeesRequest *new_box_autoadd_reverse_swap_fees_request_0(void); -struct wire_SendOnchainRequest *new_box_autoadd_send_onchain_request_0(void); - struct wire_SendPaymentRequest *new_box_autoadd_send_payment_request_0(void); struct wire_SendSpontaneousPaymentRequest *new_box_autoadd_send_spontaneous_payment_request_0(void); @@ -567,8 +553,6 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_report_issue); dummy_var ^= ((int64_t) (void*) wire_fetch_fiat_rates); dummy_var ^= ((int64_t) (void*) wire_list_fiat_currencies); - dummy_var ^= ((int64_t) (void*) wire_max_reverse_swap_amount); - dummy_var ^= ((int64_t) (void*) wire_send_onchain); dummy_var ^= ((int64_t) (void*) wire_pay_onchain); dummy_var ^= ((int64_t) (void*) wire_receive_onchain); dummy_var ^= ((int64_t) (void*) wire_buy_bitcoin); @@ -581,7 +565,6 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_redeem_swap); dummy_var ^= ((int64_t) (void*) wire_in_progress_swap); dummy_var ^= ((int64_t) (void*) wire_list_swaps); - dummy_var ^= ((int64_t) (void*) wire_in_progress_reverse_swaps); dummy_var ^= ((int64_t) (void*) wire_claim_reverse_swap); dummy_var ^= ((int64_t) (void*) wire_open_channel_fee); dummy_var ^= ((int64_t) (void*) wire_fetch_reverse_swap_fees); @@ -618,7 +601,6 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) new_box_autoadd_report_issue_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_report_payment_failure_details_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_reverse_swap_fees_request_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_send_onchain_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_send_payment_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_send_spontaneous_payment_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_sign_message_request_0); diff --git a/libs/sdk-flutter/lib/breez_sdk.dart b/libs/sdk-flutter/lib/breez_sdk.dart index 499dfe3ff..b7c0bf147 100644 --- a/libs/sdk-flutter/lib/breez_sdk.dart +++ b/libs/sdk-flutter/lib/breez_sdk.dart @@ -130,7 +130,8 @@ class BreezSDK { /// Attempts to convert the phrase to a mnemonic, then to a seed. /// /// If the phrase is not a valid mnemonic, an error is returned. - Future mnemonicToSeed(String phrase) async => await _lnToolkit.mnemonicToSeed(phrase: phrase); + Future mnemonicToSeed(String phrase) async => + await _lnToolkit.mnemonicToSeed(phrase: phrase); /// Get the full default config for a specific environment type Future defaultConfig({ @@ -178,7 +179,8 @@ class BreezSDK { Future lspInfo() async => await _lnToolkit.lspInfo(); /// Convenience method to look up [LspInformation] for a given LSP ID - Future fetchLspInfo(String lspId) async => await _lnToolkit.fetchLspInfo(id: lspId); + Future fetchLspInfo(String lspId) async => + await _lnToolkit.fetchLspInfo(id: lspId); /// close all channels with the current lsp Future closeLspChannels() async => await _lnToolkit.closeLspChannels(); @@ -199,10 +201,12 @@ class BreezSDK { /* Parse API's */ /// Parse a BOLT11 payment request and return a structure contains the parsed fields. - Future parseInvoice(String invoice) async => await _lnToolkit.parseInvoice(invoice: invoice); + Future parseInvoice(String invoice) async => + await _lnToolkit.parseInvoice(invoice: invoice); /// Parses generic user input, typically pasted from clipboard or scanned from a QR. - Future parseInput({required String input}) async => await _lnToolkit.parseInput(input: input); + Future parseInput({required String input}) async => + await _lnToolkit.parseInput(input: input); /// Get the static backup data. Future staticBackup({ @@ -322,17 +326,6 @@ class BreezSDK { /* On-Chain Swap API's */ - /// Creates a reverse swap and attempts to pay the HODL invoice - @Deprecated( - 'Use payOnchain instead. ' - 'This method was deprecated after v0.3.2', - ) - Future sendOnchain({ - required SendOnchainRequest req, - }) async { - return await _lnToolkit.sendOnchain(req: req); - } - Future onchainPaymentLimits() async { return await _lnToolkit.onchainPaymentLimits(); } @@ -367,15 +360,6 @@ class BreezSDK { return redeemOnchainFundsResponse; } - /// Returns the max amount that can be sent on-chain using the send_onchain method. - /// The returned amount is the sum of the max amount that can be sent on each channel - /// minus the expected fees. - /// This is possible since the route to the swapper node is known in advance and is expected - /// to consist of maximum 3 hops. - Future maxReverseSwapAmount() async { - return await _lnToolkit.maxReverseSwapAmount(); - } - /* Refundables API's */ /// list non-completed expired swaps that should be refunded by calling refund() @@ -420,13 +404,6 @@ class BreezSDK { return await _lnToolkit.redeemSwap(swapAddress: swapAddress); } - /// Returns the blocking [ReverseSwapInfo]s that are in progress - @Deprecated( - 'Use inProgressOnchainPayments instead. ' - 'This method was deprecated after v0.3.6', - ) - Future> inProgressReverseSwaps() async => _lnToolkit.inProgressReverseSwaps(); - /// Claims an individual reverse swap. /// /// To be used only in the context of mobile notifications, where the notification triggers @@ -467,7 +444,8 @@ class BreezSDK { } /// Returns the blocking [ReverseSwapInfo]s that are in progress - Future> inProgressOnchainPayments() async => _lnToolkit.inProgressOnchainPayments(); + Future> inProgressOnchainPayments() async => + _lnToolkit.inProgressOnchainPayments(); /// Fetches the current recommended fees Future recommendedFees() async => await _lnToolkit.recommendedFees(); diff --git a/libs/sdk-flutter/lib/bridge_generated.dart b/libs/sdk-flutter/lib/bridge_generated.dart index dcd9ef86e..8bf098655 100644 --- a/libs/sdk-flutter/lib/bridge_generated.dart +++ b/libs/sdk-flutter/lib/bridge_generated.dart @@ -210,16 +210,6 @@ abstract class BreezSdkCore { FlutterRustBridgeTaskConstMeta get kListFiatCurrenciesConstMeta; - /// See [BreezServices::max_reverse_swap_amount] - Future maxReverseSwapAmount({dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kMaxReverseSwapAmountConstMeta; - - /// See [BreezServices::send_onchain] - Future sendOnchain({required SendOnchainRequest req, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kSendOnchainConstMeta; - /// See [BreezServices::pay_onchain] Future payOnchain({required PayOnchainRequest req, dynamic hint}); @@ -282,11 +272,6 @@ abstract class BreezSdkCore { FlutterRustBridgeTaskConstMeta get kListSwapsConstMeta; - /// See [BreezServices::in_progress_reverse_swaps] - Future> inProgressReverseSwaps({dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kInProgressReverseSwapsConstMeta; - /// See [BreezServices::claim_reverse_swap] Future claimReverseSwap({required String lockupAddress, dynamic hint}); @@ -1076,15 +1061,6 @@ class LspInformation { }); } -class MaxReverseSwapAmountResponse { - /// The total sats that can be sent onchain. - final int totalSat; - - const MaxReverseSwapAmountResponse({ - required this.totalSat, - }); -} - class MessageSuccessActionData { final String message; @@ -1364,6 +1340,7 @@ class PrepareOnchainPaymentResponse { final double feesPercentage; final int feesLockup; final int feesClaim; + final int feesService; final int senderAmountSat; final int recipientAmountSat; final int totalFees; @@ -1373,6 +1350,7 @@ class PrepareOnchainPaymentResponse { required this.feesPercentage, required this.feesLockup, required this.feesClaim, + required this.feesService, required this.senderAmountSat, required this.recipientAmountSat, required this.totalFees, @@ -1602,6 +1580,10 @@ class ReverseSwapInfo { final String? claimTxid; final int onchainAmountSat; final ReverseSwapStatus status; + final int feesLockup; + final int feesClaim; + final int feesService; + final int totalFees; const ReverseSwapInfo({ required this.id, @@ -1610,6 +1592,10 @@ class ReverseSwapInfo { this.claimTxid, required this.onchainAmountSat, required this.status, + required this.feesLockup, + required this.feesClaim, + required this.feesService, + required this.totalFees, }); } @@ -1704,28 +1690,6 @@ class RouteHintHop { }); } -class SendOnchainRequest { - final int amountSat; - final String onchainRecipientAddress; - final String pairHash; - final int satPerVbyte; - - const SendOnchainRequest({ - required this.amountSat, - required this.onchainRecipientAddress, - required this.pairHash, - required this.satPerVbyte, - }); -} - -class SendOnchainResponse { - final ReverseSwapInfo reverseSwapInfo; - - const SendOnchainResponse({ - required this.reverseSwapInfo, - }); -} - /// Represents a send payment request. class SendPaymentRequest { /// The bolt11 invoice @@ -2690,39 +2654,6 @@ class BreezSdkCoreImpl implements BreezSdkCore { argNames: [], ); - Future maxReverseSwapAmount({dynamic hint}) { - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_max_reverse_swap_amount(port_), - parseSuccessData: _wire2api_max_reverse_swap_amount_response, - parseErrorData: _wire2api_FrbAnyhowException, - constMeta: kMaxReverseSwapAmountConstMeta, - argValues: [], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kMaxReverseSwapAmountConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "max_reverse_swap_amount", - argNames: [], - ); - - Future sendOnchain({required SendOnchainRequest req, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_send_onchain_request(req); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_send_onchain(port_, arg0), - parseSuccessData: _wire2api_send_onchain_response, - parseErrorData: _wire2api_FrbAnyhowException, - constMeta: kSendOnchainConstMeta, - argValues: [req], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kSendOnchainConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "send_onchain", - argNames: ["req"], - ); - Future payOnchain({required PayOnchainRequest req, dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_pay_onchain_request(req); return _platform.executeNormal(FlutterRustBridgeTask( @@ -2927,22 +2858,6 @@ class BreezSdkCoreImpl implements BreezSdkCore { argNames: ["req"], ); - Future> inProgressReverseSwaps({dynamic hint}) { - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_in_progress_reverse_swaps(port_), - parseSuccessData: _wire2api_list_reverse_swap_info, - parseErrorData: _wire2api_FrbAnyhowException, - constMeta: kInProgressReverseSwapsConstMeta, - argValues: [], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kInProgressReverseSwapsConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "in_progress_reverse_swaps", - argNames: [], - ); - Future claimReverseSwap({required String lockupAddress, dynamic hint}) { var arg0 = _platform.api2wire_String(lockupAddress); return _platform.executeNormal(FlutterRustBridgeTask( @@ -3761,14 +3676,6 @@ class BreezSdkCoreImpl implements BreezSdkCore { ); } - MaxReverseSwapAmountResponse _wire2api_max_reverse_swap_amount_response(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return MaxReverseSwapAmountResponse( - totalSat: _wire2api_u64(arr[0]), - ); - } - MessageSuccessActionData _wire2api_message_success_action_data(dynamic raw) { final arr = raw as List; if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); @@ -3984,15 +3891,16 @@ class BreezSdkCoreImpl implements BreezSdkCore { PrepareOnchainPaymentResponse _wire2api_prepare_onchain_payment_response(dynamic raw) { final arr = raw as List; - if (arr.length != 7) throw Exception('unexpected arr length: expect 7 but see ${arr.length}'); + if (arr.length != 8) throw Exception('unexpected arr length: expect 8 but see ${arr.length}'); return PrepareOnchainPaymentResponse( feesHash: _wire2api_String(arr[0]), feesPercentage: _wire2api_f64(arr[1]), feesLockup: _wire2api_u64(arr[2]), feesClaim: _wire2api_u64(arr[3]), - senderAmountSat: _wire2api_u64(arr[4]), - recipientAmountSat: _wire2api_u64(arr[5]), - totalFees: _wire2api_u64(arr[6]), + feesService: _wire2api_u64(arr[4]), + senderAmountSat: _wire2api_u64(arr[5]), + recipientAmountSat: _wire2api_u64(arr[6]), + totalFees: _wire2api_u64(arr[7]), ); } @@ -4063,7 +3971,7 @@ class BreezSdkCoreImpl implements BreezSdkCore { ReverseSwapInfo _wire2api_reverse_swap_info(dynamic raw) { final arr = raw as List; - if (arr.length != 6) throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + if (arr.length != 10) throw Exception('unexpected arr length: expect 10 but see ${arr.length}'); return ReverseSwapInfo( id: _wire2api_String(arr[0]), claimPubkey: _wire2api_String(arr[1]), @@ -4071,6 +3979,10 @@ class BreezSdkCoreImpl implements BreezSdkCore { claimTxid: _wire2api_opt_String(arr[3]), onchainAmountSat: _wire2api_u64(arr[4]), status: _wire2api_reverse_swap_status(arr[5]), + feesLockup: _wire2api_u64(arr[6]), + feesClaim: _wire2api_u64(arr[7]), + feesService: _wire2api_u64(arr[8]), + totalFees: _wire2api_u64(arr[9]), ); } @@ -4114,14 +4026,6 @@ class BreezSdkCoreImpl implements BreezSdkCore { ); } - SendOnchainResponse _wire2api_send_onchain_response(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return SendOnchainResponse( - reverseSwapInfo: _wire2api_reverse_swap_info(arr[0]), - ); - } - SendPaymentResponse _wire2api_send_payment_response(dynamic raw) { final arr = raw as List; if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); @@ -4538,13 +4442,6 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { return ptr; } - @protected - ffi.Pointer api2wire_box_autoadd_send_onchain_request(SendOnchainRequest raw) { - final ptr = inner.new_box_autoadd_send_onchain_request_0(); - _api_fill_to_wire_send_onchain_request(raw, ptr.ref); - return ptr; - } - @protected ffi.Pointer api2wire_box_autoadd_send_payment_request(SendPaymentRequest raw) { final ptr = inner.new_box_autoadd_send_payment_request_0(); @@ -4826,11 +4723,6 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { _api_fill_to_wire_reverse_swap_fees_request(apiObj, wireObj.ref); } - void _api_fill_to_wire_box_autoadd_send_onchain_request( - SendOnchainRequest apiObj, ffi.Pointer wireObj) { - _api_fill_to_wire_send_onchain_request(apiObj, wireObj.ref); - } - void _api_fill_to_wire_box_autoadd_send_payment_request( SendPaymentRequest apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_send_payment_request(apiObj, wireObj.ref); @@ -5012,6 +4904,7 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { wireObj.fees_percentage = api2wire_f64(apiObj.feesPercentage); wireObj.fees_lockup = api2wire_u64(apiObj.feesLockup); wireObj.fees_claim = api2wire_u64(apiObj.feesClaim); + wireObj.fees_service = api2wire_u64(apiObj.feesService); wireObj.sender_amount_sat = api2wire_u64(apiObj.senderAmountSat); wireObj.recipient_amount_sat = api2wire_u64(apiObj.recipientAmountSat); wireObj.total_fees = api2wire_u64(apiObj.totalFees); @@ -5080,13 +4973,6 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { wireObj.claim_tx_feerate = api2wire_opt_box_autoadd_u32(apiObj.claimTxFeerate); } - void _api_fill_to_wire_send_onchain_request(SendOnchainRequest apiObj, wire_SendOnchainRequest wireObj) { - wireObj.amount_sat = api2wire_u64(apiObj.amountSat); - wireObj.onchain_recipient_address = api2wire_String(apiObj.onchainRecipientAddress); - wireObj.pair_hash = api2wire_String(apiObj.pairHash); - wireObj.sat_per_vbyte = api2wire_u32(apiObj.satPerVbyte); - } - void _api_fill_to_wire_send_payment_request(SendPaymentRequest apiObj, wire_SendPaymentRequest wireObj) { wireObj.bolt11 = api2wire_String(apiObj.bolt11); wireObj.use_trampoline = api2wire_bool(apiObj.useTrampoline); @@ -5766,35 +5652,6 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { _lookup>('wire_list_fiat_currencies'); late final _wire_list_fiat_currencies = _wire_list_fiat_currenciesPtr.asFunction(); - void wire_max_reverse_swap_amount( - int port_, - ) { - return _wire_max_reverse_swap_amount( - port_, - ); - } - - late final _wire_max_reverse_swap_amountPtr = - _lookup>('wire_max_reverse_swap_amount'); - late final _wire_max_reverse_swap_amount = - _wire_max_reverse_swap_amountPtr.asFunction(); - - void wire_send_onchain( - int port_, - ffi.Pointer req, - ) { - return _wire_send_onchain( - port_, - req, - ); - } - - late final _wire_send_onchainPtr = - _lookup)>>( - 'wire_send_onchain'); - late final _wire_send_onchain = - _wire_send_onchainPtr.asFunction)>(); - void wire_pay_onchain( int port_, ffi.Pointer req, @@ -5975,19 +5832,6 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { late final _wire_list_swaps = _wire_list_swapsPtr.asFunction)>(); - void wire_in_progress_reverse_swaps( - int port_, - ) { - return _wire_in_progress_reverse_swaps( - port_, - ); - } - - late final _wire_in_progress_reverse_swapsPtr = - _lookup>('wire_in_progress_reverse_swaps'); - late final _wire_in_progress_reverse_swaps = - _wire_in_progress_reverse_swapsPtr.asFunction(); - void wire_claim_reverse_swap( int port_, ffi.Pointer lockup_address, @@ -6398,16 +6242,6 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { late final _new_box_autoadd_reverse_swap_fees_request_0 = _new_box_autoadd_reverse_swap_fees_request_0Ptr .asFunction Function()>(); - ffi.Pointer new_box_autoadd_send_onchain_request_0() { - return _new_box_autoadd_send_onchain_request_0(); - } - - late final _new_box_autoadd_send_onchain_request_0Ptr = - _lookup Function()>>( - 'new_box_autoadd_send_onchain_request_0'); - late final _new_box_autoadd_send_onchain_request_0 = _new_box_autoadd_send_onchain_request_0Ptr - .asFunction Function()>(); - ffi.Pointer new_box_autoadd_send_payment_request_0() { return _new_box_autoadd_send_payment_request_0(); } @@ -6869,18 +6703,6 @@ final class wire_ReportIssueRequest extends ffi.Struct { external ffi.Pointer kind; } -final class wire_SendOnchainRequest extends ffi.Struct { - @ffi.Uint64() - external int amount_sat; - - external ffi.Pointer onchain_recipient_address; - - external ffi.Pointer pair_hash; - - @ffi.Uint32() - external int sat_per_vbyte; -} - final class wire_PrepareOnchainPaymentResponse extends ffi.Struct { external ffi.Pointer fees_hash; @@ -6893,6 +6715,9 @@ final class wire_PrepareOnchainPaymentResponse extends ffi.Struct { @ffi.Uint64() external int fees_claim; + @ffi.Uint64() + external int fees_service; + @ffi.Uint64() external int sender_amount_sat; diff --git a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt index ec83ee40e..2e0e2a6a6 100644 --- a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt +++ b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt @@ -1650,38 +1650,6 @@ fun asLspInformationList(arr: ReadableArray): List { return list } -fun asMaxReverseSwapAmountResponse(maxReverseSwapAmountResponse: ReadableMap): MaxReverseSwapAmountResponse? { - if (!validateMandatoryFields( - maxReverseSwapAmountResponse, - arrayOf( - "totalSat", - ), - ) - ) { - return null - } - val totalSat = maxReverseSwapAmountResponse.getDouble("totalSat").toULong() - return MaxReverseSwapAmountResponse( - totalSat, - ) -} - -fun readableMapOf(maxReverseSwapAmountResponse: MaxReverseSwapAmountResponse): ReadableMap = - readableMapOf( - "totalSat" to maxReverseSwapAmountResponse.totalSat, - ) - -fun asMaxReverseSwapAmountResponseList(arr: ReadableArray): List { - val list = ArrayList() - for (value in arr.toArrayList()) { - when (value) { - is ReadableMap -> list.add(asMaxReverseSwapAmountResponse(value)!!) - else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) - } - } - return list -} - fun asMessageSuccessActionData(messageSuccessActionData: ReadableMap): MessageSuccessActionData? { if (!validateMandatoryFields( messageSuccessActionData, @@ -2290,6 +2258,7 @@ fun asPrepareOnchainPaymentResponse(prepareOnchainPaymentResponse: ReadableMap): "feesPercentage", "feesLockup", "feesClaim", + "feesService", "senderAmountSat", "recipientAmountSat", "totalFees", @@ -2302,6 +2271,7 @@ fun asPrepareOnchainPaymentResponse(prepareOnchainPaymentResponse: ReadableMap): val feesPercentage = prepareOnchainPaymentResponse.getDouble("feesPercentage") val feesLockup = prepareOnchainPaymentResponse.getDouble("feesLockup").toULong() val feesClaim = prepareOnchainPaymentResponse.getDouble("feesClaim").toULong() + val feesService = prepareOnchainPaymentResponse.getDouble("feesService").toULong() val senderAmountSat = prepareOnchainPaymentResponse.getDouble("senderAmountSat").toULong() val recipientAmountSat = prepareOnchainPaymentResponse.getDouble("recipientAmountSat").toULong() val totalFees = prepareOnchainPaymentResponse.getDouble("totalFees").toULong() @@ -2310,6 +2280,7 @@ fun asPrepareOnchainPaymentResponse(prepareOnchainPaymentResponse: ReadableMap): feesPercentage, feesLockup, feesClaim, + feesService, senderAmountSat, recipientAmountSat, totalFees, @@ -2322,6 +2293,7 @@ fun readableMapOf(prepareOnchainPaymentResponse: PrepareOnchainPaymentResponse): "feesPercentage" to prepareOnchainPaymentResponse.feesPercentage, "feesLockup" to prepareOnchainPaymentResponse.feesLockup, "feesClaim" to prepareOnchainPaymentResponse.feesClaim, + "feesService" to prepareOnchainPaymentResponse.feesService, "senderAmountSat" to prepareOnchainPaymentResponse.senderAmountSat, "recipientAmountSat" to prepareOnchainPaymentResponse.recipientAmountSat, "totalFees" to prepareOnchainPaymentResponse.totalFees, @@ -2981,6 +2953,10 @@ fun asReverseSwapInfo(reverseSwapInfo: ReadableMap): ReverseSwapInfo? { "claimPubkey", "onchainAmountSat", "status", + "feesLockup", + "feesClaim", + "feesService", + "totalFees", ), ) ) { @@ -2992,6 +2968,10 @@ fun asReverseSwapInfo(reverseSwapInfo: ReadableMap): ReverseSwapInfo? { val claimTxid = if (hasNonNullKey(reverseSwapInfo, "claimTxid")) reverseSwapInfo.getString("claimTxid") else null val onchainAmountSat = reverseSwapInfo.getDouble("onchainAmountSat").toULong() val status = reverseSwapInfo.getString("status")?.let { asReverseSwapStatus(it) }!! + val feesLockup = reverseSwapInfo.getDouble("feesLockup").toULong() + val feesClaim = reverseSwapInfo.getDouble("feesClaim").toULong() + val feesService = reverseSwapInfo.getDouble("feesService").toULong() + val totalFees = reverseSwapInfo.getDouble("totalFees").toULong() return ReverseSwapInfo( id, claimPubkey, @@ -2999,6 +2979,10 @@ fun asReverseSwapInfo(reverseSwapInfo: ReadableMap): ReverseSwapInfo? { claimTxid, onchainAmountSat, status, + feesLockup, + feesClaim, + feesService, + totalFees, ) } @@ -3010,6 +2994,10 @@ fun readableMapOf(reverseSwapInfo: ReverseSwapInfo): ReadableMap = "claimTxid" to reverseSwapInfo.claimTxid, "onchainAmountSat" to reverseSwapInfo.onchainAmountSat, "status" to reverseSwapInfo.status.name.lowercase(), + "feesLockup" to reverseSwapInfo.feesLockup, + "feesClaim" to reverseSwapInfo.feesClaim, + "feesService" to reverseSwapInfo.feesService, + "totalFees" to reverseSwapInfo.totalFees, ) fun asReverseSwapInfoList(arr: ReadableArray): List { @@ -3164,82 +3152,6 @@ fun asRouteHintHopList(arr: ReadableArray): List { return list } -fun asSendOnchainRequest(sendOnchainRequest: ReadableMap): SendOnchainRequest? { - if (!validateMandatoryFields( - sendOnchainRequest, - arrayOf( - "amountSat", - "onchainRecipientAddress", - "pairHash", - "satPerVbyte", - ), - ) - ) { - return null - } - val amountSat = sendOnchainRequest.getDouble("amountSat").toULong() - val onchainRecipientAddress = sendOnchainRequest.getString("onchainRecipientAddress")!! - val pairHash = sendOnchainRequest.getString("pairHash")!! - val satPerVbyte = sendOnchainRequest.getInt("satPerVbyte").toUInt() - return SendOnchainRequest( - amountSat, - onchainRecipientAddress, - pairHash, - satPerVbyte, - ) -} - -fun readableMapOf(sendOnchainRequest: SendOnchainRequest): ReadableMap = - readableMapOf( - "amountSat" to sendOnchainRequest.amountSat, - "onchainRecipientAddress" to sendOnchainRequest.onchainRecipientAddress, - "pairHash" to sendOnchainRequest.pairHash, - "satPerVbyte" to sendOnchainRequest.satPerVbyte, - ) - -fun asSendOnchainRequestList(arr: ReadableArray): List { - val list = ArrayList() - for (value in arr.toArrayList()) { - when (value) { - is ReadableMap -> list.add(asSendOnchainRequest(value)!!) - else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) - } - } - return list -} - -fun asSendOnchainResponse(sendOnchainResponse: ReadableMap): SendOnchainResponse? { - if (!validateMandatoryFields( - sendOnchainResponse, - arrayOf( - "reverseSwapInfo", - ), - ) - ) { - return null - } - val reverseSwapInfo = sendOnchainResponse.getMap("reverseSwapInfo")?.let { asReverseSwapInfo(it) }!! - return SendOnchainResponse( - reverseSwapInfo, - ) -} - -fun readableMapOf(sendOnchainResponse: SendOnchainResponse): ReadableMap = - readableMapOf( - "reverseSwapInfo" to readableMapOf(sendOnchainResponse.reverseSwapInfo), - ) - -fun asSendOnchainResponseList(arr: ReadableArray): List { - val list = ArrayList() - for (value in arr.toArrayList()) { - when (value) { - is ReadableMap -> list.add(asSendOnchainResponse(value)!!) - else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) - } - } - return list -} - fun asSendPaymentRequest(sendPaymentRequest: ReadableMap): SendPaymentRequest? { if (!validateMandatoryFields( sendPaymentRequest, diff --git a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt index 4caa57c61..8800debe1 100644 --- a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt +++ b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKModule.kt @@ -829,18 +829,6 @@ class BreezSDKModule( } } - @ReactMethod - fun inProgressReverseSwaps(promise: Promise) { - executor.execute { - try { - val res = getBreezServices().inProgressReverseSwaps() - promise.resolve(readableArrayOf(res)) - } catch (e: Exception) { - promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) - } - } - } - @ReactMethod fun claimReverseSwap( lockupAddress: String, @@ -856,35 +844,6 @@ class BreezSDKModule( } } - @ReactMethod - fun maxReverseSwapAmount(promise: Promise) { - executor.execute { - try { - val res = getBreezServices().maxReverseSwapAmount() - promise.resolve(readableMapOf(res)) - } catch (e: Exception) { - promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) - } - } - } - - @ReactMethod - fun sendOnchain( - req: ReadableMap, - promise: Promise, - ) { - executor.execute { - try { - val sendOnchainRequest = - asSendOnchainRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SendOnchainRequest")) } - val res = getBreezServices().sendOnchain(sendOnchainRequest) - promise.resolve(readableMapOf(res)) - } catch (e: Exception) { - promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) - } - } - } - @ReactMethod fun payOnchain( req: ReadableMap, diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 76b7eef64..cb736a57b 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -1921,38 +1921,6 @@ enum BreezSDKMapper { return lspInformationList.map { v -> [String: Any?] in return dictionaryOf(lspInformation: v) } } - static func asMaxReverseSwapAmountResponse(maxReverseSwapAmountResponse: [String: Any?]) throws -> MaxReverseSwapAmountResponse { - guard let totalSat = maxReverseSwapAmountResponse["totalSat"] as? UInt64 else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "totalSat", typeName: "MaxReverseSwapAmountResponse")) - } - - return MaxReverseSwapAmountResponse( - totalSat: totalSat) - } - - static func dictionaryOf(maxReverseSwapAmountResponse: MaxReverseSwapAmountResponse) -> [String: Any?] { - return [ - "totalSat": maxReverseSwapAmountResponse.totalSat, - ] - } - - static func asMaxReverseSwapAmountResponseList(arr: [Any]) throws -> [MaxReverseSwapAmountResponse] { - var list = [MaxReverseSwapAmountResponse]() - for value in arr { - if let val = value as? [String: Any?] { - var maxReverseSwapAmountResponse = try asMaxReverseSwapAmountResponse(maxReverseSwapAmountResponse: val) - list.append(maxReverseSwapAmountResponse) - } else { - throw SdkError.Generic(message: errUnexpectedType(typeName: "MaxReverseSwapAmountResponse")) - } - } - return list - } - - static func arrayOf(maxReverseSwapAmountResponseList: [MaxReverseSwapAmountResponse]) -> [Any] { - return maxReverseSwapAmountResponseList.map { v -> [String: Any?] in return dictionaryOf(maxReverseSwapAmountResponse: v) } - } - static func asMessageSuccessActionData(messageSuccessActionData: [String: Any?]) throws -> MessageSuccessActionData { guard let message = messageSuccessActionData["message"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "message", typeName: "MessageSuccessActionData")) @@ -2659,6 +2627,9 @@ enum BreezSDKMapper { guard let feesClaim = prepareOnchainPaymentResponse["feesClaim"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesClaim", typeName: "PrepareOnchainPaymentResponse")) } + guard let feesService = prepareOnchainPaymentResponse["feesService"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesService", typeName: "PrepareOnchainPaymentResponse")) + } guard let senderAmountSat = prepareOnchainPaymentResponse["senderAmountSat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "senderAmountSat", typeName: "PrepareOnchainPaymentResponse")) } @@ -2674,6 +2645,7 @@ enum BreezSDKMapper { feesPercentage: feesPercentage, feesLockup: feesLockup, feesClaim: feesClaim, + feesService: feesService, senderAmountSat: senderAmountSat, recipientAmountSat: recipientAmountSat, totalFees: totalFees @@ -2686,6 +2658,7 @@ enum BreezSDKMapper { "feesPercentage": prepareOnchainPaymentResponse.feesPercentage, "feesLockup": prepareOnchainPaymentResponse.feesLockup, "feesClaim": prepareOnchainPaymentResponse.feesClaim, + "feesService": prepareOnchainPaymentResponse.feesService, "senderAmountSat": prepareOnchainPaymentResponse.senderAmountSat, "recipientAmountSat": prepareOnchainPaymentResponse.recipientAmountSat, "totalFees": prepareOnchainPaymentResponse.totalFees, @@ -3384,13 +3357,30 @@ enum BreezSDKMapper { } let status = try asReverseSwapStatus(reverseSwapStatus: statusTmp) + guard let feesLockup = reverseSwapInfo["feesLockup"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesLockup", typeName: "ReverseSwapInfo")) + } + guard let feesClaim = reverseSwapInfo["feesClaim"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesClaim", typeName: "ReverseSwapInfo")) + } + guard let feesService = reverseSwapInfo["feesService"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesService", typeName: "ReverseSwapInfo")) + } + guard let totalFees = reverseSwapInfo["totalFees"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "totalFees", typeName: "ReverseSwapInfo")) + } + return ReverseSwapInfo( id: id, claimPubkey: claimPubkey, lockupTxid: lockupTxid, claimTxid: claimTxid, onchainAmountSat: onchainAmountSat, - status: status + status: status, + feesLockup: feesLockup, + feesClaim: feesClaim, + feesService: feesService, + totalFees: totalFees ) } @@ -3402,6 +3392,10 @@ enum BreezSDKMapper { "claimTxid": reverseSwapInfo.claimTxid == nil ? nil : reverseSwapInfo.claimTxid, "onchainAmountSat": reverseSwapInfo.onchainAmountSat, "status": valueOf(reverseSwapStatus: reverseSwapInfo.status), + "feesLockup": reverseSwapInfo.feesLockup, + "feesClaim": reverseSwapInfo.feesClaim, + "feesService": reverseSwapInfo.feesService, + "totalFees": reverseSwapInfo.totalFees, ] } @@ -3593,87 +3587,6 @@ enum BreezSDKMapper { return routeHintHopList.map { v -> [String: Any?] in return dictionaryOf(routeHintHop: v) } } - static func asSendOnchainRequest(sendOnchainRequest: [String: Any?]) throws -> SendOnchainRequest { - guard let amountSat = sendOnchainRequest["amountSat"] as? UInt64 else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountSat", typeName: "SendOnchainRequest")) - } - guard let onchainRecipientAddress = sendOnchainRequest["onchainRecipientAddress"] as? String else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "onchainRecipientAddress", typeName: "SendOnchainRequest")) - } - guard let pairHash = sendOnchainRequest["pairHash"] as? String else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "pairHash", typeName: "SendOnchainRequest")) - } - guard let satPerVbyte = sendOnchainRequest["satPerVbyte"] as? UInt32 else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "satPerVbyte", typeName: "SendOnchainRequest")) - } - - return SendOnchainRequest( - amountSat: amountSat, - onchainRecipientAddress: onchainRecipientAddress, - pairHash: pairHash, - satPerVbyte: satPerVbyte - ) - } - - static func dictionaryOf(sendOnchainRequest: SendOnchainRequest) -> [String: Any?] { - return [ - "amountSat": sendOnchainRequest.amountSat, - "onchainRecipientAddress": sendOnchainRequest.onchainRecipientAddress, - "pairHash": sendOnchainRequest.pairHash, - "satPerVbyte": sendOnchainRequest.satPerVbyte, - ] - } - - static func asSendOnchainRequestList(arr: [Any]) throws -> [SendOnchainRequest] { - var list = [SendOnchainRequest]() - for value in arr { - if let val = value as? [String: Any?] { - var sendOnchainRequest = try asSendOnchainRequest(sendOnchainRequest: val) - list.append(sendOnchainRequest) - } else { - throw SdkError.Generic(message: errUnexpectedType(typeName: "SendOnchainRequest")) - } - } - return list - } - - static func arrayOf(sendOnchainRequestList: [SendOnchainRequest]) -> [Any] { - return sendOnchainRequestList.map { v -> [String: Any?] in return dictionaryOf(sendOnchainRequest: v) } - } - - static func asSendOnchainResponse(sendOnchainResponse: [String: Any?]) throws -> SendOnchainResponse { - guard let reverseSwapInfoTmp = sendOnchainResponse["reverseSwapInfo"] as? [String: Any?] else { - throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "reverseSwapInfo", typeName: "SendOnchainResponse")) - } - let reverseSwapInfo = try asReverseSwapInfo(reverseSwapInfo: reverseSwapInfoTmp) - - return SendOnchainResponse( - reverseSwapInfo: reverseSwapInfo) - } - - static func dictionaryOf(sendOnchainResponse: SendOnchainResponse) -> [String: Any?] { - return [ - "reverseSwapInfo": dictionaryOf(reverseSwapInfo: sendOnchainResponse.reverseSwapInfo), - ] - } - - static func asSendOnchainResponseList(arr: [Any]) throws -> [SendOnchainResponse] { - var list = [SendOnchainResponse]() - for value in arr { - if let val = value as? [String: Any?] { - var sendOnchainResponse = try asSendOnchainResponse(sendOnchainResponse: val) - list.append(sendOnchainResponse) - } else { - throw SdkError.Generic(message: errUnexpectedType(typeName: "SendOnchainResponse")) - } - } - return list - } - - static func arrayOf(sendOnchainResponseList: [SendOnchainResponse]) -> [Any] { - return sendOnchainResponseList.map { v -> [String: Any?] in return dictionaryOf(sendOnchainResponse: v) } - } - static func asSendPaymentRequest(sendPaymentRequest: [String: Any?]) throws -> SendPaymentRequest { guard let bolt11 = sendPaymentRequest["bolt11"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt11", typeName: "SendPaymentRequest")) diff --git a/libs/sdk-react-native/ios/RNBreezSDK.m b/libs/sdk-react-native/ios/RNBreezSDK.m index fdc9871de..c1a708fd3 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.m +++ b/libs/sdk-react-native/ios/RNBreezSDK.m @@ -289,28 +289,12 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter) reject: (RCTPromiseRejectBlock)reject ) -RCT_EXTERN_METHOD( - inProgressReverseSwaps: (RCTPromiseResolveBlock)resolve - reject: (RCTPromiseRejectBlock)reject -) - RCT_EXTERN_METHOD( claimReverseSwap: (NSString*)lockupAddress resolve: (RCTPromiseResolveBlock)resolve reject: (RCTPromiseRejectBlock)reject ) -RCT_EXTERN_METHOD( - maxReverseSwapAmount: (RCTPromiseResolveBlock)resolve - reject: (RCTPromiseRejectBlock)reject -) - -RCT_EXTERN_METHOD( - sendOnchain: (NSDictionary*)req - resolve: (RCTPromiseResolveBlock)resolve - reject: (RCTPromiseRejectBlock)reject -) - RCT_EXTERN_METHOD( payOnchain: (NSDictionary*)req resolve: (RCTPromiseResolveBlock)resolve diff --git a/libs/sdk-react-native/ios/RNBreezSDK.swift b/libs/sdk-react-native/ios/RNBreezSDK.swift index bd825395d..d3da30c2c 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.swift +++ b/libs/sdk-react-native/ios/RNBreezSDK.swift @@ -618,16 +618,6 @@ class RNBreezSDK: RCTEventEmitter { } } - @objc(inProgressReverseSwaps:reject:) - func inProgressReverseSwaps(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { - do { - var res = try getBreezServices().inProgressReverseSwaps() - resolve(BreezSDKMapper.arrayOf(reverseSwapInfoList: res)) - } catch let err { - rejectErr(err: err, reject: reject) - } - } - @objc(claimReverseSwap:resolve:reject:) func claimReverseSwap(_ lockupAddress: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { do { @@ -638,27 +628,6 @@ class RNBreezSDK: RCTEventEmitter { } } - @objc(maxReverseSwapAmount:reject:) - func maxReverseSwapAmount(_ resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { - do { - var res = try getBreezServices().maxReverseSwapAmount() - resolve(BreezSDKMapper.dictionaryOf(maxReverseSwapAmountResponse: res)) - } catch let err { - rejectErr(err: err, reject: reject) - } - } - - @objc(sendOnchain:resolve:reject:) - func sendOnchain(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { - do { - let sendOnchainRequest = try BreezSDKMapper.asSendOnchainRequest(sendOnchainRequest: req) - var res = try getBreezServices().sendOnchain(req: sendOnchainRequest) - resolve(BreezSDKMapper.dictionaryOf(sendOnchainResponse: res)) - } catch let err { - rejectErr(err: err, reject: reject) - } - } - @objc(payOnchain:resolve:reject:) func payOnchain(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { do { diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index a8e81b4c9..5bcd8312e 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -270,10 +270,6 @@ export interface LspInformation { openingFeeParamsList: OpeningFeeParamsMenu } -export interface MaxReverseSwapAmountResponse { - totalSat: number -} - export interface MessageSuccessActionData { message: string } @@ -373,6 +369,7 @@ export interface PrepareOnchainPaymentResponse { feesPercentage: number feesLockup: number feesClaim: number + feesService: number senderAmountSat: number recipientAmountSat: number totalFees: number @@ -468,6 +465,10 @@ export interface ReverseSwapInfo { claimTxid?: string onchainAmountSat: number status: ReverseSwapStatus + feesLockup: number + feesClaim: number + feesService: number + totalFees: number } export interface ReverseSwapPairInfo { @@ -494,17 +495,6 @@ export interface RouteHintHop { htlcMaximumMsat?: number } -export interface SendOnchainRequest { - amountSat: number - onchainRecipientAddress: string - pairHash: string - satPerVbyte: number -} - -export interface SendOnchainResponse { - reverseSwapInfo: ReverseSwapInfo -} - export interface SendPaymentRequest { bolt11: string useTrampoline: boolean @@ -1117,25 +1107,10 @@ export const inProgressOnchainPayments = async (): Promise => return response } -export const inProgressReverseSwaps = async (): Promise => { - const response = await BreezSDK.inProgressReverseSwaps() - return response -} - export const claimReverseSwap = async (lockupAddress: string): Promise => { await BreezSDK.claimReverseSwap(lockupAddress) } -export const maxReverseSwapAmount = async (): Promise => { - const response = await BreezSDK.maxReverseSwapAmount() - return response -} - -export const sendOnchain = async (req: SendOnchainRequest): Promise => { - const response = await BreezSDK.sendOnchain(req) - return response -} - export const payOnchain = async (req: PayOnchainRequest): Promise => { const response = await BreezSDK.payOnchain(req) return response diff --git a/tools/sdk-cli/src/command_handlers.rs b/tools/sdk-cli/src/command_handlers.rs index f93d283f6..d112debc6 100644 --- a/tools/sdk-cli/src/command_handlers.rs +++ b/tools/sdk-cli/src/command_handlers.rs @@ -10,7 +10,7 @@ use breez_sdk_core::{ LnUrlWithdrawRequest, MetadataFilter, PayOnchainRequest, PrepareOnchainPaymentRequest, PrepareRedeemOnchainFundsRequest, PrepareRefundRequest, ReceiveOnchainRequest, ReceivePaymentRequest, RedeemOnchainFundsRequest, RefundRequest, ReportIssueRequest, - ReportPaymentFailureDetails, ReverseSwapFeesRequest, SendOnchainRequest, SendPaymentRequest, + ReportPaymentFailureDetails, ReverseSwapFeesRequest, SendPaymentRequest, SendSpontaneousPaymentRequest, SignMessageRequest, StaticBackupRequest, SwapAmountType, }; use breez_sdk_core::{GreenlightNodeConfig, NodeConfig}; @@ -150,32 +150,6 @@ pub(crate) async fn handle_command( result.push_str(&build_qr_text(&recv_payment_response.ln_invoice.bolt11)); Ok(result) } - Commands::SendOnchain { - amount_sat, - onchain_recipient_address, - sat_per_vbyte, - } => { - let pair_info = sdk()? - .fetch_reverse_swap_fees(ReverseSwapFeesRequest::default()) - .await - .map_err(|e| anyhow!("Failed to fetch reverse swap fee infos: {e}"))?; - - #[allow(deprecated)] - let rev_swap_res = sdk()? - .send_onchain(SendOnchainRequest { - amount_sat, - onchain_recipient_address, - pair_hash: pair_info.fees_hash, - sat_per_vbyte, - }) - .await?; - serde_json::to_string_pretty(&rev_swap_res.reverse_swap_info).map_err(|e| e.into()) - } - Commands::MaxReverseSwapAmount {} => { - #[allow(deprecated)] - let response = sdk()?.max_reverse_swap_amount().await?; - serde_json::to_string_pretty(&response).map_err(|e| e.into()) - } Commands::OnchainPaymentLimits {} => { let response = sdk()?.onchain_payment_limits().await?; serde_json::to_string_pretty(&response).map_err(|e| e.into()) diff --git a/tools/sdk-cli/src/commands.rs b/tools/sdk-cli/src/commands.rs index c178066e4..4dd68b8f9 100644 --- a/tools/sdk-cli/src/commands.rs +++ b/tools/sdk-cli/src/commands.rs @@ -147,17 +147,6 @@ pub(crate) enum Commands { limit: Option, }, - /// [swap-out] Send on-chain using a reverse swap - SendOnchain { - amount_sat: u64, - onchain_recipient_address: String, - /// The fee rate for the claim transaction - sat_per_vbyte: u32, - }, - - /// [swap-out] The maximum amount that can be sent onchain with a reverse swap - MaxReverseSwapAmount {}, - /// [swap-out] Get the current fees for a potential new reverse swap FetchOnchainFees { #[clap(name = "amount", short = 'a', long = "amt")]