diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index 878a8aa7d..7856199af 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -460,6 +460,16 @@ interface LnUrlCallbackStatus { ErrorStatus(LnUrlErrorData data); }; +[Enum] +interface LnUrlWithdrawCallbackStatus { + Ok(LnUrlWithdrawOkData data); + ErrorStatus(LnUrlErrorData data); +}; + +dictionary LnUrlWithdrawOkData { + LNInvoice invoice; +}; + dictionary LnUrlAuthRequestData { string k1; string? action; @@ -514,7 +524,7 @@ interface BlockingBreezServices { LnUrlPayResult pay_lnurl(LnUrlPayRequestData req_data, u64 amount_sats, string? comment); [Throws=SdkError] - LnUrlCallbackStatus withdraw_lnurl(LnUrlWithdrawRequestData req_data, u64 amount_sats, string? description); + LnUrlWithdrawCallbackStatus withdraw_lnurl(LnUrlWithdrawRequestData req_data, u64 amount_sats, string? description); [Throws=SdkError] LnUrlCallbackStatus lnurl_auth(LnUrlAuthRequestData req_data); diff --git a/libs/sdk-bindings/src/uniffi_binding.rs b/libs/sdk-bindings/src/uniffi_binding.rs index 303ab56be..0e8575021 100644 --- a/libs/sdk-bindings/src/uniffi_binding.rs +++ b/libs/sdk-bindings/src/uniffi_binding.rs @@ -12,15 +12,16 @@ use breez_sdk_core::{ ClosedChannelPaymentDetails, Config, CurrencyInfo, EnvironmentType, EventListener, FeeratePreset, FiatCurrency, GreenlightCredentials, GreenlightNodeConfig, InputType, InvoicePaidDetails, LNInvoice, LnPaymentDetails, LnUrlAuthRequestData, LnUrlCallbackStatus, - LnUrlErrorData, LnUrlPayRequestData, LnUrlPayResult, LnUrlWithdrawRequestData, LocaleOverrides, - LocalizedName, LogEntry, LogStream, LspInformation, MessageSuccessActionData, MetadataItem, - Network, NodeConfig, NodeState, OpenChannelFeeRequest, OpenChannelFeeResponse, - OpeningFeeParams, OpeningFeeParamsMenu, Payment, PaymentDetails, PaymentFailedData, - PaymentType, PaymentTypeFilter, Rate, ReceiveOnchainRequest, ReceivePaymentRequest, - ReceivePaymentResponse, RecommendedFees, ReverseSwapFeesRequest, ReverseSwapInfo, - ReverseSwapPairInfo, ReverseSwapStatus, RouteHint, RouteHintHop, SignMessageRequest, - SignMessageResponse, StaticBackupRequest, StaticBackupResponse, SuccessActionProcessed, - SwapInfo, SwapStatus, Symbol, UnspentTransactionOutput, UrlSuccessActionData, + LnUrlErrorData, LnUrlPayRequestData, LnUrlPayResult, LnUrlWithdrawCallbackStatus, + LnUrlWithdrawOkData, LnUrlWithdrawRequestData, LocaleOverrides, LocalizedName, LogEntry, + LogStream, LspInformation, MessageSuccessActionData, MetadataItem, Network, NodeConfig, + NodeState, OpenChannelFeeRequest, OpenChannelFeeResponse, OpeningFeeParams, + OpeningFeeParamsMenu, Payment, PaymentDetails, PaymentFailedData, PaymentType, + PaymentTypeFilter, Rate, ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, + RecommendedFees, ReverseSwapFeesRequest, ReverseSwapInfo, ReverseSwapPairInfo, + ReverseSwapStatus, RouteHint, RouteHintHop, SignMessageRequest, SignMessageResponse, + StaticBackupRequest, StaticBackupResponse, SuccessActionProcessed, SwapInfo, SwapStatus, + Symbol, UnspentTransactionOutput, UrlSuccessActionData, }; static RT: Lazy = Lazy::new(|| tokio::runtime::Runtime::new().unwrap()); @@ -191,7 +192,7 @@ impl BlockingBreezServices { req_data: LnUrlWithdrawRequestData, amount_sats: u64, description: Option, - ) -> SdkResult { + ) -> SdkResult { rt().block_on( self.breez_services .lnurl_withdraw(req_data, amount_sats, description), diff --git a/libs/sdk-core/src/binding.rs b/libs/sdk-core/src/binding.rs index 23a0fa523..dfea6f594 100644 --- a/libs/sdk-core/src/binding.rs +++ b/libs/sdk-core/src/binding.rs @@ -32,9 +32,10 @@ use crate::lsp::LspInformation; use crate::models::{Config, LogEntry, NodeState, Payment, PaymentTypeFilter, SwapInfo}; use crate::{ BackupStatus, BuyBitcoinRequest, BuyBitcoinResponse, CheckMessageRequest, CheckMessageResponse, - EnvironmentType, LnUrlCallbackStatus, NodeConfig, ReceiveOnchainRequest, ReceivePaymentRequest, - ReceivePaymentResponse, ReverseSwapFeesRequest, ReverseSwapInfo, ReverseSwapPairInfo, - SignMessageRequest, SignMessageResponse, StaticBackupRequest, StaticBackupResponse, + EnvironmentType, LnUrlCallbackStatus, LnUrlWithdrawCallbackStatus, NodeConfig, + ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, ReverseSwapFeesRequest, + ReverseSwapInfo, ReverseSwapPairInfo, SignMessageRequest, SignMessageResponse, + StaticBackupRequest, StaticBackupResponse, }; static BREEZ_SERVICES_INSTANCE: OnceCell> = OnceCell::new(); @@ -269,7 +270,7 @@ pub fn lnurl_withdraw( req_data: LnUrlWithdrawRequestData, amount_sats: u64, description: Option, -) -> Result { +) -> Result { block_on(async { get_breez_services()? .lnurl_withdraw(req_data, amount_sats, description) diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index 6f590ae62..1d6b0bbcf 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -350,7 +350,7 @@ impl BreezServices { req_data: LnUrlWithdrawRequestData, amount_sats: u64, description: Option, - ) -> Result { + ) -> Result { let invoice = self .receive_payment(ReceivePaymentRequest { amount_sats, diff --git a/libs/sdk-core/src/bridge_generated.rs b/libs/sdk-core/src/bridge_generated.rs index c0c50928f..92677868d 100644 --- a/libs/sdk-core/src/bridge_generated.rs +++ b/libs/sdk-core/src/bridge_generated.rs @@ -61,6 +61,8 @@ use crate::models::GreenlightCredentials; use crate::models::GreenlightNodeConfig; use crate::models::LnPaymentDetails; use crate::models::LnUrlCallbackStatus; +use crate::models::LnUrlWithdrawCallbackStatus; +use crate::models::LnUrlWithdrawOkData; use crate::models::LogEntry; use crate::models::Network; use crate::models::NodeConfig; @@ -1065,6 +1067,23 @@ impl support::IntoDart for LnUrlPayResult { } } impl support::IntoDartExceptPrimitive for LnUrlPayResult {} +impl support::IntoDart for LnUrlWithdrawCallbackStatus { + fn into_dart(self) -> support::DartAbi { + match self { + Self::Ok { data } => vec![0.into_dart(), data.into_dart()], + Self::ErrorStatus { data } => vec![1.into_dart(), data.into_dart()], + } + .into_dart() + } +} +impl support::IntoDartExceptPrimitive for LnUrlWithdrawCallbackStatus {} +impl support::IntoDart for LnUrlWithdrawOkData { + fn into_dart(self) -> support::DartAbi { + vec![self.invoice.into_dart()].into_dart() + } +} +impl support::IntoDartExceptPrimitive for LnUrlWithdrawOkData {} + impl support::IntoDart for LnUrlWithdrawRequestData { fn into_dart(self) -> support::DartAbi { vec![ diff --git a/libs/sdk-core/src/lnurl/withdraw.rs b/libs/sdk-core/src/lnurl/withdraw.rs index ce7e7df98..5b69c2680 100644 --- a/libs/sdk-core/src/lnurl/withdraw.rs +++ b/libs/sdk-core/src/lnurl/withdraw.rs @@ -1,9 +1,9 @@ use std::str::FromStr; use crate::input_parser::get_parse_and_log_response; -use crate::{lnurl::*, LnUrlCallbackStatus}; +use crate::{lnurl::*, LnUrlCallbackStatus, LnUrlWithdrawCallbackStatus, LnUrlWithdrawOkData}; use crate::{LNInvoice, LnUrlWithdrawRequestData}; -use anyhow::{anyhow, Result}; +use anyhow::{anyhow, ensure, Result}; /// Validates invoice and performs the second and last step of LNURL-withdraw, as per /// @@ -16,23 +16,33 @@ use anyhow::{anyhow, Result}; pub(crate) async fn validate_lnurl_withdraw( req_data: LnUrlWithdrawRequestData, invoice: LNInvoice, -) -> Result { - match invoice +) -> Result { + let amount_msat = invoice .amount_msat .ok_or("Expected invoice amount, but found none") - .map_err(|e| anyhow!(e))? - { - n if n < req_data.min_withdrawable => Err(anyhow!( - "Amount is smaller than the minimum allowed by the LNURL-withdraw endpoint" - )), - n if n > req_data.max_withdrawable => Err(anyhow!( - "Amount is bigger than the maximum allowed by the LNURL-withdraw endpoint" - )), - _ => { - let callback_url = build_withdraw_callback_url(&req_data, &invoice)?; - get_parse_and_log_response(&callback_url).await + .map_err(|e| anyhow!(e))?; + + ensure!( + amount_msat >= req_data.min_withdrawable, + "Amount is smaller than the minimum allowed by the LNURL-withdraw endpoint" + ); + ensure!( + amount_msat <= req_data.max_withdrawable, + "Amount is bigger than the maximum allowed by the LNURL-withdraw endpoint" + ); + + let callback_url = build_withdraw_callback_url(&req_data, &invoice)?; + let callback_res: LnUrlCallbackStatus = get_parse_and_log_response(&callback_url).await?; + let withdraw_status = match callback_res { + LnUrlCallbackStatus::Ok => LnUrlWithdrawCallbackStatus::Ok { + data: LnUrlWithdrawOkData { invoice }, + }, + LnUrlCallbackStatus::ErrorStatus { data } => { + LnUrlWithdrawCallbackStatus::ErrorStatus { data } } - } + }; + + Ok(withdraw_status) } fn build_withdraw_callback_url( @@ -97,14 +107,14 @@ mod tests { #[tokio::test] async fn test_lnurl_withdraw_success() -> Result<()> { let invoice_str = "lnbc110n1p38q3gtpp5ypz09jrd8p993snjwnm68cph4ftwp22le34xd4r8ftspwshxhmnsdqqxqyjw5qcqpxsp5htlg8ydpywvsa7h3u4hdn77ehs4z4e844em0apjyvmqfkzqhhd2q9qgsqqqyssqszpxzxt9uuqzymr7zxcdccj5g69s8q7zzjs7sgxn9ejhnvdh6gqjcy22mss2yexunagm5r2gqczh8k24cwrqml3njskm548aruhpwssq9nvrvz"; - let invoice = crate::invoice::parse_invoice(invoice_str)?; + let req_invoice = crate::invoice::parse_invoice(invoice_str)?; let withdraw_req = get_test_withdraw_req_data(0, 100); - let _m = mock_lnurl_withdraw_callback(&withdraw_req, &invoice, None)?; + let _m = mock_lnurl_withdraw_callback(&withdraw_req, &req_invoice, None)?; assert!(matches!( - validate_lnurl_withdraw(withdraw_req, invoice).await?, - LnUrlCallbackStatus::Ok + validate_lnurl_withdraw(withdraw_req, req_invoice.clone()).await?, + LnUrlWithdrawCallbackStatus::Ok { data: LnUrlWithdrawOkData { invoice } } if invoice == req_invoice )); Ok(()) @@ -135,7 +145,7 @@ mod tests { assert!(matches!( validate_lnurl_withdraw(withdraw_req, invoice).await?, - LnUrlCallbackStatus::ErrorStatus { data: _ } + LnUrlWithdrawCallbackStatus::ErrorStatus { data: _ } )); Ok(()) diff --git a/libs/sdk-core/src/models.rs b/libs/sdk-core/src/models.rs index 621d5cb28..9474fae75 100644 --- a/libs/sdk-core/src/models.rs +++ b/libs/sdk-core/src/models.rs @@ -1074,7 +1074,7 @@ pub struct UnspentTransactionOutput { pub reserved_to_block: u32, } -//// Contains the result of the entire LNURL interaction, as reported by the LNURL endpoint. +/// Contains the result of the entire LNURL interaction, as reported by the LNURL endpoint. /// /// * `Ok` indicates the interaction with the endpoint was valid, and the endpoint /// - started to pay the invoice asynchronously in the case of LNURL-withdraw, @@ -1096,6 +1096,18 @@ pub enum LnUrlCallbackStatus { }, } +/// [LnUrlCallbackStatus] specific to LNURL-withdraw, where the success case contains the invoice. +#[derive(Serialize)] +pub enum LnUrlWithdrawCallbackStatus { + Ok { data: LnUrlWithdrawOkData }, + ErrorStatus { data: LnUrlErrorData }, +} + +#[derive(Deserialize, Debug, Serialize)] +pub struct LnUrlWithdrawOkData { + pub invoice: LNInvoice, +} + /// Different providers will demand different behaviours when the user is trying to buy bitcoin. #[derive(PartialEq, Eq, Debug, Clone, Deserialize, Serialize)] #[serde(tag = "buy_bitcoin_provider")] diff --git a/libs/sdk-flutter/lib/bridge_generated.dart b/libs/sdk-flutter/lib/bridge_generated.dart index 65ef66ee7..072ff3e9a 100644 --- a/libs/sdk-flutter/lib/bridge_generated.dart +++ b/libs/sdk-flutter/lib/bridge_generated.dart @@ -159,7 +159,7 @@ abstract class BreezSdkCore { FlutterRustBridgeTaskConstMeta get kLnurlPayConstMeta; /// See [BreezServices::lnurl_withdraw] - Future lnurlWithdraw( + Future lnurlWithdraw( {required LnUrlWithdrawRequestData reqData, required int amountSats, String? description, @@ -731,6 +731,24 @@ class LnUrlPayResult with _$LnUrlPayResult { }) = LnUrlPayResult_EndpointError; } +@freezed +class LnUrlWithdrawCallbackStatus with _$LnUrlWithdrawCallbackStatus { + const factory LnUrlWithdrawCallbackStatus.ok({ + required LnUrlWithdrawOkData data, + }) = LnUrlWithdrawCallbackStatus_Ok; + const factory LnUrlWithdrawCallbackStatus.errorStatus({ + required LnUrlErrorData data, + }) = LnUrlWithdrawCallbackStatus_ErrorStatus; +} + +class LnUrlWithdrawOkData { + final LNInvoice invoice; + + const LnUrlWithdrawOkData({ + required this.invoice, + }); +} + /// Wrapped in a [LnUrlWithdraw], this is the result of [parse] when given a LNURL-withdraw endpoint. /// /// It represents the endpoint's parameters for the LNURL workflow. @@ -1831,7 +1849,7 @@ class BreezSdkCoreImpl implements BreezSdkCore { argNames: ["userAmountSat", "comment", "reqData"], ); - Future lnurlWithdraw( + Future lnurlWithdraw( {required LnUrlWithdrawRequestData reqData, required int amountSats, String? description, @@ -1841,7 +1859,7 @@ class BreezSdkCoreImpl implements BreezSdkCore { var arg2 = _platform.api2wire_opt_String(description); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_lnurl_withdraw(port_, arg0, arg1, arg2), - parseSuccessData: _wire2api_ln_url_callback_status, + parseSuccessData: _wire2api_ln_url_withdraw_callback_status, constMeta: kLnurlWithdrawConstMeta, argValues: [reqData, amountSats, description], hint: hint, @@ -2190,6 +2208,10 @@ class BreezSdkCoreImpl implements BreezSdkCore { return _wire2api_ln_url_pay_request_data(raw); } + LnUrlWithdrawOkData _wire2api_box_autoadd_ln_url_withdraw_ok_data(dynamic raw) { + return _wire2api_ln_url_withdraw_ok_data(raw); + } + LnUrlWithdrawRequestData _wire2api_box_autoadd_ln_url_withdraw_request_data(dynamic raw) { return _wire2api_ln_url_withdraw_request_data(raw); } @@ -2562,6 +2584,29 @@ class BreezSdkCoreImpl implements BreezSdkCore { } } + LnUrlWithdrawCallbackStatus _wire2api_ln_url_withdraw_callback_status(dynamic raw) { + switch (raw[0]) { + case 0: + return LnUrlWithdrawCallbackStatus_Ok( + data: _wire2api_box_autoadd_ln_url_withdraw_ok_data(raw[1]), + ); + case 1: + return LnUrlWithdrawCallbackStatus_ErrorStatus( + data: _wire2api_box_autoadd_ln_url_error_data(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + LnUrlWithdrawOkData _wire2api_ln_url_withdraw_ok_data(dynamic raw) { + final arr = raw as List; + if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return LnUrlWithdrawOkData( + invoice: _wire2api_ln_invoice(arr[0]), + ); + } + LnUrlWithdrawRequestData _wire2api_ln_url_withdraw_request_data(dynamic raw) { final arr = raw as List; if (arr.length != 5) throw Exception('unexpected arr length: expect 5 but see ${arr.length}'); diff --git a/libs/sdk-flutter/lib/bridge_generated.freezed.dart b/libs/sdk-flutter/lib/bridge_generated.freezed.dart index 0d79fe4c8..b57d5624c 100644 --- a/libs/sdk-flutter/lib/bridge_generated.freezed.dart +++ b/libs/sdk-flutter/lib/bridge_generated.freezed.dart @@ -3431,6 +3431,339 @@ abstract class LnUrlPayResult_EndpointError implements LnUrlPayResult { throw _privateConstructorUsedError; } +/// @nodoc +mixin _$LnUrlWithdrawCallbackStatus { + Object get data => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(LnUrlWithdrawOkData data) ok, + required TResult Function(LnUrlErrorData data) errorStatus, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(LnUrlWithdrawOkData data)? ok, + TResult? Function(LnUrlErrorData data)? errorStatus, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(LnUrlWithdrawOkData data)? ok, + TResult Function(LnUrlErrorData data)? errorStatus, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(LnUrlWithdrawCallbackStatus_Ok value) ok, + required TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value) errorStatus, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult? Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LnUrlWithdrawCallbackStatusCopyWith<$Res> { + factory $LnUrlWithdrawCallbackStatusCopyWith( + LnUrlWithdrawCallbackStatus value, $Res Function(LnUrlWithdrawCallbackStatus) then) = + _$LnUrlWithdrawCallbackStatusCopyWithImpl<$Res, LnUrlWithdrawCallbackStatus>; +} + +/// @nodoc +class _$LnUrlWithdrawCallbackStatusCopyWithImpl<$Res, $Val extends LnUrlWithdrawCallbackStatus> + implements $LnUrlWithdrawCallbackStatusCopyWith<$Res> { + _$LnUrlWithdrawCallbackStatusCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$LnUrlWithdrawCallbackStatus_OkCopyWith<$Res> { + factory _$$LnUrlWithdrawCallbackStatus_OkCopyWith( + _$LnUrlWithdrawCallbackStatus_Ok value, $Res Function(_$LnUrlWithdrawCallbackStatus_Ok) then) = + __$$LnUrlWithdrawCallbackStatus_OkCopyWithImpl<$Res>; + @useResult + $Res call({LnUrlWithdrawOkData data}); +} + +/// @nodoc +class __$$LnUrlWithdrawCallbackStatus_OkCopyWithImpl<$Res> + extends _$LnUrlWithdrawCallbackStatusCopyWithImpl<$Res, _$LnUrlWithdrawCallbackStatus_Ok> + implements _$$LnUrlWithdrawCallbackStatus_OkCopyWith<$Res> { + __$$LnUrlWithdrawCallbackStatus_OkCopyWithImpl( + _$LnUrlWithdrawCallbackStatus_Ok _value, $Res Function(_$LnUrlWithdrawCallbackStatus_Ok) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + }) { + return _then(_$LnUrlWithdrawCallbackStatus_Ok( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as LnUrlWithdrawOkData, + )); + } +} + +/// @nodoc + +class _$LnUrlWithdrawCallbackStatus_Ok implements LnUrlWithdrawCallbackStatus_Ok { + const _$LnUrlWithdrawCallbackStatus_Ok({required this.data}); + + @override + final LnUrlWithdrawOkData data; + + @override + String toString() { + return 'LnUrlWithdrawCallbackStatus.ok(data: $data)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LnUrlWithdrawCallbackStatus_Ok && + (identical(other.data, data) || other.data == data)); + } + + @override + int get hashCode => Object.hash(runtimeType, data); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LnUrlWithdrawCallbackStatus_OkCopyWith<_$LnUrlWithdrawCallbackStatus_Ok> get copyWith => + __$$LnUrlWithdrawCallbackStatus_OkCopyWithImpl<_$LnUrlWithdrawCallbackStatus_Ok>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(LnUrlWithdrawOkData data) ok, + required TResult Function(LnUrlErrorData data) errorStatus, + }) { + return ok(data); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(LnUrlWithdrawOkData data)? ok, + TResult? Function(LnUrlErrorData data)? errorStatus, + }) { + return ok?.call(data); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(LnUrlWithdrawOkData data)? ok, + TResult Function(LnUrlErrorData data)? errorStatus, + required TResult orElse(), + }) { + if (ok != null) { + return ok(data); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(LnUrlWithdrawCallbackStatus_Ok value) ok, + required TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value) errorStatus, + }) { + return ok(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult? Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + }) { + return ok?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + required TResult orElse(), + }) { + if (ok != null) { + return ok(this); + } + return orElse(); + } +} + +abstract class LnUrlWithdrawCallbackStatus_Ok implements LnUrlWithdrawCallbackStatus { + const factory LnUrlWithdrawCallbackStatus_Ok({required final LnUrlWithdrawOkData data}) = + _$LnUrlWithdrawCallbackStatus_Ok; + + @override + LnUrlWithdrawOkData get data; + @JsonKey(ignore: true) + _$$LnUrlWithdrawCallbackStatus_OkCopyWith<_$LnUrlWithdrawCallbackStatus_Ok> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWith<$Res> { + factory _$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWith(_$LnUrlWithdrawCallbackStatus_ErrorStatus value, + $Res Function(_$LnUrlWithdrawCallbackStatus_ErrorStatus) then) = + __$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWithImpl<$Res>; + @useResult + $Res call({LnUrlErrorData data}); +} + +/// @nodoc +class __$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWithImpl<$Res> + extends _$LnUrlWithdrawCallbackStatusCopyWithImpl<$Res, _$LnUrlWithdrawCallbackStatus_ErrorStatus> + implements _$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWith<$Res> { + __$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWithImpl(_$LnUrlWithdrawCallbackStatus_ErrorStatus _value, + $Res Function(_$LnUrlWithdrawCallbackStatus_ErrorStatus) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? data = null, + }) { + return _then(_$LnUrlWithdrawCallbackStatus_ErrorStatus( + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as LnUrlErrorData, + )); + } +} + +/// @nodoc + +class _$LnUrlWithdrawCallbackStatus_ErrorStatus implements LnUrlWithdrawCallbackStatus_ErrorStatus { + const _$LnUrlWithdrawCallbackStatus_ErrorStatus({required this.data}); + + @override + final LnUrlErrorData data; + + @override + String toString() { + return 'LnUrlWithdrawCallbackStatus.errorStatus(data: $data)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LnUrlWithdrawCallbackStatus_ErrorStatus && + (identical(other.data, data) || other.data == data)); + } + + @override + int get hashCode => Object.hash(runtimeType, data); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWith<_$LnUrlWithdrawCallbackStatus_ErrorStatus> + get copyWith => + __$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWithImpl<_$LnUrlWithdrawCallbackStatus_ErrorStatus>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(LnUrlWithdrawOkData data) ok, + required TResult Function(LnUrlErrorData data) errorStatus, + }) { + return errorStatus(data); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(LnUrlWithdrawOkData data)? ok, + TResult? Function(LnUrlErrorData data)? errorStatus, + }) { + return errorStatus?.call(data); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(LnUrlWithdrawOkData data)? ok, + TResult Function(LnUrlErrorData data)? errorStatus, + required TResult orElse(), + }) { + if (errorStatus != null) { + return errorStatus(data); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(LnUrlWithdrawCallbackStatus_Ok value) ok, + required TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value) errorStatus, + }) { + return errorStatus(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult? Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + }) { + return errorStatus?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(LnUrlWithdrawCallbackStatus_Ok value)? ok, + TResult Function(LnUrlWithdrawCallbackStatus_ErrorStatus value)? errorStatus, + required TResult orElse(), + }) { + if (errorStatus != null) { + return errorStatus(this); + } + return orElse(); + } +} + +abstract class LnUrlWithdrawCallbackStatus_ErrorStatus implements LnUrlWithdrawCallbackStatus { + const factory LnUrlWithdrawCallbackStatus_ErrorStatus({required final LnUrlErrorData data}) = + _$LnUrlWithdrawCallbackStatus_ErrorStatus; + + @override + LnUrlErrorData get data; + @JsonKey(ignore: true) + _$$LnUrlWithdrawCallbackStatus_ErrorStatusCopyWith<_$LnUrlWithdrawCallbackStatus_ErrorStatus> + get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc mixin _$NodeConfig { GreenlightNodeConfig get config => throw _privateConstructorUsedError;