diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index 07310ef7f..828324273 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -734,6 +734,7 @@ dictionary RecommendedFees { interface InputType { BitcoinAddress(BitcoinAddressData address); Bolt11(LNInvoice invoice); + Bolt12(string offer); NodeId(string node_id); Url(string url); LnUrlPay(LnUrlPayRequestData data); diff --git a/libs/sdk-common/src/input_parser.rs b/libs/sdk-common/src/input_parser.rs index fc8b8d3cb..6cdd6aa2a 100644 --- a/libs/sdk-common/src/input_parser.rs +++ b/libs/sdk-common/src/input_parser.rs @@ -4,6 +4,7 @@ use ::bip21::Uri; use anyhow::{anyhow, Result}; use bitcoin::bech32; use bitcoin::bech32::FromBase32; +use lightning::offers::offer::Offer; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use LnUrlRequestData::*; @@ -185,6 +186,12 @@ pub async fn parse(input: &str) -> Result { return Ok(InputType::Bolt11 { invoice }); } + if let Ok(offer) = input.parse::() { + return Ok(InputType::Bolt12 { + offer: offer.to_string(), + }); + } + // Public key serialized in compressed form (66 hex chars) if let Ok(_node_id) = bitcoin::secp256k1::PublicKey::from_str(input) { return Ok(InputType::NodeId { @@ -418,6 +425,9 @@ pub enum InputType { Bolt11 { invoice: LNInvoice, }, + Bolt12 { + offer: String, + }, NodeId { node_id: String, }, @@ -926,6 +936,19 @@ pub(crate) mod tests { Ok(()) } + #[tokio::test] + async fn test_bolt12_offer() -> Result<()> { + let bolt12_offer = "lno1pqpzwyq2p32x2um5ypmx2cm5dae8x93pqthvwfzadd7jejes8q9lhc4rvjxd022zv5l44g6qah82ru5rdpnpj"; + + assert!(matches!( + parse(bolt12_offer).await?, + InputType::Bolt12 { offer } + if offer == bolt12_offer + )); + + Ok(()) + } + #[tokio::test] async fn test_url() -> Result<()> { assert!(matches!( diff --git a/libs/sdk-core/src/binding.rs b/libs/sdk-core/src/binding.rs index d4636cce8..3d0b4409e 100644 --- a/libs/sdk-core/src/binding.rs +++ b/libs/sdk-core/src/binding.rs @@ -162,6 +162,7 @@ pub struct _LnUrlWithdrawRequestData { pub enum _InputType { BitcoinAddress { address: BitcoinAddressData }, Bolt11 { invoice: LNInvoice }, + Bolt12 { offer: String }, NodeId { node_id: String }, Url { url: String }, LnUrlPay { data: LnUrlPayRequestData }, diff --git a/libs/sdk-core/src/bridge_generated.rs b/libs/sdk-core/src/bridge_generated.rs index 5d6c32529..7f1a6b48e 100644 --- a/libs/sdk-core/src/bridge_generated.rs +++ b/libs/sdk-core/src/bridge_generated.rs @@ -1025,6 +1025,9 @@ const _: fn() = || { InputType::Bolt11 { invoice } => { let _: LNInvoice = invoice; } + InputType::Bolt12 { offer } => { + let _: String = offer; + } InputType::NodeId { node_id } => { let _: String = node_id; } @@ -1613,17 +1616,18 @@ impl support::IntoDart for mirror_InputType { InputType::Bolt11 { invoice } => { vec![1.into_dart(), invoice.into_into_dart().into_dart()] } + InputType::Bolt12 { offer } => vec![2.into_dart(), offer.into_into_dart().into_dart()], InputType::NodeId { node_id } => { - vec![2.into_dart(), node_id.into_into_dart().into_dart()] + vec![3.into_dart(), node_id.into_into_dart().into_dart()] } - InputType::Url { url } => vec![3.into_dart(), url.into_into_dart().into_dart()], - InputType::LnUrlPay { data } => vec![4.into_dart(), data.into_into_dart().into_dart()], + InputType::Url { url } => vec![4.into_dart(), url.into_into_dart().into_dart()], + InputType::LnUrlPay { data } => vec![5.into_dart(), data.into_into_dart().into_dart()], InputType::LnUrlWithdraw { data } => { - vec![5.into_dart(), data.into_into_dart().into_dart()] + vec![6.into_dart(), data.into_into_dart().into_dart()] } - InputType::LnUrlAuth { data } => vec![6.into_dart(), data.into_into_dart().into_dart()], + InputType::LnUrlAuth { data } => vec![7.into_dart(), data.into_into_dart().into_dart()], InputType::LnUrlError { data } => { - vec![7.into_dart(), data.into_into_dart().into_dart()] + vec![8.into_dart(), data.into_into_dart().into_dart()] } } .into_dart() diff --git a/libs/sdk-flutter/lib/bridge_generated.dart b/libs/sdk-flutter/lib/bridge_generated.dart index 7ac7d374a..427038d93 100644 --- a/libs/sdk-flutter/lib/bridge_generated.dart +++ b/libs/sdk-flutter/lib/bridge_generated.dart @@ -670,6 +670,9 @@ sealed class InputType with _$InputType { const factory InputType.bolt11({ required LNInvoice invoice, }) = InputType_Bolt11; + const factory InputType.bolt12({ + required String offer, + }) = InputType_Bolt12; const factory InputType.nodeId({ required String nodeId, }) = InputType_NodeId; @@ -3421,26 +3424,30 @@ class BreezSdkCoreImpl implements BreezSdkCore { invoice: _wire2api_box_autoadd_ln_invoice(raw[1]), ); case 2: + return InputType_Bolt12( + offer: _wire2api_String(raw[1]), + ); + case 3: return InputType_NodeId( nodeId: _wire2api_String(raw[1]), ); - case 3: + case 4: return InputType_Url( url: _wire2api_String(raw[1]), ); - case 4: + case 5: return InputType_LnUrlPay( data: _wire2api_box_autoadd_ln_url_pay_request_data(raw[1]), ); - case 5: + case 6: return InputType_LnUrlWithdraw( data: _wire2api_box_autoadd_ln_url_withdraw_request_data(raw[1]), ); - case 6: + case 7: return InputType_LnUrlAuth( data: _wire2api_box_autoadd_ln_url_auth_request_data(raw[1]), ); - case 7: + case 8: return InputType_LnUrlError( data: _wire2api_box_autoadd_ln_url_error_data(raw[1]), ); diff --git a/libs/sdk-flutter/lib/bridge_generated.freezed.dart b/libs/sdk-flutter/lib/bridge_generated.freezed.dart index 15ddfc256..3a169ac53 100644 --- a/libs/sdk-flutter/lib/bridge_generated.freezed.dart +++ b/libs/sdk-flutter/lib/bridge_generated.freezed.dart @@ -2180,6 +2180,7 @@ mixin _$InputType { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2192,6 +2193,7 @@ mixin _$InputType { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2204,6 +2206,7 @@ mixin _$InputType { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2217,6 +2220,7 @@ mixin _$InputType { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2229,6 +2233,7 @@ mixin _$InputType { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2241,6 +2246,7 @@ mixin _$InputType { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2334,6 +2340,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2349,6 +2356,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2364,6 +2372,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2383,6 +2392,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2398,6 +2408,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2413,6 +2424,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2503,6 +2515,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2518,6 +2531,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2533,6 +2547,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2552,6 +2567,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2567,6 +2583,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2582,6 +2599,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2605,6 +2623,179 @@ abstract class InputType_Bolt11 implements InputType { _$$InputType_Bolt11ImplCopyWith<_$InputType_Bolt11Impl> get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$InputType_Bolt12ImplCopyWith<$Res> { + factory _$$InputType_Bolt12ImplCopyWith( + _$InputType_Bolt12Impl value, $Res Function(_$InputType_Bolt12Impl) then) = + __$$InputType_Bolt12ImplCopyWithImpl<$Res>; + @useResult + $Res call({String offer}); +} + +/// @nodoc +class __$$InputType_Bolt12ImplCopyWithImpl<$Res> extends _$InputTypeCopyWithImpl<$Res, _$InputType_Bolt12Impl> + implements _$$InputType_Bolt12ImplCopyWith<$Res> { + __$$InputType_Bolt12ImplCopyWithImpl( + _$InputType_Bolt12Impl _value, $Res Function(_$InputType_Bolt12Impl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? offer = null, + }) { + return _then(_$InputType_Bolt12Impl( + offer: null == offer + ? _value.offer + : offer // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$InputType_Bolt12Impl implements InputType_Bolt12 { + const _$InputType_Bolt12Impl({required this.offer}); + + @override + final String offer; + + @override + String toString() { + return 'InputType.bolt12(offer: $offer)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InputType_Bolt12Impl && + (identical(other.offer, offer) || other.offer == offer)); + } + + @override + int get hashCode => Object.hash(runtimeType, offer); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$InputType_Bolt12ImplCopyWith<_$InputType_Bolt12Impl> get copyWith => + __$$InputType_Bolt12ImplCopyWithImpl<_$InputType_Bolt12Impl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(BitcoinAddressData address) bitcoinAddress, + required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, + required TResult Function(String nodeId) nodeId, + required TResult Function(String url) url, + required TResult Function(LnUrlPayRequestData data) lnUrlPay, + required TResult Function(LnUrlWithdrawRequestData data) lnUrlWithdraw, + required TResult Function(LnUrlAuthRequestData data) lnUrlAuth, + required TResult Function(LnUrlErrorData data) lnUrlError, + }) { + return bolt12(offer); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(BitcoinAddressData address)? bitcoinAddress, + TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, + TResult? Function(String nodeId)? nodeId, + TResult? Function(String url)? url, + TResult? Function(LnUrlPayRequestData data)? lnUrlPay, + TResult? Function(LnUrlWithdrawRequestData data)? lnUrlWithdraw, + TResult? Function(LnUrlAuthRequestData data)? lnUrlAuth, + TResult? Function(LnUrlErrorData data)? lnUrlError, + }) { + return bolt12?.call(offer); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(BitcoinAddressData address)? bitcoinAddress, + TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, + TResult Function(String nodeId)? nodeId, + TResult Function(String url)? url, + TResult Function(LnUrlPayRequestData data)? lnUrlPay, + TResult Function(LnUrlWithdrawRequestData data)? lnUrlWithdraw, + TResult Function(LnUrlAuthRequestData data)? lnUrlAuth, + TResult Function(LnUrlErrorData data)? lnUrlError, + required TResult orElse(), + }) { + if (bolt12 != null) { + return bolt12(offer); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, + required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, + required TResult Function(InputType_NodeId value) nodeId, + required TResult Function(InputType_Url value) url, + required TResult Function(InputType_LnUrlPay value) lnUrlPay, + required TResult Function(InputType_LnUrlWithdraw value) lnUrlWithdraw, + required TResult Function(InputType_LnUrlAuth value) lnUrlAuth, + required TResult Function(InputType_LnUrlError value) lnUrlError, + }) { + return bolt12(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, + TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, + TResult? Function(InputType_NodeId value)? nodeId, + TResult? Function(InputType_Url value)? url, + TResult? Function(InputType_LnUrlPay value)? lnUrlPay, + TResult? Function(InputType_LnUrlWithdraw value)? lnUrlWithdraw, + TResult? Function(InputType_LnUrlAuth value)? lnUrlAuth, + TResult? Function(InputType_LnUrlError value)? lnUrlError, + }) { + return bolt12?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, + TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, + TResult Function(InputType_NodeId value)? nodeId, + TResult Function(InputType_Url value)? url, + TResult Function(InputType_LnUrlPay value)? lnUrlPay, + TResult Function(InputType_LnUrlWithdraw value)? lnUrlWithdraw, + TResult Function(InputType_LnUrlAuth value)? lnUrlAuth, + TResult Function(InputType_LnUrlError value)? lnUrlError, + required TResult orElse(), + }) { + if (bolt12 != null) { + return bolt12(this); + } + return orElse(); + } +} + +abstract class InputType_Bolt12 implements InputType { + const factory InputType_Bolt12({required final String offer}) = _$InputType_Bolt12Impl; + + String get offer; + @JsonKey(ignore: true) + _$$InputType_Bolt12ImplCopyWith<_$InputType_Bolt12Impl> get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc abstract class _$$InputType_NodeIdImplCopyWith<$Res> { factory _$$InputType_NodeIdImplCopyWith( @@ -2670,6 +2861,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2685,6 +2877,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2700,6 +2893,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2719,6 +2913,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2734,6 +2929,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2749,6 +2945,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2835,6 +3032,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2850,6 +3048,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2865,6 +3064,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2884,6 +3084,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2899,6 +3100,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2914,6 +3116,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3003,6 +3206,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3018,6 +3222,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3033,6 +3238,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3052,6 +3258,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3067,6 +3274,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3082,6 +3290,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3172,6 +3381,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3187,6 +3397,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3202,6 +3413,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3221,6 +3433,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3236,6 +3449,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3251,6 +3465,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3342,6 +3557,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3357,6 +3573,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3372,6 +3589,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3391,6 +3609,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3406,6 +3625,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3421,6 +3641,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3511,6 +3732,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(String offer) bolt12, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3526,6 +3748,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(String offer)? bolt12, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3541,6 +3764,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(String offer)? bolt12, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3560,6 +3784,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12 value) bolt12, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3575,6 +3800,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12 value)? bolt12, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3590,6 +3816,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12 value)? bolt12, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, 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 27f2a4945..c6fb8af6c 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 @@ -3987,6 +3987,9 @@ fun asInputType(inputType: ReadableMap): InputType? { if (type == "bolt11") { return InputType.Bolt11(inputType.getMap("invoice")?.let { asLnInvoice(it) }!!) } + if (type == "bolt12") { + return InputType.Bolt12(inputType.getString("offer")!!) + } if (type == "nodeId") { return InputType.NodeId(inputType.getString("nodeId")!!) } @@ -4019,6 +4022,10 @@ fun readableMapOf(inputType: InputType): ReadableMap? { pushToMap(map, "type", "bolt11") pushToMap(map, "invoice", readableMapOf(inputType.invoice)) } + is InputType.Bolt12 -> { + pushToMap(map, "type", "bolt12") + pushToMap(map, "offer", inputType.offer) + } is InputType.NodeId -> { pushToMap(map, "type", "nodeId") pushToMap(map, "nodeId", inputType.nodeId) diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 012eecd30..4bfe0a79c 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -4722,6 +4722,12 @@ enum BreezSDKMapper { return InputType.bolt11(invoice: _invoice) } + if type == "bolt12" { + guard let _offer = inputType["offer"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "offer", typeName: "InputType")) + } + return InputType.bolt12(offer: _offer) + } if type == "nodeId" { guard let _nodeId = inputType["nodeId"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "nodeId", typeName: "InputType")) @@ -4788,6 +4794,14 @@ enum BreezSDKMapper { "invoice": dictionaryOf(lnInvoice: invoice), ] + case let .bolt12( + offer + ): + return [ + "type": "bolt12", + "offer": offer, + ] + case let .nodeId( nodeId ): diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index 5225c062e..2bf4e885f 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -674,6 +674,7 @@ export enum HealthCheckStatus { export enum InputTypeVariant { BITCOIN_ADDRESS = "bitcoinAddress", BOLT11 = "bolt11", + BOLT12 = "bolt12", NODE_ID = "nodeId", URL = "url", LN_URL_PAY = "lnUrlPay", @@ -688,6 +689,9 @@ export type InputType = { } | { type: InputTypeVariant.BOLT11, invoice: LnInvoice +} | { + type: InputTypeVariant.BOLT12, + offer: string } | { type: InputTypeVariant.NODE_ID, nodeId: string