From ad384b106bfcee3e225625b879b153f398b6ee7f Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Fri, 5 Jul 2024 20:48:30 +0200 Subject: [PATCH] Squash and rebase Bolt12 implementation --- libs/Cargo.lock | 33 +- libs/Cargo.toml | 6 +- libs/sdk-bindings/src/breez_sdk.udl | 41 +- libs/sdk-bindings/src/uniffi_binding.rs | 54 +- libs/sdk-common/src/input_parser.rs | 35 ++ libs/sdk-common/src/invoice.rs | 53 +- libs/sdk-core/src/binding.rs | 57 +- libs/sdk-core/src/breez_services.rs | 48 +- libs/sdk-core/src/bridge_generated.io.rs | 123 +++- libs/sdk-core/src/bridge_generated.rs | 120 +++- libs/sdk-core/src/error.rs | 8 +- libs/sdk-core/src/greenlight/error.rs | 12 +- libs/sdk-core/src/greenlight/node_api.rs | 68 ++- libs/sdk-core/src/models.rs | 49 +- libs/sdk-core/src/node_api.rs | 21 +- libs/sdk-core/src/test_utils.rs | 16 +- .../ios/Classes/bridge_generated.h | 32 +- libs/sdk-flutter/lib/bridge_generated.dart | 312 +++++++++- .../lib/bridge_generated.freezed.dart | 558 ++++++++++++++++++ .../main/java/com/breezsdk/BreezSDKMapper.kt | 385 +++++++++++- .../main/java/com/breezsdk/BreezSDKModule.kt | 168 ++++++ .../sdk-react-native/ios/BreezSDKMapper.swift | 558 +++++++++++++++++- libs/sdk-react-native/ios/RNBreezSDK.m | 12 + libs/sdk-react-native/ios/RNBreezSDK.swift | 33 ++ libs/sdk-react-native/src/index.ts | 14 + tools/sdk-cli/Cargo.lock | 277 +++++---- 26 files changed, 2881 insertions(+), 212 deletions(-) diff --git a/libs/Cargo.lock b/libs/Cargo.lock index ed1e5f25e..cbfe1e147 100644 --- a/libs/Cargo.lock +++ b/libs/Cargo.lock @@ -1828,6 +1828,15 @@ dependencies = [ "regex", ] +[[package]] +name = "lightning" +version = "0.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cec5fa9382154fe9671e8df93095b800c7d77abc66e2a5ef839d672521c5e" +dependencies = [ + "bitcoin 0.29.2", +] + [[package]] name = "lightning-invoice" version = "0.24.0" @@ -1837,7 +1846,21 @@ dependencies = [ "bech32", "bitcoin 0.29.2", "bitcoin_hashes 0.11.0", - "lightning", + "lightning 0.0.116", + "num-traits", + "secp256k1 0.24.3", +] + +[[package]] +name = "lightning-invoice" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb24878b0f4ef75f020976c886d9ad1503867802329cc963e0ab4623ea3b25c" +dependencies = [ + "bech32", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", + "lightning 0.0.118", "num-traits", "secp256k1 0.24.3", ] @@ -2792,8 +2815,8 @@ dependencies = [ "bitcoin 0.29.2", "cbc", "hex", - "lightning", - "lightning-invoice", + "lightning 0.0.118", + "lightning-invoice 0.26.0", "log", "mockito", "once_cell", @@ -3784,8 +3807,8 @@ dependencies = [ "hashbrown 0.8.2", "hex", "itertools", - "lightning", - "lightning-invoice", + "lightning 0.0.116", + "lightning-invoice 0.24.0", "log", "scopeguard", "serde", diff --git a/libs/Cargo.toml b/libs/Cargo.toml index 1a7fdaa9d..bc8249aa7 100644 --- a/libs/Cargo.toml +++ b/libs/Cargo.toml @@ -23,10 +23,10 @@ base64 = "0.13.0" bitcoin = "=0.29.2" # Same version as used in gl-client # Pin the reqwest dependency until macOS linker issue is fixed: https://github.com/seanmonstar/reqwest/issues/2006 hex = "0.4" -lightning = "=0.0.116" # Same version as used in gl-client -lightning-invoice = "=0.24.0" # Same version as used in gl-client +lightning = "=0.0.118" # Same version as used in gl-client +lightning-invoice = "=0.26.0" # Same version as used in gl-client log = "0.4" -mockito = "1" +mockito = "1.4.0" once_cell = "1" prost = "^0.11" regex = "1.8.1" diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index 03cb72043..2f844904f 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -91,6 +91,7 @@ enum SendPaymentError { "InvalidInvoice", "InvoiceExpired", "InvalidNetwork", + "OfferChanged", "PaymentFailed", "PaymentTimeout", "RouteNotFound", @@ -481,6 +482,21 @@ dictionary StaticBackupResponse { sequence? backup; }; +dictionary CreateOfferRequest { + string description; + u64? amount_msat = null; + u64? absolute_expiry = null; + u64? quantity_max = null; +}; + +dictionary PayOfferRequest { + string offer; + u64? amount_msat = null; + f64? timeout = null; + string? payer_note = null; + string? label = null; +}; + dictionary ReceiveOnchainRequest { OpeningFeeParams? opening_fee_params = null; }; @@ -716,10 +732,27 @@ dictionary RecommendedFees { u64 minimum_fee; }; +[Enum] +interface Amount { + Bitcoin(u64 amount_msat); + Currency(string iso4217_code, u64 fractional_amount); +}; + +dictionary LNOffer { + string bolt12; + sequence chains; + string description; + string signing_pubkey; + Amount? amount; + u64? absolute_expiry; + string? issuer; +}; + [Enum] interface InputType { BitcoinAddress(BitcoinAddressData address); Bolt11(LNInvoice invoice); + Bolt12Offer(LNOffer offer); NodeId(string node_id); Url(string url); LnUrlPay(LnUrlPayRequestData data); @@ -752,7 +785,7 @@ dictionary RedeemOnchainFundsResponse { }; dictionary SendPaymentRequest { - string bolt11; + string invoice; u64? amount_msat = null; string? label = null; }; @@ -967,6 +1000,12 @@ interface BlockingBreezServices { [Throws=SdkError] PrepareRedeemOnchainFundsResponse prepare_redeem_onchain_funds(PrepareRedeemOnchainFundsRequest req); + + [Throws=SdkError] + string create_offer(CreateOfferRequest req); + + [Throws=SendPaymentError] + SendPaymentResponse pay_offer(PayOfferRequest req); }; namespace breez_sdk { diff --git a/libs/sdk-bindings/src/uniffi_binding.rs b/libs/sdk-bindings/src/uniffi_binding.rs index 266bd70aa..a08074aef 100644 --- a/libs/sdk-bindings/src/uniffi_binding.rs +++ b/libs/sdk-bindings/src/uniffi_binding.rs @@ -5,31 +5,31 @@ use breez_sdk_core::lnurl::pay::{LnUrlPayResult, LnUrlPaySuccessData}; use breez_sdk_core::{ error::*, mnemonic_to_seed as sdk_mnemonic_to_seed, parse as sdk_parse_input, parse_invoice as sdk_parse_invoice, AesSuccessActionDataDecrypted, AesSuccessActionDataResult, - BackupFailedData, BackupStatus, BitcoinAddressData, BreezEvent, BreezServices, + Amount, BackupFailedData, BackupStatus, BitcoinAddressData, BreezEvent, BreezServices, BuyBitcoinProvider, BuyBitcoinRequest, BuyBitcoinResponse, ChannelState, CheckMessageRequest, CheckMessageResponse, ClosedChannelPaymentDetails, Config, ConfigureNodeRequest, - ConnectRequest, CurrencyInfo, EnvironmentType, EventListener, FeeratePreset, FiatCurrency, - GreenlightCredentials, GreenlightDeviceCredentials, GreenlightNodeConfig, HealthCheckStatus, - InputType, InvoicePaidDetails, LNInvoice, ListPaymentsRequest, 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, + ConnectRequest, CreateOfferRequest, CurrencyInfo, EnvironmentType, EventListener, + FeeratePreset, FiatCurrency, GreenlightCredentials, GreenlightDeviceCredentials, + GreenlightNodeConfig, HealthCheckStatus, InputType, InvoicePaidDetails, LNInvoice, LNOffer, + ListPaymentsRequest, 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, PayOfferRequest, 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, }; use log::{Level, LevelFilter, Metadata, Record}; use once_cell::sync::{Lazy, OnceCell}; @@ -381,6 +381,14 @@ impl BlockingBreezServices { ) -> SdkResult { rt().block_on(self.breez_services.prepare_redeem_onchain_funds(req)) } + + pub fn create_offer(&self, req: CreateOfferRequest) -> Result { + rt().block_on(self.breez_services.create_offer(req)) + } + + pub fn pay_offer(&self, req: PayOfferRequest) -> Result { + rt().block_on(self.breez_services.pay_offer(req)) + } } pub fn parse_invoice(invoice: String) -> SdkResult { diff --git a/libs/sdk-common/src/input_parser.rs b/libs/sdk-common/src/input_parser.rs index 002109715..1f3da8f42 100644 --- a/libs/sdk-common/src/input_parser.rs +++ b/libs/sdk-common/src/input_parser.rs @@ -4,9 +4,11 @@ use anyhow::{anyhow, Result}; use bip21::Uri; use bitcoin::bech32; use bitcoin::bech32::FromBase32; +use lightning::offers::offer::Offer; use serde::{Deserialize, Serialize}; use LnUrlRequestData::*; +use crate::prelude::InputType::Bolt12Offer; use crate::prelude::*; /// Parses generic user input, typically pasted from clipboard or scanned from a QR. @@ -149,6 +151,7 @@ use crate::prelude::*; /// } /// } /// ``` + pub async fn parse(input: &str) -> Result { let input = input.trim(); @@ -179,6 +182,24 @@ pub async fn parse(input: &str) -> Result { return Ok(InputType::Bolt11 { invoice }); } + if let Ok(offer) = input.parse::() { + return Ok(Bolt12Offer { + offer: LNOffer { + bolt12: input.to_string(), + chains: offer + .chains() + .iter() + .map(|chain| chain.to_string()) + .collect(), + amount: offer.amount().map(|amount| amount.clone().into()), + description: offer.description().to_string(), + absolute_expiry: offer.absolute_expiry().map(|expiry| expiry.as_secs()), + issuer: offer.issuer().map(|s| s.to_string()), + signing_pubkey: offer.signing_pubkey().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 { @@ -396,6 +417,9 @@ pub enum InputType { Bolt11 { invoice: LNInvoice, }, + Bolt12Offer { + offer: LNOffer, + }, NodeId { node_id: String, }, @@ -786,6 +810,17 @@ pub(crate) mod tests { Ok(()) } + #[tokio::test] + async fn test_bolt12_offer() -> Result<()> { + let offer = "lno1pqqnyzsmx5cx6umpwssx6atvw35j6ut4v9h8g6t50ysx7enxv4epyrmjw4ehgcm0wfczucm0d5hxzag5qqtzzq3lxgva5qlw9xsjmeqs0ek9cdj0vpec9ur972l7mywa66u3q7dlhs"; + + assert!(matches!( + parse(offer).await?, + InputType::Bolt12Offer { offer: _offer } + )); + Ok(()) + } + #[tokio::test] async fn test_url() -> Result<()> { assert!(matches!( diff --git a/libs/sdk-common/src/invoice.rs b/libs/sdk-common/src/invoice.rs index 04dac480f..f4a879880 100644 --- a/libs/sdk-common/src/invoice.rs +++ b/libs/sdk-common/src/invoice.rs @@ -4,8 +4,11 @@ use std::time::{SystemTimeError, UNIX_EPOCH}; use bitcoin::secp256k1::{self, PublicKey}; use hex::ToHex; use lightning::routing::gossip::RoutingFees; -use lightning::routing::*; -use lightning_invoice::*; +use lightning::routing::router; +use lightning_invoice::{ + Bolt11Invoice, Bolt11InvoiceDescription, Bolt11ParseError, Bolt11SemanticError, CreationError, + InvoiceBuilder, RawBolt11Invoice, SignedRawBolt11Invoice, +}; use regex::Regex; use serde::{Deserialize, Serialize}; @@ -75,7 +78,49 @@ impl From for InvoiceError { } } -/// Wrapper for a BOLT11 LN invoice +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub enum Amount { + Bitcoin { + amount_msat: u64, + }, + Currency { + // Reference to [FiatCurrency.id] + iso4217_code: String, + fractional_amount: u64, + }, +} + +impl From for Amount { + fn from(amount: lightning::offers::offer::Amount) -> Self { + match amount { + lightning::offers::offer::Amount::Bitcoin { amount_msats } => Amount::Bitcoin { + amount_msat: amount_msats, + }, + lightning::offers::offer::Amount::Currency { + iso4217_code, + amount, + } => Amount::Currency { + iso4217_code: String::from_utf8(iso4217_code.to_vec()) + .expect("Expecting a valid ISO 4217 character sequence"), + fractional_amount: amount, + }, + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct LNOffer { + pub bolt12: String, + pub chains: Vec, + pub amount: Option, + pub description: String, + pub absolute_expiry: Option, + pub issuer: Option, + pub signing_pubkey: String, + // pub paths: Vec, +} + +/// Wrapper for a BOLT11 invoice #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct LNInvoice { pub bolt11: String, @@ -271,7 +316,7 @@ pub fn parse_invoice(bolt11: &str) -> InvoiceResult { let converted_hints = invoice_hints.iter().map(RouteHint::from_ldk_hint).collect(); // return the parsed invoice let ln_invoice = LNInvoice { - bolt11: bolt11.to_string(), + bolt11: invoice.to_string(), network: invoice.network().into(), payee_pubkey, expiry: invoice.expiry_time().as_secs(), diff --git a/libs/sdk-core/src/binding.rs b/libs/sdk-core/src/binding.rs index 200c7ccb6..a1167eb6f 100644 --- a/libs/sdk-core/src/binding.rs +++ b/libs/sdk-core/src/binding.rs @@ -19,12 +19,12 @@ use log::{Level, LevelFilter, Metadata, Record}; use once_cell::sync::{Lazy, OnceCell}; use sdk_common::invoice; pub use sdk_common::prelude::{ - parse, AesSuccessActionDataDecrypted, AesSuccessActionDataResult, BitcoinAddressData, - CurrencyInfo, FiatCurrency, InputType, LNInvoice, LnUrlAuthRequestData, LnUrlCallbackStatus, - LnUrlError, LnUrlErrorData, LnUrlPayErrorData, LnUrlPayRequest, LnUrlPayRequestData, - LnUrlWithdrawRequest, LnUrlWithdrawRequestData, LnUrlWithdrawResult, LnUrlWithdrawSuccessData, - LocaleOverrides, LocalizedName, MessageSuccessActionData, Network, Rate, RouteHint, - RouteHintHop, SuccessActionProcessed, Symbol, UrlSuccessActionData, + parse, AesSuccessActionDataDecrypted, AesSuccessActionDataResult, Amount, BitcoinAddressData, + CurrencyInfo, FiatCurrency, InputType, LNInvoice, LNOffer, LnUrlAuthRequestData, + LnUrlCallbackStatus, LnUrlError, LnUrlErrorData, LnUrlPayErrorData, LnUrlPayRequest, + LnUrlPayRequestData, LnUrlWithdrawRequest, LnUrlWithdrawRequestData, LnUrlWithdrawResult, + LnUrlWithdrawSuccessData, LocaleOverrides, LocalizedName, MessageSuccessActionData, Network, + Rate, RouteHint, RouteHintHop, SuccessActionProcessed, Symbol, UrlSuccessActionData, }; use tokio::sync::Mutex; @@ -38,10 +38,11 @@ use crate::lsp::LspInformation; use crate::models::{Config, LogEntry, NodeState, Payment, SwapInfo}; use crate::{ BackupStatus, BuyBitcoinRequest, BuyBitcoinResponse, CheckMessageRequest, CheckMessageResponse, - ConfigureNodeRequest, ConnectRequest, EnvironmentType, ListPaymentsRequest, LnUrlAuthError, - MaxReverseSwapAmountResponse, NodeConfig, NodeCredentials, OnchainPaymentLimitsResponse, - OpenChannelFeeRequest, OpenChannelFeeResponse, PayOnchainRequest, PayOnchainResponse, - PrepareOnchainPaymentRequest, PrepareOnchainPaymentResponse, PrepareRedeemOnchainFundsRequest, + ConfigureNodeRequest, ConnectRequest, CreateOfferRequest, EnvironmentType, ListPaymentsRequest, + LnUrlAuthError, MaxReverseSwapAmountResponse, NodeConfig, NodeCredentials, + OnchainPaymentLimitsResponse, OpenChannelFeeRequest, OpenChannelFeeResponse, PayOfferRequest, + PayOnchainRequest, PayOnchainResponse, PrepareOnchainPaymentRequest, + PrepareOnchainPaymentResponse, PrepareRedeemOnchainFundsRequest, PrepareRedeemOnchainFundsResponse, PrepareRefundRequest, PrepareRefundResponse, ReceiveOnchainRequest, ReceivePaymentRequest, ReceivePaymentResponse, RedeemOnchainFundsRequest, RedeemOnchainFundsResponse, RefundRequest, RefundResponse, @@ -87,6 +88,28 @@ pub enum _Network { Regtest, } +#[frb(mirror(Amount))] +pub enum _Amount { + Bitcoin { + amount_msat: u64, + }, + Currency { + iso4217_code: String, + fractional_amount: u64, + }, +} + +#[frb(mirror(LNOffer))] +pub struct _LNOffer { + pub bolt12: String, + pub chains: Vec, + pub amount: Option, + pub description: String, + pub absolute_expiry: Option, + pub issuer: Option, + pub signing_pubkey: String, +} + #[frb(mirror(LNInvoice))] pub struct _LNInvoice { pub bolt11: String, @@ -160,6 +183,7 @@ pub struct _LnUrlWithdrawRequestData { pub enum _InputType { BitcoinAddress { address: BitcoinAddressData }, Bolt11 { invoice: LNInvoice }, + Bolt12Offer { offer: LNOffer }, NodeId { node_id: String }, Url { url: String }, LnUrlPay { data: LnUrlPayRequestData }, @@ -171,7 +195,7 @@ pub enum _InputType { #[frb(mirror(BitcoinAddressData))] pub struct _BitcoinAddressData { pub address: String, - pub network: crate::prelude::Network, + pub network: Network, pub amount_sat: Option, pub label: Option, pub message: Option, @@ -559,6 +583,17 @@ pub fn receive_payment(req: ReceivePaymentRequest) -> Result) } +/// See [BreezServices::create_offer] +pub fn create_offer(req: CreateOfferRequest) -> Result { + block_on(async { get_breez_services().await?.create_offer(req).await }) +} + +/// See [BreezServices::pay_offer] +pub fn pay_offer(req: PayOfferRequest) -> Result { + block_on(async { get_breez_services().await?.pay_offer(req).await }) + .map_err(anyhow::Error::new::) +} + /* LNURL API's */ /// See [BreezServices::lnurl_pay] diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index a30727a3f..65655b680 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -261,7 +261,7 @@ impl BreezServices { req: SendPaymentRequest, ) -> Result { self.start_node().await?; - let parsed_invoice = parse_invoice(req.bolt11.as_str())?; + let parsed_invoice = parse_invoice(req.invoice.as_str())?; let invoice_amount_msat = parsed_invoice.amount_msat.unwrap_or_default(); let provided_amount_msat = req.amount_msat.unwrap_or_default(); @@ -292,11 +292,7 @@ impl BreezServices { self.persist_pending_payment(&parsed_invoice, amount_msat, req.label.clone())?; let payment_res = self .node_api - .send_payment( - parsed_invoice.bolt11.clone(), - req.amount_msat, - req.label.clone(), - ) + .send_payment(req.invoice.clone(), req.amount_msat, req.label.clone()) .map_err(Into::into) .await; let payment = self @@ -356,7 +352,7 @@ impl BreezServices { } ValidatedCallbackResponse::EndpointSuccess { data: cb } => { let pay_req = SendPaymentRequest { - bolt11: cb.pr.clone(), + invoice: cb.pr.clone(), amount_msat: None, label: req.payment_label, }; @@ -1996,6 +1992,44 @@ impl BreezServices { ); Ok(res) } + + pub async fn create_offer(&self, req: CreateOfferRequest) -> Result { + self.start_node().await?; + Ok(self.node_api.create_offer(req).await?) + } + + pub async fn pay_offer( + &self, + req: PayOfferRequest, + ) -> Result { + self.start_node().await?; + + let fetch_invoice_response = self + .node_api + .fetch_invoice(FetchInvoiceRequest { + offer: req.offer.clone(), + amount_msat: req.amount_msat, + timeout: req.timeout, + payer_note: req.payer_note.to_owned(), + }) + .await?; + + if let Some(_) = fetch_invoice_response.changes { + return Err(SendPaymentError::OfferChanged { + err: "Offer changed".to_string(), + }); + } + + Ok(self + .send_payment(SendPaymentRequest { + invoice: fetch_invoice_response.bolt12, + // we expect amount_msat from the invoice to be the same as the one in the + // PayOfferRequest due to the above check, can omit + amount_msat: None, + label: req.label, + }) + .await?) + } } struct GlobalSdkLogger { diff --git a/libs/sdk-core/src/bridge_generated.io.rs b/libs/sdk-core/src/bridge_generated.io.rs index a16169e6b..1c3752778 100644 --- a/libs/sdk-core/src/bridge_generated.io.rs +++ b/libs/sdk-core/src/bridge_generated.io.rs @@ -178,6 +178,16 @@ pub extern "C" fn wire_receive_payment(port_: i64, req: *mut wire_ReceivePayment wire_receive_payment_impl(port_, req) } +#[no_mangle] +pub extern "C" fn wire_create_offer(port_: i64, req: *mut wire_CreateOfferRequest) { + wire_create_offer_impl(port_, req) +} + +#[no_mangle] +pub extern "C" fn wire_pay_offer(port_: i64, req: *mut wire_PayOfferRequest) { + wire_pay_offer_impl(port_, req) +} + #[no_mangle] pub extern "C" fn wire_lnurl_pay(port_: i64, req: *mut wire_LnUrlPayRequest) { wire_lnurl_pay_impl(port_, req) @@ -351,6 +361,16 @@ pub extern "C" fn new_box_autoadd_connect_request_0() -> *mut wire_ConnectReques support::new_leak_box_ptr(wire_ConnectRequest::new_with_null_ptr()) } +#[no_mangle] +pub extern "C" fn new_box_autoadd_create_offer_request_0() -> *mut wire_CreateOfferRequest { + support::new_leak_box_ptr(wire_CreateOfferRequest::new_with_null_ptr()) +} + +#[no_mangle] +pub extern "C" fn new_box_autoadd_f64_0(value: f64) -> *mut f64 { + support::new_leak_box_ptr(value) +} + #[no_mangle] pub extern "C" fn new_box_autoadd_greenlight_credentials_0() -> *mut wire_GreenlightCredentials { support::new_leak_box_ptr(wire_GreenlightCredentials::new_with_null_ptr()) @@ -401,6 +421,11 @@ pub extern "C" fn new_box_autoadd_opening_fee_params_0() -> *mut wire_OpeningFee support::new_leak_box_ptr(wire_OpeningFeeParams::new_with_null_ptr()) } +#[no_mangle] +pub extern "C" fn new_box_autoadd_pay_offer_request_0() -> *mut wire_PayOfferRequest { + support::new_leak_box_ptr(wire_PayOfferRequest::new_with_null_ptr()) +} + #[no_mangle] pub extern "C" fn new_box_autoadd_pay_onchain_request_0() -> *mut wire_PayOnchainRequest { support::new_leak_box_ptr(wire_PayOnchainRequest::new_with_null_ptr()) @@ -573,6 +598,17 @@ impl Wire2Api for *mut wire_ConnectRequest { Wire2Api::::wire2api(*wrap).into() } } +impl Wire2Api for *mut wire_CreateOfferRequest { + fn wire2api(self) -> CreateOfferRequest { + let wrap = unsafe { support::box_from_leak_ptr(self) }; + Wire2Api::::wire2api(*wrap).into() + } +} +impl Wire2Api for *mut f64 { + fn wire2api(self) -> f64 { + unsafe { *support::box_from_leak_ptr(self) } + } +} impl Wire2Api for *mut wire_GreenlightCredentials { fn wire2api(self) -> GreenlightCredentials { let wrap = unsafe { support::box_from_leak_ptr(self) }; @@ -632,6 +668,12 @@ impl Wire2Api for *mut wire_OpeningFeeParams { Wire2Api::::wire2api(*wrap).into() } } +impl Wire2Api for *mut wire_PayOfferRequest { + fn wire2api(self) -> PayOfferRequest { + let wrap = unsafe { support::box_from_leak_ptr(self) }; + Wire2Api::::wire2api(*wrap).into() + } +} impl Wire2Api for *mut wire_PayOnchainRequest { fn wire2api(self) -> PayOnchainRequest { let wrap = unsafe { support::box_from_leak_ptr(self) }; @@ -789,6 +831,16 @@ impl Wire2Api for wire_ConnectRequest { } } } +impl Wire2Api for wire_CreateOfferRequest { + fn wire2api(self) -> CreateOfferRequest { + CreateOfferRequest { + amount_msat: self.amount_msat.wire2api(), + description: self.description.wire2api(), + absolute_expiry: self.absolute_expiry.wire2api(), + quantity_max: self.quantity_max.wire2api(), + } + } +} impl Wire2Api for wire_GreenlightCredentials { fn wire2api(self) -> GreenlightCredentials { @@ -946,6 +998,17 @@ impl Wire2Api for wire_OpeningFeeParams { } } +impl Wire2Api for wire_PayOfferRequest { + fn wire2api(self) -> PayOfferRequest { + PayOfferRequest { + offer: self.offer.wire2api(), + amount_msat: self.amount_msat.wire2api(), + timeout: self.timeout.wire2api(), + payer_note: self.payer_note.wire2api(), + label: self.label.wire2api(), + } + } +} impl Wire2Api for wire_PayOnchainRequest { fn wire2api(self) -> PayOnchainRequest { PayOnchainRequest { @@ -1074,7 +1137,7 @@ impl Wire2Api for wire_SendOnchainRequest { impl Wire2Api for wire_SendPaymentRequest { fn wire2api(self) -> SendPaymentRequest { SendPaymentRequest { - bolt11: self.bolt11.wire2api(), + invoice: self.invoice.wire2api(), amount_msat: self.amount_msat.wire2api(), label: self.label.wire2api(), } @@ -1169,6 +1232,15 @@ pub struct wire_ConnectRequest { restore_only: *mut bool, } +#[repr(C)] +#[derive(Clone)] +pub struct wire_CreateOfferRequest { + amount_msat: *mut u64, + description: *mut wire_uint_8_list, + absolute_expiry: *mut u64, + quantity_max: *mut u64, +} + #[repr(C)] #[derive(Clone)] pub struct wire_GreenlightCredentials { @@ -1291,6 +1363,16 @@ pub struct wire_OpeningFeeParams { promise: *mut wire_uint_8_list, } +#[repr(C)] +#[derive(Clone)] +pub struct wire_PayOfferRequest { + offer: *mut wire_uint_8_list, + amount_msat: *mut u64, + timeout: *mut f64, + payer_note: *mut wire_uint_8_list, + label: *mut wire_uint_8_list, +} + #[repr(C)] #[derive(Clone)] pub struct wire_PayOnchainRequest { @@ -1392,7 +1474,7 @@ pub struct wire_SendOnchainRequest { #[repr(C)] #[derive(Clone)] pub struct wire_SendPaymentRequest { - bolt11: *mut wire_uint_8_list, + invoice: *mut wire_uint_8_list, amount_msat: *mut u64, label: *mut wire_uint_8_list, } @@ -1565,6 +1647,23 @@ impl Default for wire_ConnectRequest { } } +impl NewWithNullPtr for wire_CreateOfferRequest { + fn new_with_null_ptr() -> Self { + Self { + amount_msat: core::ptr::null_mut(), + description: core::ptr::null_mut(), + absolute_expiry: core::ptr::null_mut(), + quantity_max: core::ptr::null_mut(), + } + } +} + +impl Default for wire_CreateOfferRequest { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + impl NewWithNullPtr for wire_GreenlightCredentials { fn new_with_null_ptr() -> Self { Self { @@ -1778,6 +1877,24 @@ impl Default for wire_OpeningFeeParams { } } +impl NewWithNullPtr for wire_PayOfferRequest { + fn new_with_null_ptr() -> Self { + Self { + offer: core::ptr::null_mut(), + amount_msat: core::ptr::null_mut(), + timeout: core::ptr::null_mut(), + payer_note: core::ptr::null_mut(), + label: core::ptr::null_mut(), + } + } +} + +impl Default for wire_PayOfferRequest { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + impl NewWithNullPtr for wire_PayOnchainRequest { fn new_with_null_ptr() -> Self { Self { @@ -1999,7 +2116,7 @@ impl Default for wire_SendOnchainRequest { impl NewWithNullPtr for wire_SendPaymentRequest { fn new_with_null_ptr() -> Self { Self { - bolt11: core::ptr::null_mut(), + invoice: core::ptr::null_mut(), amount_msat: core::ptr::null_mut(), label: core::ptr::null_mut(), } diff --git a/libs/sdk-core/src/bridge_generated.rs b/libs/sdk-core/src/bridge_generated.rs index 00e16775a..9885fda30 100644 --- a/libs/sdk-core/src/bridge_generated.rs +++ b/libs/sdk-core/src/bridge_generated.rs @@ -41,6 +41,7 @@ use crate::models::ClosedChannelPaymentDetails; use crate::models::Config; use crate::models::ConfigureNodeRequest; use crate::models::ConnectRequest; +use crate::models::CreateOfferRequest; use crate::models::EnvironmentType; use crate::models::GreenlightCredentials; use crate::models::GreenlightDeviceCredentials; @@ -59,6 +60,7 @@ use crate::models::OpenChannelFeeRequest; use crate::models::OpenChannelFeeResponse; use crate::models::OpeningFeeParams; use crate::models::OpeningFeeParamsMenu; +use crate::models::PayOfferRequest; use crate::models::PayOnchainRequest; use crate::models::PayOnchainResponse; use crate::models::Payment; @@ -528,6 +530,32 @@ fn wire_receive_payment_impl( }, ) } +fn wire_create_offer_impl(port_: MessagePort, req: impl Wire2Api + UnwindSafe) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, String, _>( + WrapInfo { + debug_name: "create_offer", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_req = req.wire2api(); + move |task_callback| create_offer(api_req) + }, + ) +} +fn wire_pay_offer_impl(port_: MessagePort, req: impl Wire2Api + UnwindSafe) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, SendPaymentResponse, _>( + WrapInfo { + debug_name: "pay_offer", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_req = req.wire2api(); + move |task_callback| pay_offer(api_req) + }, + ) +} fn wire_lnurl_pay_impl(port_: MessagePort, req: impl Wire2Api + UnwindSafe) { FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, LnUrlPayResult, _>( WrapInfo { @@ -894,6 +922,9 @@ pub struct mirror_AesSuccessActionDataDecrypted(AesSuccessActionDataDecrypted); #[derive(Clone)] pub struct mirror_AesSuccessActionDataResult(AesSuccessActionDataResult); +#[derive(Clone)] +pub struct mirror_Amount(Amount); + #[derive(Clone)] pub struct mirror_BitcoinAddressData(BitcoinAddressData); @@ -909,6 +940,9 @@ pub struct mirror_InputType(InputType); #[derive(Clone)] pub struct mirror_LNInvoice(LNInvoice); +#[derive(Clone)] +pub struct mirror_LNOffer(LNOffer); + #[derive(Clone)] pub struct mirror_LnUrlAuthRequestData(LnUrlAuthRequestData); @@ -979,6 +1013,18 @@ const _: fn() = || { let _: String = reason; } } + match None::.unwrap() { + Amount::Bitcoin { amount_msat } => { + let _: u64 = amount_msat; + } + Amount::Currency { + iso4217_code, + fractional_amount, + } => { + let _: String = iso4217_code; + let _: u64 = fractional_amount; + } + } { let BitcoinAddressData = None::.unwrap(); let _: String = BitcoinAddressData.address; @@ -1009,6 +1055,9 @@ const _: fn() = || { InputType::Bolt11 { invoice } => { let _: LNInvoice = invoice; } + InputType::Bolt12Offer { offer } => { + let _: LNOffer = offer; + } InputType::NodeId { node_id } => { let _: String = node_id; } @@ -1043,6 +1092,16 @@ const _: fn() = || { let _: Vec = LNInvoice.payment_secret; let _: u64 = LNInvoice.min_final_cltv_expiry_delta; } + { + let LNOffer = None::.unwrap(); + let _: String = LNOffer.bolt12; + let _: Vec = LNOffer.chains; + let _: Option = LNOffer.amount; + let _: String = LNOffer.description; + let _: Option = LNOffer.absolute_expiry; + let _: Option = LNOffer.issuer; + let _: String = LNOffer.signing_pubkey; + } { let LnUrlAuthRequestData = None::.unwrap(); let _: String = LnUrlAuthRequestData.k1; @@ -1318,6 +1377,31 @@ impl rust2dart::IntoIntoDart for AesSuccessAc } } +impl support::IntoDart for mirror_Amount { + fn into_dart(self) -> support::DartAbi { + match self.0 { + Amount::Bitcoin { amount_msat } => { + vec![0.into_dart(), amount_msat.into_into_dart().into_dart()] + } + Amount::Currency { + iso4217_code, + fractional_amount, + } => vec![ + 1.into_dart(), + iso4217_code.into_into_dart().into_dart(), + fractional_amount.into_into_dart().into_dart(), + ], + } + .into_dart() + } +} +impl support::IntoDartExceptPrimitive for mirror_Amount {} +impl rust2dart::IntoIntoDart for Amount { + fn into_into_dart(self) -> mirror_Amount { + mirror_Amount(self) + } +} + impl support::IntoDart for BackupFailedData { fn into_dart(self) -> support::DartAbi { vec![self.error.into_into_dart().into_dart()].into_dart() @@ -1594,17 +1678,20 @@ impl support::IntoDart for mirror_InputType { InputType::Bolt11 { invoice } => { vec![1.into_dart(), invoice.into_into_dart().into_dart()] } + InputType::Bolt12Offer { 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() @@ -1663,6 +1750,27 @@ impl rust2dart::IntoIntoDart for LNInvoice { } } +impl support::IntoDart for mirror_LNOffer { + fn into_dart(self) -> support::DartAbi { + vec![ + self.0.bolt12.into_into_dart().into_dart(), + self.0.chains.into_into_dart().into_dart(), + self.0.amount.map(|v| mirror_Amount(v)).into_dart(), + self.0.description.into_into_dart().into_dart(), + self.0.absolute_expiry.into_dart(), + self.0.issuer.into_dart(), + self.0.signing_pubkey.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl support::IntoDartExceptPrimitive for mirror_LNOffer {} +impl rust2dart::IntoIntoDart for LNOffer { + fn into_into_dart(self) -> mirror_LNOffer { + mirror_LNOffer(self) + } +} + impl support::IntoDart for LnPaymentDetails { fn into_dart(self) -> support::DartAbi { vec![ diff --git a/libs/sdk-core/src/error.rs b/libs/sdk-core/src/error.rs index 4c7c22eee..4076b717d 100644 --- a/libs/sdk-core/src/error.rs +++ b/libs/sdk-core/src/error.rs @@ -96,7 +96,9 @@ impl From for LnUrlPayError { fn from(value: SendPaymentError) -> Self { match value { SendPaymentError::AlreadyPaid => Self::AlreadyPaid, - SendPaymentError::Generic { err } => Self::Generic { err }, + SendPaymentError::Generic { err } | SendPaymentError::OfferChanged { err } => { + Self::Generic { err } + } SendPaymentError::InvalidAmount { err } => Self::InvalidAmount { err }, SendPaymentError::InvalidInvoice { err } => Self::InvalidInvoice { err }, SendPaymentError::InvalidNetwork { err } => Self::InvalidNetwork { err }, @@ -425,6 +427,7 @@ impl From for SdkError { | SendPaymentError::InvoiceExpired { err } | SendPaymentError::PaymentFailed { err } | SendPaymentError::PaymentTimeout { err } + | SendPaymentError::OfferChanged { err } | SendPaymentError::RouteNotFound { err } | SendPaymentError::RouteTooExpensive { err } => Self::Generic { err }, SendPaymentError::ServiceConnectivity { err } => Self::ServiceConnectivity { err }, @@ -552,6 +555,9 @@ pub enum SendPaymentError { #[error("Payment timeout: {err}")] PaymentTimeout { err: String }, + #[error("Offer has changed: {err}")] + OfferChanged { err: String }, + /// This error is raised when no route can be found when attempting to make a /// payment by the node. #[error("Route not found: {err}")] diff --git a/libs/sdk-core/src/greenlight/error.rs b/libs/sdk-core/src/greenlight/error.rs index 93e1f48d3..fb3068a94 100644 --- a/libs/sdk-core/src/greenlight/error.rs +++ b/libs/sdk-core/src/greenlight/error.rs @@ -185,11 +185,15 @@ impl From for NodeError { JsonRpcErrCode::InvoiceExpiredDuringWait => { Self::InvoiceExpired(wrapped_status.to_string()) } - JsonRpcErrCode::InvoiceNoDescription => { - Self::InvoiceNoDescription(wrapped_status.to_string()) + JsonRpcErrCode::OfferExpired => Self::OfferExpired(wrapped_status.to_string()), + JsonRpcErrCode::OfferBadInvreqReply => { + Self::OfferInvoiceRequestError(wrapped_status.to_string()) } - JsonRpcErrCode::InvoicePreimageAlreadyExists => { - Self::InvoicePreimageAlreadyExists(wrapped_status.to_string()) + JsonRpcErrCode::OfferRouteNotFound => { + Self::RouteNotFound(wrapped_status.to_string()) + } + JsonRpcErrCode::OfferTimeout => { + Self::OfferInvoiceRequestTimeout(wrapped_status.to_string()) } _ => Self::Generic(wrapped_status.to_string()), }, diff --git a/libs/sdk-core/src/greenlight/node_api.rs b/libs/sdk-core/src/greenlight/node_api.rs index 92efab6cb..517202d0a 100644 --- a/libs/sdk-core/src/greenlight/node_api.rs +++ b/libs/sdk-core/src/greenlight/node_api.rs @@ -27,6 +27,8 @@ use gl_client::scheduler::Scheduler; use gl_client::signer::model::greenlight::{amount, scheduler}; use gl_client::signer::{Error, Signer}; use gl_client::{node, utils}; +use lightning::offers::offer::Offer; +use lightning::util::message_signing::verify; use sdk_common::prelude::*; use serde::{Deserialize, Serialize}; use strum_macros::{Display, EnumString}; @@ -46,7 +48,6 @@ use crate::bitcoin::util::bip32::{ChildNumber, ExtendedPrivKey}; use crate::bitcoin::{ Address, OutPoint, Script, Sequence, Transaction, TxIn, TxOut, Txid, Witness, }; -use crate::lightning::util::message_signing::verify; use crate::lightning_invoice::{RawBolt11Invoice, SignedRawBolt11Invoice}; use crate::node_api::{CreateInvoiceRequest, FetchBolt11Result, NodeAPI, NodeError, NodeResult}; use crate::persist::db::SqliteStorage; @@ -1736,6 +1737,55 @@ impl NodeAPI for Greenlight { } Ok((hints, has_public_channel)) } + + async fn fetch_invoice(&self, req: FetchInvoiceRequest) -> NodeResult { + // Parse the offer locally, to avoid any unnecessary calls to the recipient + if let Err(_parse_error) = req.offer.parse::() { + return Err(NodeError::InvalidOffer("Invalid offer".to_string())); + }; + + // Fetch the invoice from the recipient's node + let mut client = self.get_node_client().await?; + let response = client + .fetch_invoice(Into::::into(req)) + .await? + .into_inner(); + + Ok(FetchInvoiceResponse { + bolt12: response.invoice, + changes: response.changes.map(|changes| FetchInvoiceChanges { + amount: changes.amount_msat.map(|amount| amount.msat), + vendor: changes.vendor, + description: changes.description, + }), + }) + } + + async fn create_offer(&self, req: CreateOfferRequest) -> NodeResult { + let mut client = self.get_node_client().await?; + + let offer = client + .offer(cln::OfferRequest { + amount: req + .amount_msat + .map(|msat| msat.to_string()) + .unwrap_or("any".to_string()), + description: req.description, + absolute_expiry: req.absolute_expiry, + single_use: Some(false), + issuer: None, + label: None, + quantity_max: req.quantity_max, + recurrence: None, + recurrence_base: None, + recurrence_paywindow: None, + recurrence_limit: None, + }) + .await? + .into_inner(); + + Ok(offer.bolt12) + } } #[derive(Clone, PartialEq, Eq, Debug, EnumString, Display, Deserialize, Serialize)] @@ -2292,6 +2342,22 @@ impl TryFrom for Channel { } } +impl From for gl_client::pb::cln::FetchinvoiceRequest { + fn from(request: FetchInvoiceRequest) -> Self { + cln::FetchinvoiceRequest { + offer: request.offer, + amount_msat: request.amount_msat.map(|msat| cln::Amount { msat }), + timeout: request.timeout, + payer_note: request.payer_note, + // Not yet implemented + quantity: None, + recurrence_counter: None, + recurrence_start: None, + recurrence_label: None, + } + } +} + #[cfg(test)] mod tests { use anyhow::Result; diff --git a/libs/sdk-core/src/models.rs b/libs/sdk-core/src/models.rs index 7ee4c9628..3dcb669c1 100644 --- a/libs/sdk-core/src/models.rs +++ b/libs/sdk-core/src/models.rs @@ -9,7 +9,6 @@ use ripemd::Ripemd160; use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef}; use rusqlite::ToSql; use sdk_common::grpc; -use sdk_common::prelude::Network::*; use sdk_common::prelude::*; use serde::{Deserialize, Serialize}; use strum_macros::{Display, EnumString}; @@ -486,7 +485,7 @@ impl Config { chainnotifier_url: "https://chainnotifier.breez.technology".to_string(), mempoolspace_url: None, working_dir: ".".to_string(), - network: Bitcoin, + network: Network::Bitcoin, payment_timeout_sec: 60, default_lsp_id: None, api_key: Some(api_key), @@ -502,7 +501,7 @@ impl Config { chainnotifier_url: "https://chainnotifier.breez.technology".to_string(), mempoolspace_url: None, working_dir: ".".to_string(), - network: Bitcoin, + network: Network::Bitcoin, payment_timeout_sec: 60, default_lsp_id: None, api_key: Some(api_key), @@ -843,9 +842,9 @@ pub struct ReceivePaymentResponse { /// Represents a send payment request. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SendPaymentRequest { - /// The bolt11 invoice - pub bolt11: String, - /// The amount to pay in millisatoshis. Should only be set when `bolt11` is a zero-amount invoice. + /// The bolt11/12 invoice + pub invoice: String, + /// The amount to pay in millisatoshis. Should only be set when `invoice` is a zero-amount invoice. pub amount_msat: Option, /// The external label or identifier of the [Payment] pub label: Option, @@ -1059,6 +1058,44 @@ pub struct RefundResponse { pub refund_tx_id: String, } +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct FetchInvoiceRequest { + pub(crate) offer: String, + pub(crate) amount_msat: Option, + pub(crate) timeout: Option, + pub(crate) payer_note: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct FetchInvoiceChanges { + pub(crate) vendor: Option, + pub(crate) description: Option, + pub(crate) amount: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct FetchInvoiceResponse { + pub(crate) bolt12: String, + pub(crate) changes: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct PayOfferRequest { + pub offer: String, + pub amount_msat: Option, + pub timeout: Option, + pub payer_note: Option, + pub label: Option, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CreateOfferRequest { + pub amount_msat: Option, + pub description: String, + pub absolute_expiry: Option, + pub quantity_max: Option, +} + /// Dynamic fee parameters offered by the LSP for opening a new channel. /// /// After they are received, the client shouldn't change them when calling LSP methods, diff --git a/libs/sdk-core/src/node_api.rs b/libs/sdk-core/src/node_api.rs index 732a751d7..5e7114be0 100644 --- a/libs/sdk-core/src/node_api.rs +++ b/libs/sdk-core/src/node_api.rs @@ -11,9 +11,10 @@ use crate::{ bitcoin::util::bip32::{ChildNumber, ExtendedPrivKey}, lightning_invoice::RawBolt11Invoice, persist::error::PersistError, - CustomMessage, LspInformation, MaxChannelAmount, NodeCredentials, Payment, PaymentResponse, + CreateOfferRequest, CustomMessage, FetchInvoiceRequest, FetchInvoiceResponse, LnUrlAuthError, + LspInformation, MaxChannelAmount, NodeCredentials, Payment, PaymentResponse, PrepareRedeemOnchainFundsRequest, PrepareRedeemOnchainFundsResponse, RouteHint, RouteHintHop, - SyncResponse, TlvEntry, LnUrlAuthError + SyncResponse, TlvEntry, }; pub type NodeResult = Result; @@ -29,6 +30,9 @@ pub enum NodeError { #[error(transparent)] InvalidInvoice(#[from] InvoiceError), + #[error("{0}")] + InvalidOffer(String), + #[error("{0}")] InvoiceExpired(String), @@ -47,6 +51,15 @@ pub enum NodeError { #[error(transparent)] Persistance(#[from] PersistError), + #[error("{0}")] + OfferExpired(String), + + #[error("{0}")] + OfferInvoiceRequestError(String), + + #[error("{0}")] + OfferInvoiceRequestTimeout(String), + #[error("{0}")] RestoreOnly(String), @@ -85,7 +98,7 @@ impl From for LnUrlAuthError { match value { NodeError::ServiceConnectivity(err) => Self::ServiceConnectivity { err }, _ => Self::Generic { - err: value.to_string() + err: value.to_string(), }, } } @@ -177,6 +190,8 @@ pub trait NodeAPI: Send + Sync { async fn stream_custom_messages( &self, ) -> NodeResult> + Send>>>; + async fn fetch_invoice(&self, req: FetchInvoiceRequest) -> NodeResult; + async fn create_offer(&self, req: CreateOfferRequest) -> NodeResult; /// Gets the private key at the path specified fn derive_bip32_key(&self, path: Vec) -> NodeResult; diff --git a/libs/sdk-core/src/test_utils.rs b/libs/sdk-core/src/test_utils.rs index ad1fc9068..9bbff52c5 100644 --- a/libs/sdk-core/src/test_utils.rs +++ b/libs/sdk-core/src/test_utils.rs @@ -44,10 +44,10 @@ use crate::swap_in::swap::create_submarine_swap_script; use crate::swap_out::boltzswap::{BoltzApiCreateReverseSwapResponse, BoltzApiReverseSwapStatus}; use crate::swap_out::error::{ReverseSwapError, ReverseSwapResult}; use crate::{ - parse_invoice, Config, CustomMessage, LNInvoice, MaxChannelAmount, NodeCredentials, - OpeningFeeParamsMenu, PaymentResponse, PrepareRedeemOnchainFundsRequest, - PrepareRedeemOnchainFundsResponse, ReceivePaymentRequest, ReverseSwapPairInfo, RouteHint, - RouteHintHop, SwapInfo, + parse_invoice, Config, CreateOfferRequest, CustomMessage, FetchInvoiceRequest, + FetchInvoiceResponse, LNInvoice, MaxChannelAmount, NodeCredentials, OpeningFeeParamsMenu, + PaymentResponse, PrepareRedeemOnchainFundsRequest, PrepareRedeemOnchainFundsResponse, + ReceivePaymentRequest, ReverseSwapPairInfo, RouteHint, RouteHintHop, SwapInfo, }; pub const MOCK_REVERSE_SWAP_MIN: u64 = 50_000; @@ -506,6 +506,14 @@ impl NodeAPI for MockNodeAPI { async fn fetch_bolt11(&self, _payment_hash: Vec) -> NodeResult> { Ok(None) } + + async fn fetch_invoice(&self, _req: FetchInvoiceRequest) -> NodeResult { + Err(NodeError::Generic("Not implemented".to_string())) + } + + async fn create_offer(&self, _req: CreateOfferRequest) -> NodeResult { + Err(NodeError::Generic("Not implemented".to_string())) + } } impl MockNodeAPI { diff --git a/libs/sdk-flutter/ios/Classes/bridge_generated.h b/libs/sdk-flutter/ios/Classes/bridge_generated.h index 61e733af5..d7f6268e9 100644 --- a/libs/sdk-flutter/ios/Classes/bridge_generated.h +++ b/libs/sdk-flutter/ios/Classes/bridge_generated.h @@ -113,7 +113,7 @@ typedef struct wire_ListPaymentsRequest { } wire_ListPaymentsRequest; typedef struct wire_SendPaymentRequest { - struct wire_uint_8_list *bolt11; + struct wire_uint_8_list *invoice; uint64_t *amount_msat; struct wire_uint_8_list *label; } wire_SendPaymentRequest; @@ -154,6 +154,21 @@ typedef struct wire_ReceivePaymentRequest { uint32_t *cltv; } wire_ReceivePaymentRequest; +typedef struct wire_CreateOfferRequest { + uint64_t *amount_msat; + struct wire_uint_8_list *description; + uint64_t *absolute_expiry; + uint64_t *quantity_max; +} wire_CreateOfferRequest; + +typedef struct wire_PayOfferRequest { + struct wire_uint_8_list *offer; + uint64_t *amount_msat; + double *timeout; + struct wire_uint_8_list *payer_note; + struct wire_uint_8_list *label; +} wire_PayOfferRequest; + typedef struct wire_LnUrlPayRequestData { struct wire_uint_8_list *callback; uint64_t min_sendable; @@ -364,6 +379,10 @@ void wire_send_spontaneous_payment(int64_t port_, struct wire_SendSpontaneousPay void wire_receive_payment(int64_t port_, struct wire_ReceivePaymentRequest *req); +void wire_create_offer(int64_t port_, struct wire_CreateOfferRequest *req); + +void wire_pay_offer(int64_t port_, struct wire_PayOfferRequest *req); + void wire_lnurl_pay(int64_t port_, struct wire_LnUrlPayRequest *req); void wire_lnurl_withdraw(int64_t port_, struct wire_LnUrlWithdrawRequest *req); @@ -431,6 +450,10 @@ struct wire_ConfigureNodeRequest *new_box_autoadd_configure_node_request_0(void) struct wire_ConnectRequest *new_box_autoadd_connect_request_0(void); +struct wire_CreateOfferRequest *new_box_autoadd_create_offer_request_0(void); + +double *new_box_autoadd_f64_0(double value); + struct wire_GreenlightCredentials *new_box_autoadd_greenlight_credentials_0(void); struct wire_GreenlightNodeConfig *new_box_autoadd_greenlight_node_config_0(void); @@ -451,6 +474,8 @@ struct wire_OpenChannelFeeRequest *new_box_autoadd_open_channel_fee_request_0(vo struct wire_OpeningFeeParams *new_box_autoadd_opening_fee_params_0(void); +struct wire_PayOfferRequest *new_box_autoadd_pay_offer_request_0(void); + struct wire_PayOnchainRequest *new_box_autoadd_pay_onchain_request_0(void); struct wire_PrepareOnchainPaymentRequest *new_box_autoadd_prepare_onchain_payment_request_0(void); @@ -536,6 +561,8 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_send_payment); dummy_var ^= ((int64_t) (void*) wire_send_spontaneous_payment); dummy_var ^= ((int64_t) (void*) wire_receive_payment); + dummy_var ^= ((int64_t) (void*) wire_create_offer); + dummy_var ^= ((int64_t) (void*) wire_pay_offer); dummy_var ^= ((int64_t) (void*) wire_lnurl_pay); dummy_var ^= ((int64_t) (void*) wire_lnurl_withdraw); dummy_var ^= ((int64_t) (void*) wire_lnurl_auth); @@ -569,6 +596,8 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) new_box_autoadd_check_message_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_configure_node_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_connect_request_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_create_offer_request_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_f64_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_greenlight_credentials_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_greenlight_node_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_i64_0); @@ -579,6 +608,7 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) new_box_autoadd_node_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_open_channel_fee_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_opening_fee_params_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_pay_offer_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_pay_onchain_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_prepare_onchain_payment_request_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_prepare_redeem_onchain_funds_request_0); diff --git a/libs/sdk-flutter/lib/bridge_generated.dart b/libs/sdk-flutter/lib/bridge_generated.dart index 014501e95..84ca672b3 100644 --- a/libs/sdk-flutter/lib/bridge_generated.dart +++ b/libs/sdk-flutter/lib/bridge_generated.dart @@ -180,6 +180,16 @@ abstract class BreezSdkCore { FlutterRustBridgeTaskConstMeta get kReceivePaymentConstMeta; + /// See [BreezServices::create_offer] + Future createOffer({required CreateOfferRequest req, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCreateOfferConstMeta; + + /// See [BreezServices::pay_offer] + Future payOffer({required PayOfferRequest req, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kPayOfferConstMeta; + /// See [BreezServices::lnurl_pay] Future lnurlPay({required LnUrlPayRequest req, dynamic hint}); @@ -344,6 +354,17 @@ sealed class AesSuccessActionDataResult with _$AesSuccessActionDataResult { }) = AesSuccessActionDataResult_ErrorStatus; } +@freezed +sealed class Amount with _$Amount { + const factory Amount.bitcoin({ + required int amountMsat, + }) = Amount_Bitcoin; + const factory Amount.currency({ + required String iso4217Code, + required int fractionalAmount, + }) = Amount_Currency; +} + class BackupFailedData { final String error; @@ -569,6 +590,20 @@ class ConnectRequest { }); } +class CreateOfferRequest { + final int? amountMsat; + final String description; + final int? absoluteExpiry; + final int? quantityMax; + + const CreateOfferRequest({ + this.amountMsat, + required this.description, + this.absoluteExpiry, + this.quantityMax, + }); +} + class CurrencyInfo { final String name; final int fractionSize; @@ -650,6 +685,9 @@ sealed class InputType with _$InputType { const factory InputType.bolt11({ required LNInvoice invoice, }) = InputType_Bolt11; + const factory InputType.bolt12Offer({ + required LNOffer offer, + }) = InputType_Bolt12Offer; const factory InputType.nodeId({ required String nodeId, }) = InputType_NodeId; @@ -738,6 +776,26 @@ class LNInvoice { }); } +class LNOffer { + final String bolt12; + final List chains; + final Amount? amount; + final String description; + final int? absoluteExpiry; + final String? issuer; + final String signingPubkey; + + const LNOffer({ + required this.bolt12, + required this.chains, + this.amount, + required this.description, + this.absoluteExpiry, + this.issuer, + required this.signingPubkey, + }); +} + /// Details of a LN payment, as included in a [Payment] class LnPaymentDetails { final String paymentHash; @@ -1194,6 +1252,22 @@ class OpeningFeeParamsMenu { }); } +class PayOfferRequest { + final String offer; + final int? amountMsat; + final double? timeout; + final String? payerNote; + final String? label; + + const PayOfferRequest({ + required this.offer, + this.amountMsat, + this.timeout, + this.payerNote, + this.label, + }); +} + class PayOnchainRequest { final String recipientAddress; final PrepareOnchainPaymentResponse prepareRes; @@ -1673,17 +1747,17 @@ class SendOnchainResponse { /// Represents a send payment request. class SendPaymentRequest { - /// The bolt11 invoice - final String bolt11; + /// The bolt11/12 invoice + final String invoice; - /// The amount to pay in millisatoshis. Should only be set when `bolt11` is a zero-amount invoice. + /// The amount to pay in millisatoshis. Should only be set when `invoice` is a zero-amount invoice. final int? amountMsat; /// The external label or identifier of the [Payment] final String? label; const SendPaymentRequest({ - required this.bolt11, + required this.invoice, this.amountMsat, this.label, }); @@ -2529,6 +2603,40 @@ class BreezSdkCoreImpl implements BreezSdkCore { argNames: ["req"], ); + Future createOffer({required CreateOfferRequest req, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_create_offer_request(req); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_create_offer(port_, arg0), + parseSuccessData: _wire2api_String, + parseErrorData: _wire2api_FrbAnyhowException, + constMeta: kCreateOfferConstMeta, + argValues: [req], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kCreateOfferConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "create_offer", + argNames: ["req"], + ); + + Future payOffer({required PayOfferRequest req, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_pay_offer_request(req); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_pay_offer(port_, arg0), + parseSuccessData: _wire2api_send_payment_response, + parseErrorData: _wire2api_FrbAnyhowException, + constMeta: kPayOfferConstMeta, + argValues: [req], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kPayOfferConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "pay_offer", + argNames: ["req"], + ); + Future lnurlPay({required LnUrlPayRequest req, dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_ln_url_pay_request(req); return _platform.executeNormal(FlutterRustBridgeTask( @@ -3040,6 +3148,22 @@ class BreezSdkCoreImpl implements BreezSdkCore { } } + Amount _wire2api_amount(dynamic raw) { + switch (raw[0]) { + case 0: + return Amount_Bitcoin( + amountMsat: _wire2api_u64(raw[1]), + ); + case 1: + return Amount_Currency( + iso4217Code: _wire2api_String(raw[1]), + fractionalAmount: _wire2api_u64(raw[2]), + ); + default: + throw Exception("unreachable"); + } + } + BackupFailedData _wire2api_backup_failed_data(dynamic raw) { final arr = raw as List; if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); @@ -3081,6 +3205,10 @@ class BreezSdkCoreImpl implements BreezSdkCore { return _wire2api_aes_success_action_data_result(raw); } + Amount _wire2api_box_autoadd_amount(dynamic raw) { + return _wire2api_amount(raw); + } + BackupFailedData _wire2api_box_autoadd_backup_failed_data(dynamic raw) { return _wire2api_backup_failed_data(raw); } @@ -3117,6 +3245,10 @@ class BreezSdkCoreImpl implements BreezSdkCore { return _wire2api_ln_invoice(raw); } + LNOffer _wire2api_box_autoadd_ln_offer(dynamic raw) { + return _wire2api_ln_offer(raw); + } + LnPaymentDetails _wire2api_box_autoadd_ln_payment_details(dynamic raw) { return _wire2api_ln_payment_details(raw); } @@ -3364,26 +3496,30 @@ class BreezSdkCoreImpl implements BreezSdkCore { invoice: _wire2api_box_autoadd_ln_invoice(raw[1]), ); case 2: + return InputType_Bolt12Offer( + offer: _wire2api_box_autoadd_ln_offer(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]), ); @@ -3469,6 +3605,20 @@ class BreezSdkCoreImpl implements BreezSdkCore { ); } + LNOffer _wire2api_ln_offer(dynamic raw) { + final arr = raw as List; + if (arr.length != 7) throw Exception('unexpected arr length: expect 7 but see ${arr.length}'); + return LNOffer( + bolt12: _wire2api_String(arr[0]), + chains: _wire2api_StringList(arr[1]), + amount: _wire2api_opt_box_autoadd_amount(arr[2]), + description: _wire2api_String(arr[3]), + absoluteExpiry: _wire2api_opt_box_autoadd_u64(arr[4]), + issuer: _wire2api_opt_String(arr[5]), + signingPubkey: _wire2api_String(arr[6]), + ); + } + LnPaymentDetails _wire2api_ln_payment_details(dynamic raw) { final arr = raw as List; if (arr.length != 16) throw Exception('unexpected arr length: expect 16 but see ${arr.length}'); @@ -3770,6 +3920,10 @@ class BreezSdkCoreImpl implements BreezSdkCore { return raw == null ? null : _wire2api_StringList(raw); } + Amount? _wire2api_opt_box_autoadd_amount(dynamic raw) { + return raw == null ? null : _wire2api_box_autoadd_amount(raw); + } + bool? _wire2api_opt_box_autoadd_bool(dynamic raw) { return raw == null ? null : _wire2api_box_autoadd_bool(raw); } @@ -4267,6 +4421,18 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { return ptr; } + @protected + ffi.Pointer api2wire_box_autoadd_create_offer_request(CreateOfferRequest raw) { + final ptr = inner.new_box_autoadd_create_offer_request_0(); + _api_fill_to_wire_create_offer_request(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_f64(double raw) { + return inner.new_box_autoadd_f64_0(api2wire_f64(raw)); + } + @protected ffi.Pointer api2wire_box_autoadd_greenlight_credentials( GreenlightCredentials raw) { @@ -4340,6 +4506,13 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { return ptr; } + @protected + ffi.Pointer api2wire_box_autoadd_pay_offer_request(PayOfferRequest raw) { + final ptr = inner.new_box_autoadd_pay_offer_request_0(); + _api_fill_to_wire_pay_offer_request(raw, ptr.ref); + return ptr; + } + @protected ffi.Pointer api2wire_box_autoadd_pay_onchain_request(PayOnchainRequest raw) { final ptr = inner.new_box_autoadd_pay_onchain_request_0(); @@ -4513,6 +4686,11 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { return raw == null ? ffi.nullptr : api2wire_box_autoadd_bool(raw); } + @protected + ffi.Pointer api2wire_opt_box_autoadd_f64(double? raw) { + return raw == null ? ffi.nullptr : api2wire_box_autoadd_f64(raw); + } + @protected ffi.Pointer api2wire_opt_box_autoadd_greenlight_credentials( GreenlightCredentials? raw) { @@ -4595,6 +4773,11 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { _api_fill_to_wire_connect_request(apiObj, wireObj.ref); } + void _api_fill_to_wire_box_autoadd_create_offer_request( + CreateOfferRequest apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_create_offer_request(apiObj, wireObj.ref); + } + void _api_fill_to_wire_box_autoadd_greenlight_credentials( GreenlightCredentials apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_greenlight_credentials(apiObj, wireObj.ref); @@ -4639,6 +4822,11 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { _api_fill_to_wire_opening_fee_params(apiObj, wireObj.ref); } + void _api_fill_to_wire_box_autoadd_pay_offer_request( + PayOfferRequest apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_pay_offer_request(apiObj, wireObj.ref); + } + void _api_fill_to_wire_box_autoadd_pay_onchain_request( PayOnchainRequest apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_pay_onchain_request(apiObj, wireObj.ref); @@ -4755,6 +4943,13 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { wireObj.restore_only = api2wire_opt_box_autoadd_bool(apiObj.restoreOnly); } + void _api_fill_to_wire_create_offer_request(CreateOfferRequest apiObj, wire_CreateOfferRequest wireObj) { + wireObj.amount_msat = api2wire_opt_box_autoadd_u64(apiObj.amountMsat); + wireObj.description = api2wire_String(apiObj.description); + wireObj.absolute_expiry = api2wire_opt_box_autoadd_u64(apiObj.absoluteExpiry); + wireObj.quantity_max = api2wire_opt_box_autoadd_u64(apiObj.quantityMax); + } + void _api_fill_to_wire_greenlight_credentials( GreenlightCredentials apiObj, wire_GreenlightCredentials wireObj) { wireObj.developer_key = api2wire_uint_8_list(apiObj.developerKey); @@ -4851,6 +5046,14 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { wireObj.promise = api2wire_String(apiObj.promise); } + void _api_fill_to_wire_pay_offer_request(PayOfferRequest apiObj, wire_PayOfferRequest wireObj) { + wireObj.offer = api2wire_String(apiObj.offer); + wireObj.amount_msat = api2wire_opt_box_autoadd_u64(apiObj.amountMsat); + wireObj.timeout = api2wire_opt_box_autoadd_f64(apiObj.timeout); + wireObj.payer_note = api2wire_opt_String(apiObj.payerNote); + wireObj.label = api2wire_opt_String(apiObj.label); + } + void _api_fill_to_wire_pay_onchain_request(PayOnchainRequest apiObj, wire_PayOnchainRequest wireObj) { wireObj.recipient_address = api2wire_String(apiObj.recipientAddress); _api_fill_to_wire_prepare_onchain_payment_response(apiObj.prepareRes, wireObj.prepare_res); @@ -4945,7 +5148,7 @@ class BreezSdkCorePlatform extends FlutterRustBridgeBase { } void _api_fill_to_wire_send_payment_request(SendPaymentRequest apiObj, wire_SendPaymentRequest wireObj) { - wireObj.bolt11 = api2wire_String(apiObj.bolt11); + wireObj.invoice = api2wire_String(apiObj.invoice); wireObj.amount_msat = api2wire_opt_box_autoadd_u64(apiObj.amountMsat); wireObj.label = api2wire_opt_String(apiObj.label); } @@ -5534,6 +5737,38 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { late final _wire_receive_payment = _wire_receive_paymentPtr.asFunction)>(); + void wire_create_offer( + int port_, + ffi.Pointer req, + ) { + return _wire_create_offer( + port_, + req, + ); + } + + late final _wire_create_offerPtr = + _lookup)>>( + 'wire_create_offer'); + late final _wire_create_offer = + _wire_create_offerPtr.asFunction)>(); + + void wire_pay_offer( + int port_, + ffi.Pointer req, + ) { + return _wire_pay_offer( + port_, + req, + ); + } + + late final _wire_pay_offerPtr = + _lookup)>>( + 'wire_pay_offer'); + late final _wire_pay_offer = + _wire_pay_offerPtr.asFunction)>(); + void wire_lnurl_pay( int port_, ffi.Pointer req, @@ -5995,6 +6230,29 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { late final _new_box_autoadd_connect_request_0 = _new_box_autoadd_connect_request_0Ptr.asFunction Function()>(); + ffi.Pointer new_box_autoadd_create_offer_request_0() { + return _new_box_autoadd_create_offer_request_0(); + } + + late final _new_box_autoadd_create_offer_request_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_create_offer_request_0'); + late final _new_box_autoadd_create_offer_request_0 = _new_box_autoadd_create_offer_request_0Ptr + .asFunction Function()>(); + + ffi.Pointer new_box_autoadd_f64_0( + double value, + ) { + return _new_box_autoadd_f64_0( + value, + ); + } + + late final _new_box_autoadd_f64_0Ptr = + _lookup Function(ffi.Double)>>('new_box_autoadd_f64_0'); + late final _new_box_autoadd_f64_0 = + _new_box_autoadd_f64_0Ptr.asFunction Function(double)>(); + ffi.Pointer new_box_autoadd_greenlight_credentials_0() { return _new_box_autoadd_greenlight_credentials_0(); } @@ -6097,6 +6355,16 @@ class BreezSdkCoreWire implements FlutterRustBridgeWireBase { late final _new_box_autoadd_opening_fee_params_0 = _new_box_autoadd_opening_fee_params_0Ptr.asFunction Function()>(); + ffi.Pointer new_box_autoadd_pay_offer_request_0() { + return _new_box_autoadd_pay_offer_request_0(); + } + + late final _new_box_autoadd_pay_offer_request_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_pay_offer_request_0'); + late final _new_box_autoadd_pay_offer_request_0 = + _new_box_autoadd_pay_offer_request_0Ptr.asFunction Function()>(); + ffi.Pointer new_box_autoadd_pay_onchain_request_0() { return _new_box_autoadd_pay_onchain_request_0(); } @@ -6505,7 +6773,7 @@ final class wire_ListPaymentsRequest extends ffi.Struct { } final class wire_SendPaymentRequest extends ffi.Struct { - external ffi.Pointer bolt11; + external ffi.Pointer invoice; external ffi.Pointer amount_msat; @@ -6572,6 +6840,28 @@ final class wire_ReceivePaymentRequest extends ffi.Struct { external ffi.Pointer cltv; } +final class wire_CreateOfferRequest extends ffi.Struct { + external ffi.Pointer amount_msat; + + external ffi.Pointer description; + + external ffi.Pointer absolute_expiry; + + external ffi.Pointer quantity_max; +} + +final class wire_PayOfferRequest extends ffi.Struct { + external ffi.Pointer offer; + + external ffi.Pointer amount_msat; + + external ffi.Pointer timeout; + + external ffi.Pointer payer_note; + + external ffi.Pointer label; +} + final class wire_LnUrlPayRequestData extends ffi.Struct { external ffi.Pointer callback; diff --git a/libs/sdk-flutter/lib/bridge_generated.freezed.dart b/libs/sdk-flutter/lib/bridge_generated.freezed.dart index 03be1dbae..df4bd5248 100644 --- a/libs/sdk-flutter/lib/bridge_generated.freezed.dart +++ b/libs/sdk-flutter/lib/bridge_generated.freezed.dart @@ -347,6 +347,335 @@ abstract class AesSuccessActionDataResult_ErrorStatus implements AesSuccessActio get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +mixin _$Amount { + @optionalTypeArgs + TResult when({ + required TResult Function(int amountMsat) bitcoin, + required TResult Function(String iso4217Code, int fractionalAmount) currency, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int amountMsat)? bitcoin, + TResult? Function(String iso4217Code, int fractionalAmount)? currency, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int amountMsat)? bitcoin, + TResult Function(String iso4217Code, int fractionalAmount)? currency, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(Amount_Bitcoin value) bitcoin, + required TResult Function(Amount_Currency value) currency, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(Amount_Bitcoin value)? bitcoin, + TResult? Function(Amount_Currency value)? currency, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(Amount_Bitcoin value)? bitcoin, + TResult Function(Amount_Currency value)? currency, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AmountCopyWith<$Res> { + factory $AmountCopyWith(Amount value, $Res Function(Amount) then) = _$AmountCopyWithImpl<$Res, Amount>; +} + +/// @nodoc +class _$AmountCopyWithImpl<$Res, $Val extends Amount> implements $AmountCopyWith<$Res> { + _$AmountCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$Amount_BitcoinImplCopyWith<$Res> { + factory _$$Amount_BitcoinImplCopyWith( + _$Amount_BitcoinImpl value, $Res Function(_$Amount_BitcoinImpl) then) = + __$$Amount_BitcoinImplCopyWithImpl<$Res>; + @useResult + $Res call({int amountMsat}); +} + +/// @nodoc +class __$$Amount_BitcoinImplCopyWithImpl<$Res> extends _$AmountCopyWithImpl<$Res, _$Amount_BitcoinImpl> + implements _$$Amount_BitcoinImplCopyWith<$Res> { + __$$Amount_BitcoinImplCopyWithImpl(_$Amount_BitcoinImpl _value, $Res Function(_$Amount_BitcoinImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? amountMsat = null, + }) { + return _then(_$Amount_BitcoinImpl( + amountMsat: null == amountMsat + ? _value.amountMsat + : amountMsat // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$Amount_BitcoinImpl implements Amount_Bitcoin { + const _$Amount_BitcoinImpl({required this.amountMsat}); + + @override + final int amountMsat; + + @override + String toString() { + return 'Amount.bitcoin(amountMsat: $amountMsat)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$Amount_BitcoinImpl && + (identical(other.amountMsat, amountMsat) || other.amountMsat == amountMsat)); + } + + @override + int get hashCode => Object.hash(runtimeType, amountMsat); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$Amount_BitcoinImplCopyWith<_$Amount_BitcoinImpl> get copyWith => + __$$Amount_BitcoinImplCopyWithImpl<_$Amount_BitcoinImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int amountMsat) bitcoin, + required TResult Function(String iso4217Code, int fractionalAmount) currency, + }) { + return bitcoin(amountMsat); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int amountMsat)? bitcoin, + TResult? Function(String iso4217Code, int fractionalAmount)? currency, + }) { + return bitcoin?.call(amountMsat); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int amountMsat)? bitcoin, + TResult Function(String iso4217Code, int fractionalAmount)? currency, + required TResult orElse(), + }) { + if (bitcoin != null) { + return bitcoin(amountMsat); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(Amount_Bitcoin value) bitcoin, + required TResult Function(Amount_Currency value) currency, + }) { + return bitcoin(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(Amount_Bitcoin value)? bitcoin, + TResult? Function(Amount_Currency value)? currency, + }) { + return bitcoin?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(Amount_Bitcoin value)? bitcoin, + TResult Function(Amount_Currency value)? currency, + required TResult orElse(), + }) { + if (bitcoin != null) { + return bitcoin(this); + } + return orElse(); + } +} + +abstract class Amount_Bitcoin implements Amount { + const factory Amount_Bitcoin({required final int amountMsat}) = _$Amount_BitcoinImpl; + + int get amountMsat; + @JsonKey(ignore: true) + _$$Amount_BitcoinImplCopyWith<_$Amount_BitcoinImpl> get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$Amount_CurrencyImplCopyWith<$Res> { + factory _$$Amount_CurrencyImplCopyWith( + _$Amount_CurrencyImpl value, $Res Function(_$Amount_CurrencyImpl) then) = + __$$Amount_CurrencyImplCopyWithImpl<$Res>; + @useResult + $Res call({String iso4217Code, int fractionalAmount}); +} + +/// @nodoc +class __$$Amount_CurrencyImplCopyWithImpl<$Res> extends _$AmountCopyWithImpl<$Res, _$Amount_CurrencyImpl> + implements _$$Amount_CurrencyImplCopyWith<$Res> { + __$$Amount_CurrencyImplCopyWithImpl( + _$Amount_CurrencyImpl _value, $Res Function(_$Amount_CurrencyImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? iso4217Code = null, + Object? fractionalAmount = null, + }) { + return _then(_$Amount_CurrencyImpl( + iso4217Code: null == iso4217Code + ? _value.iso4217Code + : iso4217Code // ignore: cast_nullable_to_non_nullable + as String, + fractionalAmount: null == fractionalAmount + ? _value.fractionalAmount + : fractionalAmount // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$Amount_CurrencyImpl implements Amount_Currency { + const _$Amount_CurrencyImpl({required this.iso4217Code, required this.fractionalAmount}); + + @override + final String iso4217Code; + @override + final int fractionalAmount; + + @override + String toString() { + return 'Amount.currency(iso4217Code: $iso4217Code, fractionalAmount: $fractionalAmount)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$Amount_CurrencyImpl && + (identical(other.iso4217Code, iso4217Code) || other.iso4217Code == iso4217Code) && + (identical(other.fractionalAmount, fractionalAmount) || + other.fractionalAmount == fractionalAmount)); + } + + @override + int get hashCode => Object.hash(runtimeType, iso4217Code, fractionalAmount); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$Amount_CurrencyImplCopyWith<_$Amount_CurrencyImpl> get copyWith => + __$$Amount_CurrencyImplCopyWithImpl<_$Amount_CurrencyImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int amountMsat) bitcoin, + required TResult Function(String iso4217Code, int fractionalAmount) currency, + }) { + return currency(iso4217Code, fractionalAmount); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int amountMsat)? bitcoin, + TResult? Function(String iso4217Code, int fractionalAmount)? currency, + }) { + return currency?.call(iso4217Code, fractionalAmount); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int amountMsat)? bitcoin, + TResult Function(String iso4217Code, int fractionalAmount)? currency, + required TResult orElse(), + }) { + if (currency != null) { + return currency(iso4217Code, fractionalAmount); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(Amount_Bitcoin value) bitcoin, + required TResult Function(Amount_Currency value) currency, + }) { + return currency(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(Amount_Bitcoin value)? bitcoin, + TResult? Function(Amount_Currency value)? currency, + }) { + return currency?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(Amount_Bitcoin value)? bitcoin, + TResult Function(Amount_Currency value)? currency, + required TResult orElse(), + }) { + if (currency != null) { + return currency(this); + } + return orElse(); + } +} + +abstract class Amount_Currency implements Amount { + const factory Amount_Currency({required final String iso4217Code, required final int fractionalAmount}) = + _$Amount_CurrencyImpl; + + String get iso4217Code; + int get fractionalAmount; + @JsonKey(ignore: true) + _$$Amount_CurrencyImplCopyWith<_$Amount_CurrencyImpl> get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc mixin _$BreezEvent { @optionalTypeArgs @@ -1937,6 +2266,7 @@ mixin _$InputType { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -1949,6 +2279,7 @@ mixin _$InputType { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -1961,6 +2292,7 @@ mixin _$InputType { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -1974,6 +2306,7 @@ mixin _$InputType { TResult map({ required TResult Function(InputType_BitcoinAddress value) bitcoinAddress, required TResult Function(InputType_Bolt11 value) bolt11, + required TResult Function(InputType_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -1986,6 +2319,7 @@ mixin _$InputType { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -1998,6 +2332,7 @@ mixin _$InputType { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2091,6 +2426,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2106,6 +2442,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2121,6 +2458,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2140,6 +2478,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2155,6 +2494,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2170,6 +2510,7 @@ class _$InputType_BitcoinAddressImpl implements InputType_BitcoinAddress { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2260,6 +2601,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2275,6 +2617,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2290,6 +2633,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2309,6 +2653,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2324,6 +2669,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2339,6 +2685,7 @@ class _$InputType_Bolt11Impl implements InputType_Bolt11 { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2362,6 +2709,181 @@ abstract class InputType_Bolt11 implements InputType { _$$InputType_Bolt11ImplCopyWith<_$InputType_Bolt11Impl> get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$InputType_Bolt12OfferImplCopyWith<$Res> { + factory _$$InputType_Bolt12OfferImplCopyWith( + _$InputType_Bolt12OfferImpl value, $Res Function(_$InputType_Bolt12OfferImpl) then) = + __$$InputType_Bolt12OfferImplCopyWithImpl<$Res>; + @useResult + $Res call({LNOffer offer}); +} + +/// @nodoc +class __$$InputType_Bolt12OfferImplCopyWithImpl<$Res> + extends _$InputTypeCopyWithImpl<$Res, _$InputType_Bolt12OfferImpl> + implements _$$InputType_Bolt12OfferImplCopyWith<$Res> { + __$$InputType_Bolt12OfferImplCopyWithImpl( + _$InputType_Bolt12OfferImpl _value, $Res Function(_$InputType_Bolt12OfferImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? offer = null, + }) { + return _then(_$InputType_Bolt12OfferImpl( + offer: null == offer + ? _value.offer + : offer // ignore: cast_nullable_to_non_nullable + as LNOffer, + )); + } +} + +/// @nodoc + +class _$InputType_Bolt12OfferImpl implements InputType_Bolt12Offer { + const _$InputType_Bolt12OfferImpl({required this.offer}); + + @override + final LNOffer offer; + + @override + String toString() { + return 'InputType.bolt12Offer(offer: $offer)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InputType_Bolt12OfferImpl && + (identical(other.offer, offer) || other.offer == offer)); + } + + @override + int get hashCode => Object.hash(runtimeType, offer); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$InputType_Bolt12OfferImplCopyWith<_$InputType_Bolt12OfferImpl> get copyWith => + __$$InputType_Bolt12OfferImplCopyWithImpl<_$InputType_Bolt12OfferImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(BitcoinAddressData address) bitcoinAddress, + required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, + 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 bolt12Offer(offer); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(BitcoinAddressData address)? bitcoinAddress, + TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, + 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 bolt12Offer?.call(offer); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(BitcoinAddressData address)? bitcoinAddress, + TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, + 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 (bolt12Offer != null) { + return bolt12Offer(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_Bolt12Offer value) bolt12Offer, + 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 bolt12Offer(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, + TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, + 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 bolt12Offer?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, + TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, + 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 (bolt12Offer != null) { + return bolt12Offer(this); + } + return orElse(); + } +} + +abstract class InputType_Bolt12Offer implements InputType { + const factory InputType_Bolt12Offer({required final LNOffer offer}) = _$InputType_Bolt12OfferImpl; + + LNOffer get offer; + @JsonKey(ignore: true) + _$$InputType_Bolt12OfferImplCopyWith<_$InputType_Bolt12OfferImpl> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc abstract class _$$InputType_NodeIdImplCopyWith<$Res> { factory _$$InputType_NodeIdImplCopyWith( @@ -2427,6 +2949,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2442,6 +2965,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2457,6 +2981,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2476,6 +3001,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2491,6 +3017,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2506,6 +3033,7 @@ class _$InputType_NodeIdImpl implements InputType_NodeId { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2592,6 +3120,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2607,6 +3136,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2622,6 +3152,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2641,6 +3172,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2656,6 +3188,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2671,6 +3204,7 @@ class _$InputType_UrlImpl implements InputType_Url { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2760,6 +3294,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2775,6 +3310,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2790,6 +3326,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2809,6 +3346,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2824,6 +3362,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2839,6 +3378,7 @@ class _$InputType_LnUrlPayImpl implements InputType_LnUrlPay { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -2929,6 +3469,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -2944,6 +3485,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2959,6 +3501,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -2978,6 +3521,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -2993,6 +3537,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3008,6 +3553,7 @@ class _$InputType_LnUrlWithdrawImpl implements InputType_LnUrlWithdraw { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3099,6 +3645,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3114,6 +3661,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3129,6 +3677,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3148,6 +3697,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3163,6 +3713,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3178,6 +3729,7 @@ class _$InputType_LnUrlAuthImpl implements InputType_LnUrlAuth { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, TResult Function(InputType_NodeId value)? nodeId, TResult Function(InputType_Url value)? url, TResult Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3268,6 +3820,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult when({ required TResult Function(BitcoinAddressData address) bitcoinAddress, required TResult Function(LNInvoice invoice) bolt11, + required TResult Function(LNOffer offer) bolt12Offer, required TResult Function(String nodeId) nodeId, required TResult Function(String url) url, required TResult Function(LnUrlPayRequestData data) lnUrlPay, @@ -3283,6 +3836,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult? whenOrNull({ TResult? Function(BitcoinAddressData address)? bitcoinAddress, TResult? Function(LNInvoice invoice)? bolt11, + TResult? Function(LNOffer offer)? bolt12Offer, TResult? Function(String nodeId)? nodeId, TResult? Function(String url)? url, TResult? Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3298,6 +3852,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult maybeWhen({ TResult Function(BitcoinAddressData address)? bitcoinAddress, TResult Function(LNInvoice invoice)? bolt11, + TResult Function(LNOffer offer)? bolt12Offer, TResult Function(String nodeId)? nodeId, TResult Function(String url)? url, TResult Function(LnUrlPayRequestData data)? lnUrlPay, @@ -3317,6 +3872,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_Bolt12Offer value) bolt12Offer, required TResult Function(InputType_NodeId value) nodeId, required TResult Function(InputType_Url value) url, required TResult Function(InputType_LnUrlPay value) lnUrlPay, @@ -3332,6 +3888,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult? mapOrNull({ TResult? Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult? Function(InputType_Bolt11 value)? bolt11, + TResult? Function(InputType_Bolt12Offer value)? bolt12Offer, TResult? Function(InputType_NodeId value)? nodeId, TResult? Function(InputType_Url value)? url, TResult? Function(InputType_LnUrlPay value)? lnUrlPay, @@ -3347,6 +3904,7 @@ class _$InputType_LnUrlErrorImpl implements InputType_LnUrlError { TResult maybeMap({ TResult Function(InputType_BitcoinAddress value)? bitcoinAddress, TResult Function(InputType_Bolt11 value)? bolt11, + TResult Function(InputType_Bolt12Offer value)? bolt12Offer, 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 1355a31e1..9c2a5d58e 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 @@ -436,6 +436,7 @@ fun asConfigList(arr: ReadableArray): List { return list } +<<<<<<< HEAD fun asConfigureNodeRequest(configureNodeRequest: ReadableMap): ConfigureNodeRequest? { if (!validateMandatoryFields( configureNodeRequest, @@ -481,11 +482,19 @@ fun asConnectRequest(connectRequest: ReadableMap): ConnectRequest? { arrayOf( "config", "seed", +======= +fun asCreateOfferRequest(createOfferRequest: ReadableMap): CreateOfferRequest? { + if (!validateMandatoryFields( + createOfferRequest, + arrayOf( + "description", +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) ), ) ) { return null } +<<<<<<< HEAD val config = connectRequest.getMap("config")?.let { asConfig(it) }!! val seed = connectRequest.getArray("seed")?.let { asUByteList(it) }!! val restoreOnly = if (hasNonNullKey(connectRequest, "restoreOnly")) connectRequest.getBoolean("restoreOnly") else null @@ -508,6 +517,40 @@ fun asConnectRequestList(arr: ReadableArray): List { for (value in arr.toArrayList()) { when (value) { is ReadableMap -> list.add(asConnectRequest(value)!!) +======= + val amountMsat = if (hasNonNullKey(createOfferRequest, "amountMsat")) createOfferRequest.getDouble("amountMsat").toULong() else null + val description = createOfferRequest.getString("description")!! + val absoluteExpiry = + if (hasNonNullKey( + createOfferRequest, + "absoluteExpiry", + ) + ) { + createOfferRequest.getDouble("absoluteExpiry").toULong() + } else { + null + } + return CreateOfferRequest( + amountMsat, + description, + absoluteExpiry, + ) +} + +fun readableMapOf(createOfferRequest: CreateOfferRequest): ReadableMap { + return readableMapOf( + "amountMsat" to createOfferRequest.amountMsat, + "description" to createOfferRequest.description, + "absoluteExpiry" to createOfferRequest.absoluteExpiry, + ) +} + +fun asCreateOfferRequestList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asCreateOfferRequest(value)!!) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) } } @@ -634,6 +677,7 @@ fun asGreenlightCredentialsList(arr: ReadableArray): List when (value) { is ReadableMap -> list.add(asGreenlightCredentials(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -666,6 +710,8 @@ fun asGreenlightDeviceCredentialsList(arr: ReadableArray): List list.add(asGreenlightDeviceCredentials(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -822,6 +868,63 @@ fun asLnInvoiceList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asLnInvoice(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD +======= + } + } + return list +} + +fun asLnOffer(lnOffer: ReadableMap): LnOffer? { + if (!validateMandatoryFields( + lnOffer, + arrayOf( + "bolt12", + "chains", + "description", + "signingPubkey", + ), + ) + ) { + return null + } + val bolt12 = lnOffer.getString("bolt12")!! + val chains = lnOffer.getArray("chains")?.let { asStringList(it) }!! + val description = lnOffer.getString("description")!! + val signingPubkey = lnOffer.getString("signingPubkey")!! + val amount = if (hasNonNullKey(lnOffer, "amount")) lnOffer.getMap("amount")?.let { asAmount(it) } else null + val absoluteExpiry = if (hasNonNullKey(lnOffer, "absoluteExpiry")) lnOffer.getDouble("absoluteExpiry").toULong() else null + val issuer = if (hasNonNullKey(lnOffer, "issuer")) lnOffer.getString("issuer") else null + return LnOffer( + bolt12, + chains, + description, + signingPubkey, + amount, + absoluteExpiry, + issuer, + ) +} + +fun readableMapOf(lnOffer: LnOffer): ReadableMap { + return readableMapOf( + "bolt12" to lnOffer.bolt12, + "chains" to readableArrayOf(lnOffer.chains), + "description" to lnOffer.description, + "signingPubkey" to lnOffer.signingPubkey, + "amount" to lnOffer.amount?.let { readableMapOf(it) }, + "absoluteExpiry" to lnOffer.absoluteExpiry, + "issuer" to lnOffer.issuer, + ) +} + +fun asLnOfferList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asLnOffer(value)!!) + else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -1584,6 +1687,7 @@ fun asLspInformationList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asLspInformation(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -1616,6 +1720,8 @@ fun asMaxReverseSwapAmountResponseList(arr: ReadableArray): List list.add(asMaxReverseSwapAmountResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -1648,6 +1754,7 @@ fun asMessageSuccessActionDataList(arr: ReadableArray): List list.add(asMessageSuccessActionData(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -1684,6 +1791,8 @@ fun asMetadataFilterList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asMetadataFilter(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -1796,6 +1905,7 @@ fun asNodeStateList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asNodeState(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -1832,6 +1942,8 @@ fun asOnchainPaymentLimitsResponseList(arr: ReadableArray): List list.add(asOnchainPaymentLimitsResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -1998,17 +2110,26 @@ fun asOpeningFeeParamsMenuList(arr: ReadableArray): List { return list } +<<<<<<< HEAD fun asPayOnchainRequest(payOnchainRequest: ReadableMap): PayOnchainRequest? { if (!validateMandatoryFields( payOnchainRequest, arrayOf( "recipientAddress", "prepareRes", +======= +fun asPayOfferRequest(payOfferRequest: ReadableMap): PayOfferRequest? { + if (!validateMandatoryFields( + payOfferRequest, + arrayOf( + "offer", +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) ), ) ) { return null } +<<<<<<< HEAD val recipientAddress = payOnchainRequest.getString("recipientAddress")!! val prepareRes = payOnchainRequest.getMap("prepareRes")?.let { asPrepareOnchainPaymentResponse(it) }!! return PayOnchainRequest( @@ -2060,6 +2181,34 @@ fun asPayOnchainResponseList(arr: ReadableArray): List { for (value in arr.toArrayList()) { when (value) { is ReadableMap -> list.add(asPayOnchainResponse(value)!!) +======= + val offer = payOfferRequest.getString("offer")!! + val amountMsat = if (hasNonNullKey(payOfferRequest, "amountMsat")) payOfferRequest.getDouble("amountMsat").toULong() else null + val timeout = if (hasNonNullKey(payOfferRequest, "timeout")) payOfferRequest.getDouble("timeout") else null + val payerNote = if (hasNonNullKey(payOfferRequest, "payerNote")) payOfferRequest.getString("payerNote") else null + return PayOfferRequest( + offer, + amountMsat, + timeout, + payerNote, + ) +} + +fun readableMapOf(payOfferRequest: PayOfferRequest): ReadableMap { + return readableMapOf( + "offer" to payOfferRequest.offer, + "amountMsat" to payOfferRequest.amountMsat, + "timeout" to payOfferRequest.timeout, + "payerNote" to payOfferRequest.payerNote, + ) +} + +fun asPayOfferRequestList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asPayOfferRequest(value)!!) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) } } @@ -2168,6 +2317,7 @@ fun asPaymentFailedDataList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asPaymentFailedData(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -2336,6 +2486,8 @@ fun asPrepareRedeemOnchainFundsResponseList(arr: ReadableArray): List list.add(asPrepareRedeemOnchainFundsResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -2412,6 +2564,83 @@ fun asPrepareRefundResponseList(arr: ReadableArray): List when (value) { is ReadableMap -> list.add(asPrepareRefundResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD +======= + } + } + return list +} + +fun asPrepareSweepRequest(prepareSweepRequest: ReadableMap): PrepareSweepRequest? { + if (!validateMandatoryFields( + prepareSweepRequest, + arrayOf( + "toAddress", + "satsPerVbyte", + ), + ) + ) { + return null + } + val toAddress = prepareSweepRequest.getString("toAddress")!! + val satsPerVbyte = prepareSweepRequest.getDouble("satsPerVbyte").toULong() + return PrepareSweepRequest( + toAddress, + satsPerVbyte, + ) +} + +fun readableMapOf(prepareSweepRequest: PrepareSweepRequest): ReadableMap { + return readableMapOf( + "toAddress" to prepareSweepRequest.toAddress, + "satsPerVbyte" to prepareSweepRequest.satsPerVbyte, + ) +} + +fun asPrepareSweepRequestList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asPrepareSweepRequest(value)!!) + else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) + } + } + return list +} + +fun asPrepareSweepResponse(prepareSweepResponse: ReadableMap): PrepareSweepResponse? { + if (!validateMandatoryFields( + prepareSweepResponse, + arrayOf( + "sweepTxWeight", + "sweepTxFeeSat", + ), + ) + ) { + return null + } + val sweepTxWeight = prepareSweepResponse.getDouble("sweepTxWeight").toULong() + val sweepTxFeeSat = prepareSweepResponse.getDouble("sweepTxFeeSat").toULong() + return PrepareSweepResponse( + sweepTxWeight, + sweepTxFeeSat, + ) +} + +fun readableMapOf(prepareSweepResponse: PrepareSweepResponse): ReadableMap { + return readableMapOf( + "sweepTxWeight" to prepareSweepResponse.sweepTxWeight, + "sweepTxFeeSat" to prepareSweepResponse.sweepTxFeeSat, + ) +} + +fun asPrepareSweepResponseList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asPrepareSweepResponse(value)!!) + else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -2673,6 +2902,7 @@ fun asRecommendedFeesList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asRecommendedFees(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -2741,6 +2971,8 @@ fun asRedeemOnchainFundsResponseList(arr: ReadableArray): List list.add(asRedeemOnchainFundsResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -2813,6 +3045,7 @@ fun asRefundResponseList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asRefundResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -2848,6 +3081,8 @@ fun asReportPaymentFailureDetailsList(arr: ReadableArray): List list.add(asReportPaymentFailureDetails(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -3175,25 +3410,31 @@ fun asSendPaymentRequest(sendPaymentRequest: ReadableMap): SendPaymentRequest? { if (!validateMandatoryFields( sendPaymentRequest, arrayOf( - "bolt11", + "invoice", ), ) ) { return null } - val bolt11 = sendPaymentRequest.getString("bolt11")!! + val invoice = sendPaymentRequest.getString("invoice")!! val amountMsat = if (hasNonNullKey(sendPaymentRequest, "amountMsat")) sendPaymentRequest.getDouble("amountMsat").toULong() else null val label = if (hasNonNullKey(sendPaymentRequest, "label")) sendPaymentRequest.getString("label") else null return SendPaymentRequest( - bolt11, + invoice, amountMsat, label, ) } +<<<<<<< HEAD fun readableMapOf(sendPaymentRequest: SendPaymentRequest): ReadableMap = readableMapOf( "bolt11" to sendPaymentRequest.bolt11, +======= +fun readableMapOf(sendPaymentRequest: SendPaymentRequest): ReadableMap { + return readableMapOf( + "invoice" to sendPaymentRequest.invoice, +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) "amountMsat" to sendPaymentRequest.amountMsat, "label" to sendPaymentRequest.label, ) @@ -3289,6 +3530,7 @@ fun asSendSpontaneousPaymentRequestList(arr: ReadableArray): List list.add(asSendSpontaneousPaymentRequest(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -3321,6 +3563,8 @@ fun asServiceHealthCheckResponseList(arr: ReadableArray): List list.add(asServiceHealthCheckResponse(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -3583,6 +3827,79 @@ fun asSwapInfoList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asSwapInfo(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD +======= + } + } + return list +} + +fun asSweepRequest(sweepRequest: ReadableMap): SweepRequest? { + if (!validateMandatoryFields( + sweepRequest, + arrayOf( + "toAddress", + "feeRateSatsPerVbyte", + ), + ) + ) { + return null + } + val toAddress = sweepRequest.getString("toAddress")!! + val feeRateSatsPerVbyte = sweepRequest.getInt("feeRateSatsPerVbyte").toUInt() + return SweepRequest( + toAddress, + feeRateSatsPerVbyte, + ) +} + +fun readableMapOf(sweepRequest: SweepRequest): ReadableMap { + return readableMapOf( + "toAddress" to sweepRequest.toAddress, + "feeRateSatsPerVbyte" to sweepRequest.feeRateSatsPerVbyte, + ) +} + +fun asSweepRequestList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asSweepRequest(value)!!) + else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) + } + } + return list +} + +fun asSweepResponse(sweepResponse: ReadableMap): SweepResponse? { + if (!validateMandatoryFields( + sweepResponse, + arrayOf( + "txid", + ), + ) + ) { + return null + } + val txid = sweepResponse.getArray("txid")?.let { asUByteList(it) }!! + return SweepResponse( + txid, + ) +} + +fun readableMapOf(sweepResponse: SweepResponse): ReadableMap { + return readableMapOf( + "txid" to readableArrayOf(sweepResponse.txid), + ) +} + +fun asSweepResponseList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asSweepResponse(value)!!) + else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -3622,6 +3939,7 @@ fun asSymbolList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asSymbol(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -3658,6 +3976,8 @@ fun asTlvEntryList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asTlvEntry(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -3747,6 +4067,7 @@ fun asUrlSuccessActionDataList(arr: ReadableArray): List { return list } +<<<<<<< HEAD fun asAesSuccessActionDataResult(aesSuccessActionDataResult: ReadableMap): AesSuccessActionDataResult? { val type = aesSuccessActionDataResult.getString("type") @@ -3757,10 +4078,21 @@ fun asAesSuccessActionDataResult(aesSuccessActionDataResult: ReadableMap): AesSu } if (type == "errorStatus") { return AesSuccessActionDataResult.ErrorStatus(aesSuccessActionDataResult.getString("reason")!!) +======= +fun asAmount(amount: ReadableMap): Amount? { + val type = amount.getString("type") + + if (type == "bitcoin") { + return Amount.Bitcoin(amount.getDouble("amountMsat").toULong()) + } + if (type == "currency") { + return Amount.Currency(amount.getString("iso4217Code")!!) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } return null } +<<<<<<< HEAD fun readableMapOf(aesSuccessActionDataResult: AesSuccessActionDataResult): ReadableMap? { val map = Arguments.createMap() when (aesSuccessActionDataResult) { @@ -3771,16 +4103,37 @@ fun readableMapOf(aesSuccessActionDataResult: AesSuccessActionDataResult): Reada is AesSuccessActionDataResult.ErrorStatus -> { pushToMap(map, "type", "errorStatus") pushToMap(map, "reason", aesSuccessActionDataResult.reason) +======= +fun readableMapOf(amount: Amount): ReadableMap? { + val map = Arguments.createMap() + when (amount) { + is Amount.Bitcoin -> { + pushToMap(map, "type", "bitcoin") + pushToMap(map, "amountMsat", amount.amountMsat) + } + is Amount.Currency -> { + pushToMap(map, "type", "currency") + pushToMap(map, "iso4217Code", amount.iso4217Code) + pushToMap(map, "fractionalAmount", amount.fractionalAmount) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return map } +<<<<<<< HEAD fun asAesSuccessActionDataResultList(arr: ReadableArray): List { val list = ArrayList() for (value in arr.toArrayList()) { when (value) { is ReadableMap -> list.add(asAesSuccessActionDataResult(value)!!) +======= +fun asAmountList(arr: ReadableArray): List { + val list = ArrayList() + for (value in arr.toArrayList()) { + when (value) { + is ReadableMap -> list.add(asAmount(value)!!) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) } } @@ -3918,6 +4271,7 @@ fun asFeeratePresetList(arr: ReadableArray): List { when (value) { is String -> list.add(asFeeratePreset(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -3931,6 +4285,8 @@ fun asHealthCheckStatusList(arr: ReadableArray): List { when (value) { is String -> list.add(asHealthCheckStatus(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -3945,6 +4301,9 @@ fun asInputType(inputType: ReadableMap): InputType? { if (type == "bolt11") { return InputType.Bolt11(inputType.getMap("invoice")?.let { asLnInvoice(it) }!!) } + if (type == "bolt12Offer") { + return InputType.Bolt12Offer(inputType.getMap("offer")?.let { asLnOffer(it) }!!) + } if (type == "nodeId") { return InputType.NodeId(inputType.getString("nodeId")!!) } @@ -3977,6 +4336,10 @@ fun readableMapOf(inputType: InputType): ReadableMap? { pushToMap(map, "type", "bolt11") pushToMap(map, "invoice", readableMapOf(inputType.invoice)) } + is InputType.Bolt12Offer -> { + pushToMap(map, "type", "bolt12Offer") + pushToMap(map, "offer", readableMapOf(inputType.offer)) + } is InputType.NodeId -> { pushToMap(map, "type", "nodeId") pushToMap(map, "nodeId", inputType.nodeId) @@ -4182,6 +4545,7 @@ fun asNodeConfigList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asNodeConfig(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +<<<<<<< HEAD } } return list @@ -4213,6 +4577,8 @@ fun asNodeCredentialsList(arr: ReadableArray): List { when (value) { is ReadableMap -> list.add(asNodeCredentials(value)!!) else -> throw SdkException.Generic(errUnexpectedType("${value::class.java.name}")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -4524,6 +4890,7 @@ fun asStringList(arr: ReadableArray): List { fun errMissingMandatoryField( fieldName: String, typeName: String, +<<<<<<< HEAD ): String = "Missing mandatory field $fieldName for type $typeName" fun errUnexpectedType(typeName: String): String = "Unexpected type $typeName" @@ -4533,4 +4900,16 @@ fun errUnexpectedValue(fieldName: String): String = "Unexpected value for option fun camelToUpperSnakeCase(str: String): String { val pattern = "(?<=.)[A-Z]".toRegex() return str.replace(pattern, "_$0").uppercase() +======= +): String { + return "Missing mandatory field $fieldName for type $typeName" +} + +fun errUnexpectedType(typeName: String): String { + return "Unexpected type $typeName" +} + +fun errUnexpectedValue(fieldName: String): String { + return "Unexpected value for optional field $fieldName" +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } 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 73f05778d..2cd25726d 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 @@ -109,8 +109,12 @@ class BreezSDKModule( executor.execute { try { val envTypeTmp = asEnvironmentType(envType) +<<<<<<< HEAD val nodeConfigTmp = asNodeConfig(nodeConfig) ?: run { throw SdkException.Generic(errMissingMandatoryField("nodeConfig", "NodeConfig")) } +======= + val nodeConfigTmp = asNodeConfig(nodeConfig) ?: run { throw SdkException.Generic(errMissingMandatoryField("nodeConfig", "NodeConfig")) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = defaultConfig(envTypeTmp, apiKey, nodeConfigTmp) val workingDir = File(reactApplicationContext.filesDir.toString() + "/breezSdk") @@ -130,7 +134,13 @@ class BreezSDKModule( executor.execute { try { val staticBackupRequest = +<<<<<<< HEAD asStaticBackupRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "StaticBackupRequest")) } +======= + asStaticBackupRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "StaticBackupRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = staticBackup(staticBackupRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -179,6 +189,7 @@ class BreezSDKModule( return } +<<<<<<< HEAD executor.execute { try { val connectRequest = @@ -193,6 +204,19 @@ class BreezSDKModule( e.printStackTrace() promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) } +======= + try { + val configTmp = asConfig(config) ?: run { throw SdkException.Generic(errMissingMandatoryField("config", "Config")) } + val emitter = reactApplicationContext.getJSModule(RCTDeviceEventEmitter::class.java) + + ensureWorkingDir(configTmp.workingDir) + + breezServices = connect(configTmp, asUByteList(seed), BreezSDKListener(emitter)) + promise.resolve(readableMapOf("status" to "ok")) + } catch (e: Exception) { + e.printStackTrace() + promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } @@ -202,6 +226,7 @@ class BreezSDKModule( try { getBreezServices().disconnect() breezServices = null +<<<<<<< HEAD promise.resolve(readableMapOf("status" to "ok")) } catch (e: Exception) { promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) @@ -220,6 +245,8 @@ class BreezSDKModule( asConfigureNodeRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "ConfigureNodeRequest")) } getBreezServices().configureNode(configureNodeRequest) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) promise.resolve(readableMapOf("status" to "ok")) } catch (e: Exception) { promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) @@ -235,7 +262,13 @@ class BreezSDKModule( executor.execute { try { val sendPaymentRequest = +<<<<<<< HEAD asSendPaymentRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SendPaymentRequest")) } +======= + asSendPaymentRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "SendPaymentRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().sendPayment(sendPaymentRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -252,8 +285,14 @@ class BreezSDKModule( executor.execute { try { val sendSpontaneousPaymentRequest = +<<<<<<< HEAD asSendSpontaneousPaymentRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SendSpontaneousPaymentRequest")) } +======= + asSendSpontaneousPaymentRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "SendSpontaneousPaymentRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().sendSpontaneousPayment(sendSpontaneousPaymentRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -270,8 +309,14 @@ class BreezSDKModule( executor.execute { try { val receivePaymentRequest = +<<<<<<< HEAD asReceivePaymentRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "ReceivePaymentRequest")) } +======= + asReceivePaymentRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "ReceivePaymentRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().receivePayment(receivePaymentRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -287,8 +332,12 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD val lnUrlPayRequest = asLnUrlPayRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "LnUrlPayRequest")) } +======= + val lnUrlPayRequest = asLnUrlPayRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "LnUrlPayRequest")) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().payLnurl(lnUrlPayRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -305,8 +354,14 @@ class BreezSDKModule( executor.execute { try { val lnUrlWithdrawRequest = +<<<<<<< HEAD asLnUrlWithdrawRequest(request) ?: run { throw SdkException.Generic(errMissingMandatoryField("request", "LnUrlWithdrawRequest")) } +======= + asLnUrlWithdrawRequest(request) ?: run { + throw SdkException.Generic(errMissingMandatoryField("request", "LnUrlWithdrawRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().withdrawLnurl(lnUrlWithdrawRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -323,8 +378,14 @@ class BreezSDKModule( executor.execute { try { val lnUrlAuthRequestData = +<<<<<<< HEAD asLnUrlAuthRequestData(reqData) ?: run { throw SdkException.Generic(errMissingMandatoryField("reqData", "LnUrlAuthRequestData")) } +======= + asLnUrlAuthRequestData(reqData) ?: run { + throw SdkException.Generic(errMissingMandatoryField("reqData", "LnUrlAuthRequestData")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().lnurlAuth(lnUrlAuthRequestData) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -382,7 +443,13 @@ class BreezSDKModule( executor.execute { try { val signMessageRequest = +<<<<<<< HEAD asSignMessageRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SignMessageRequest")) } +======= + asSignMessageRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "SignMessageRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().signMessage(signMessageRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -399,7 +466,13 @@ class BreezSDKModule( executor.execute { try { val checkMessageRequest = +<<<<<<< HEAD asCheckMessageRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "CheckMessageRequest")) } +======= + asCheckMessageRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "CheckMessageRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().checkMessage(checkMessageRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -472,8 +545,17 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD getBreezServices().setPaymentMetadata(hash, metadata) promise.resolve(readableMapOf("status" to "ok")) +======= + val listPaymentsRequest = + asListPaymentsRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "ListPaymentsRequest")) + } + val res = getBreezServices().listPayments(listPaymentsRequest) + promise.resolve(readableArrayOf(res)) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } catch (e: Exception) { promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) } @@ -487,10 +569,15 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD val redeemOnchainFundsRequest = asRedeemOnchainFundsRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "RedeemOnchainFundsRequest")) } val res = getBreezServices().redeemOnchainFunds(redeemOnchainFundsRequest) +======= + val sweepRequest = asSweepRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SweepRequest")) } + val res = getBreezServices().sweep(sweepRequest) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) promise.resolve(readableMapOf(res)) } catch (e: Exception) { promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) @@ -572,8 +659,14 @@ class BreezSDKModule( executor.execute { try { val openChannelFeeRequest = +<<<<<<< HEAD asOpenChannelFeeRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "OpenChannelFeeRequest")) } +======= + asOpenChannelFeeRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "OpenChannelFeeRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().openChannelFee(openChannelFeeRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -656,8 +749,14 @@ class BreezSDKModule( executor.execute { try { val receiveOnchainRequest = +<<<<<<< HEAD asReceiveOnchainRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "ReceiveOnchainRequest")) } +======= + asReceiveOnchainRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "ReceiveOnchainRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().receiveOnchain(receiveOnchainRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -725,8 +824,14 @@ class BreezSDKModule( executor.execute { try { val prepareRefundRequest = +<<<<<<< HEAD asPrepareRefundRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PrepareRefundRequest")) } +======= + asPrepareRefundRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "PrepareRefundRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().prepareRefund(prepareRefundRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -742,8 +847,12 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD val refundRequest = asRefundRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "RefundRequest")) } +======= + val refundRequest = asRefundRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "RefundRequest")) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().refund(refundRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -760,8 +869,14 @@ class BreezSDKModule( executor.execute { try { val reverseSwapFeesRequest = +<<<<<<< HEAD asReverseSwapFeesRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "ReverseSwapFeesRequest")) } +======= + asReverseSwapFeesRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "ReverseSwapFeesRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().fetchReverseSwapFees(reverseSwapFeesRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -844,7 +959,13 @@ class BreezSDKModule( executor.execute { try { val sendOnchainRequest = +<<<<<<< HEAD asSendOnchainRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "SendOnchainRequest")) } +======= + asSendOnchainRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "SendOnchainRequest")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().sendOnchain(sendOnchainRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -928,8 +1049,12 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD val buyBitcoinRequest = asBuyBitcoinRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "BuyBitcoinRequest")) } +======= + val buyBitcoinRequest = asBuyBitcoinRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "BuyBitcoinRequest")) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) val res = getBreezServices().buyBitcoin(buyBitcoinRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { @@ -945,10 +1070,53 @@ class BreezSDKModule( ) { executor.execute { try { +<<<<<<< HEAD val prepareRedeemOnchainFundsRequest = asPrepareRedeemOnchainFundsRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PrepareRedeemOnchainFundsRequest")) } val res = getBreezServices().prepareRedeemOnchainFunds(prepareRedeemOnchainFundsRequest) +======= + val prepareSweepRequest = + asPrepareSweepRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "PrepareSweepRequest")) + } + val res = getBreezServices().prepareSweep(prepareSweepRequest) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) + promise.resolve(readableMapOf(res)) + } catch (e: Exception) { + promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) + } + } + } + + @ReactMethod + fun createOffer( + req: ReadableMap, + promise: Promise, + ) { + executor.execute { + try { + val createOfferRequest = + asCreateOfferRequest(req) ?: run { + throw SdkException.Generic(errMissingMandatoryField("req", "CreateOfferRequest")) + } + val res = getBreezServices().createOffer(createOfferRequest) + promise.resolve(res) + } catch (e: Exception) { + promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) + } + } + } + + @ReactMethod + fun payOffer( + req: ReadableMap, + promise: Promise, + ) { + executor.execute { + try { + val payOfferRequest = asPayOfferRequest(req) ?: run { throw SdkException.Generic(errMissingMandatoryField("req", "PayOfferRequest")) } + val res = getBreezServices().payOffer(payOfferRequest) promise.resolve(readableMapOf(res)) } catch (e: Exception) { promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e) diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 5ae9ded78..17d956608 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -337,6 +337,12 @@ enum BreezSDKMapper { } static func asClosedChannelPaymentDetails(closedChannelPaymentDetails: [String: Any?]) throws -> ClosedChannelPaymentDetails { +<<<<<<< HEAD +======= + guard let shortChannelId = closedChannelPaymentDetails["shortChannelId"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "shortChannelId", typeName: "ClosedChannelPaymentDetails")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) guard let stateTmp = closedChannelPaymentDetails["state"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "state", typeName: "ClosedChannelPaymentDetails")) } @@ -345,6 +351,7 @@ enum BreezSDKMapper { guard let fundingTxid = closedChannelPaymentDetails["fundingTxid"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "fundingTxid", typeName: "ClosedChannelPaymentDetails")) } +<<<<<<< HEAD var shortChannelId: String? if hasNonNilKey(data: closedChannelPaymentDetails, key: "shortChannelId") { guard let shortChannelIdTmp = closedChannelPaymentDetails["shortChannelId"] as? String else { @@ -352,6 +359,8 @@ enum BreezSDKMapper { } shortChannelId = shortChannelIdTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var closingTxid: String? if hasNonNilKey(data: closedChannelPaymentDetails, key: "closingTxid") { guard let closingTxidTmp = closedChannelPaymentDetails["closingTxid"] as? String else { @@ -398,6 +407,7 @@ enum BreezSDKMapper { guard let breezserver = config["breezserver"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "breezserver", typeName: "Config")) } +<<<<<<< HEAD guard let chainnotifierUrl = config["chainnotifierUrl"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "chainnotifierUrl", typeName: "Config")) } @@ -407,6 +417,10 @@ enum BreezSDKMapper { throw SdkError.Generic(message: errUnexpectedValue(fieldName: "mempoolspaceUrl")) } mempoolspaceUrl = mempoolspaceUrlTmp +======= + guard let mempoolspaceUrl = config["mempoolspaceUrl"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "mempoolspaceUrl", typeName: "Config")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } guard let workingDir = config["workingDir"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "workingDir", typeName: "Config")) @@ -492,6 +506,7 @@ enum BreezSDKMapper { return configList.map { v -> [String: Any?] in dictionaryOf(config: v) } } +<<<<<<< HEAD static func asConfigureNodeRequest(configureNodeRequest: [String: Any?]) throws -> ConfigureNodeRequest { var closeToAddress: String? if hasNonNilKey(data: configureNodeRequest, key: "closeToAddress") { @@ -568,13 +583,62 @@ enum BreezSDKMapper { list.append(connectRequest) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "ConnectRequest")) +======= + static func asCreateOfferRequest(createOfferRequest: [String: Any?]) throws -> CreateOfferRequest { + var amountMsat: UInt64? + if hasNonNilKey(data: createOfferRequest, key: "amountMsat") { + guard let amountMsatTmp = createOfferRequest["amountMsat"] as? UInt64 else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "amountMsat")) + } + amountMsat = amountMsatTmp + } + guard let description = createOfferRequest["description"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "description", typeName: "CreateOfferRequest")) + } + var absoluteExpiry: UInt64? + if hasNonNilKey(data: createOfferRequest, key: "absoluteExpiry") { + guard let absoluteExpiryTmp = createOfferRequest["absoluteExpiry"] as? UInt64 else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "absoluteExpiry")) + } + absoluteExpiry = absoluteExpiryTmp + } + + return CreateOfferRequest( + amountMsat: amountMsat, + description: description, + absoluteExpiry: absoluteExpiry + ) + } + + static func dictionaryOf(createOfferRequest: CreateOfferRequest) -> [String: Any?] { + return [ + "amountMsat": createOfferRequest.amountMsat == nil ? nil : createOfferRequest.amountMsat, + "description": createOfferRequest.description, + "absoluteExpiry": createOfferRequest.absoluteExpiry == nil ? nil : createOfferRequest.absoluteExpiry, + ] + } + + static func asCreateOfferRequestList(arr: [Any]) throws -> [CreateOfferRequest] { + var list = [CreateOfferRequest]() + for value in arr { + if let val = value as? [String: Any?] { + var createOfferRequest = try asCreateOfferRequest(createOfferRequest: val) + list.append(createOfferRequest) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "CreateOfferRequest")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list } +<<<<<<< HEAD static func arrayOf(connectRequestList: [ConnectRequest]) -> [Any] { return connectRequestList.map { v -> [String: Any?] in dictionaryOf(connectRequest: v) } +======= + static func arrayOf(createOfferRequestList: [CreateOfferRequest]) -> [Any] { + return createOfferRequestList.map { v -> [String: Any?] in dictionaryOf(createOfferRequest: v) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } static func asCurrencyInfo(currencyInfo: [String: Any?]) throws -> CurrencyInfo { @@ -691,11 +755,19 @@ enum BreezSDKMapper { } static func asGreenlightCredentials(greenlightCredentials: [String: Any?]) throws -> GreenlightCredentials { +<<<<<<< HEAD guard let developerKey = greenlightCredentials["developerKey"] as? [UInt8] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "developerKey", typeName: "GreenlightCredentials")) } guard let developerCert = greenlightCredentials["developerCert"] as? [UInt8] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "developerCert", typeName: "GreenlightCredentials")) +======= + guard let deviceKey = greenlightCredentials["deviceKey"] as? [UInt8] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "deviceKey", typeName: "GreenlightCredentials")) + } + guard let deviceCert = greenlightCredentials["deviceCert"] as? [UInt8] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "deviceCert", typeName: "GreenlightCredentials")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } return GreenlightCredentials( @@ -811,10 +883,13 @@ enum BreezSDKMapper { guard let bolt11 = invoicePaidDetails["bolt11"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt11", typeName: "InvoicePaidDetails")) } +<<<<<<< HEAD var payment: Payment? if let paymentTmp = invoicePaidDetails["payment"] as? [String: Any?] { payment = try asPayment(payment: paymentTmp) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return InvoicePaidDetails( paymentHash: paymentHash, @@ -852,11 +927,14 @@ enum BreezSDKMapper { guard let bolt11 = lnInvoice["bolt11"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt11", typeName: "LnInvoice")) } +<<<<<<< HEAD guard let networkTmp = lnInvoice["network"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "network", typeName: "LnInvoice")) } let network = try asNetwork(network: networkTmp) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) guard let payeePubkey = lnInvoice["payeePubkey"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payeePubkey", typeName: "LnInvoice")) } @@ -898,9 +976,12 @@ enum BreezSDKMapper { guard let paymentSecret = lnInvoice["paymentSecret"] as? [UInt8] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "paymentSecret", typeName: "LnInvoice")) } +<<<<<<< HEAD guard let minFinalCltvExpiryDelta = lnInvoice["minFinalCltvExpiryDelta"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "minFinalCltvExpiryDelta", typeName: "LnInvoice")) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return LnInvoice( bolt11: bolt11, @@ -952,17 +1033,93 @@ enum BreezSDKMapper { return lnInvoiceList.map { v -> [String: Any?] in dictionaryOf(lnInvoice: v) } } + static func asLnOffer(lnOffer: [String: Any?]) throws -> LnOffer { + guard let bolt12 = lnOffer["bolt12"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt12", typeName: "LnOffer")) + } + guard let chains = lnOffer["chains"] as? [String] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "chains", typeName: "LnOffer")) + } + guard let description = lnOffer["description"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "description", typeName: "LnOffer")) + } + guard let signingPubkey = lnOffer["signingPubkey"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "signingPubkey", typeName: "LnOffer")) + } + var amount: Amount? + if let amountTmp = lnOffer["amount"] as? [String: Any?] { + amount = try asAmount(amount: amountTmp) + } + + var absoluteExpiry: UInt64? + if hasNonNilKey(data: lnOffer, key: "absoluteExpiry") { + guard let absoluteExpiryTmp = lnOffer["absoluteExpiry"] as? UInt64 else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "absoluteExpiry")) + } + absoluteExpiry = absoluteExpiryTmp + } + var issuer: String? + if hasNonNilKey(data: lnOffer, key: "issuer") { + guard let issuerTmp = lnOffer["issuer"] as? String else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "issuer")) + } + issuer = issuerTmp + } + + return LnOffer( + bolt12: bolt12, + chains: chains, + description: description, + signingPubkey: signingPubkey, + amount: amount, + absoluteExpiry: absoluteExpiry, + issuer: issuer + ) + } + + static func dictionaryOf(lnOffer: LnOffer) -> [String: Any?] { + return [ + "bolt12": lnOffer.bolt12, + "chains": lnOffer.chains, + "description": lnOffer.description, + "signingPubkey": lnOffer.signingPubkey, + "amount": lnOffer.amount == nil ? nil : dictionaryOf(amount: lnOffer.amount!), + "absoluteExpiry": lnOffer.absoluteExpiry == nil ? nil : lnOffer.absoluteExpiry, + "issuer": lnOffer.issuer == nil ? nil : lnOffer.issuer, + ] + } + + static func asLnOfferList(arr: [Any]) throws -> [LnOffer] { + var list = [LnOffer]() + for value in arr { + if let val = value as? [String: Any?] { + var lnOffer = try asLnOffer(lnOffer: val) + list.append(lnOffer) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "LnOffer")) + } + } + return list + } + + static func arrayOf(lnOfferList: [LnOffer]) -> [Any] { + return lnOfferList.map { v -> [String: Any?] in dictionaryOf(lnOffer: v) } + } + static func asListPaymentsRequest(listPaymentsRequest: [String: Any?]) throws -> ListPaymentsRequest { var filters: [PaymentTypeFilter]? if let filtersTmp = listPaymentsRequest["filters"] as? [String] { filters = try asPaymentTypeFilterList(arr: filtersTmp) } +<<<<<<< HEAD var metadataFilters: [MetadataFilter]? if let metadataFiltersTmp = listPaymentsRequest["metadataFilters"] as? [[String: Any?]] { metadataFilters = try asMetadataFilterList(arr: metadataFiltersTmp) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var fromTimestamp: Int64? if hasNonNilKey(data: listPaymentsRequest, key: "fromTimestamp") { guard let fromTimestampTmp = listPaymentsRequest["fromTimestamp"] as? Int64 else { @@ -1058,6 +1215,7 @@ enum BreezSDKMapper { guard let bolt11 = lnPaymentDetails["bolt11"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt11", typeName: "LnPaymentDetails")) } +<<<<<<< HEAD var openChannelBolt11: String? if hasNonNilKey(data: lnPaymentDetails, key: "openChannelBolt11") { guard let openChannelBolt11Tmp = lnPaymentDetails["openChannelBolt11"] as? String else { @@ -1065,11 +1223,14 @@ enum BreezSDKMapper { } openChannelBolt11 = openChannelBolt11Tmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var lnurlSuccessAction: SuccessActionProcessed? if let lnurlSuccessActionTmp = lnPaymentDetails["lnurlSuccessAction"] as? [String: Any?] { lnurlSuccessAction = try asSuccessActionProcessed(successActionProcessed: lnurlSuccessActionTmp) } +<<<<<<< HEAD var lnurlPayDomain: String? if hasNonNilKey(data: lnPaymentDetails, key: "lnurlPayDomain") { guard let lnurlPayDomainTmp = lnPaymentDetails["lnurlPayDomain"] as? String else { @@ -1084,6 +1245,8 @@ enum BreezSDKMapper { } lnurlPayComment = lnurlPayCommentTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var lnurlMetadata: String? if hasNonNilKey(data: lnPaymentDetails, key: "lnurlMetadata") { guard let lnurlMetadataTmp = lnPaymentDetails["lnurlMetadata"] as? String else { @@ -1105,6 +1268,7 @@ enum BreezSDKMapper { } lnurlWithdrawEndpoint = lnurlWithdrawEndpointTmp } +<<<<<<< HEAD var swapInfo: SwapInfo? if let swapInfoTmp = lnPaymentDetails["swapInfo"] as? [String: Any?] { swapInfo = try asSwapInfo(swapInfo: swapInfoTmp) @@ -1122,6 +1286,8 @@ enum BreezSDKMapper { } pendingExpirationBlock = pendingExpirationBlockTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return LnPaymentDetails( paymentHash: paymentHash, @@ -1185,12 +1351,15 @@ enum BreezSDKMapper { guard let k1 = lnUrlAuthRequestData["k1"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "k1", typeName: "LnUrlAuthRequestData")) } +<<<<<<< HEAD guard let domain = lnUrlAuthRequestData["domain"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "domain", typeName: "LnUrlAuthRequestData")) } guard let url = lnUrlAuthRequestData["url"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "url", typeName: "LnUrlAuthRequestData")) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var action: String? if hasNonNilKey(data: lnUrlAuthRequestData, key: "action") { guard let actionTmp = lnUrlAuthRequestData["action"] as? String else { @@ -1198,6 +1367,15 @@ enum BreezSDKMapper { } action = actionTmp } +<<<<<<< HEAD +======= + guard let domain = lnUrlAuthRequestData["domain"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "domain", typeName: "LnUrlAuthRequestData")) + } + guard let url = lnUrlAuthRequestData["url"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "url", typeName: "LnUrlAuthRequestData")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return LnUrlAuthRequestData( k1: k1, @@ -1319,6 +1497,7 @@ enum BreezSDKMapper { } comment = commentTmp } +<<<<<<< HEAD var paymentLabel: String? if hasNonNilKey(data: lnUrlPayRequest, key: "paymentLabel") { guard let paymentLabelTmp = lnUrlPayRequest["paymentLabel"] as? String else { @@ -1326,6 +1505,8 @@ enum BreezSDKMapper { } paymentLabel = paymentLabelTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return LnUrlPayRequest( data: data, @@ -1380,6 +1561,7 @@ enum BreezSDKMapper { guard let domain = lnUrlPayRequestData["domain"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "domain", typeName: "LnUrlPayRequestData")) } +<<<<<<< HEAD guard let allowsNostr = lnUrlPayRequestData["allowsNostr"] as? Bool else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "allowsNostr", typeName: "LnUrlPayRequestData")) } @@ -1390,6 +1572,8 @@ enum BreezSDKMapper { } nostrPubkey = nostrPubkeyTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var lnAddress: String? if hasNonNilKey(data: lnUrlPayRequestData, key: "lnAddress") { guard let lnAddressTmp = lnUrlPayRequestData["lnAddress"] as? String else { @@ -1448,10 +1632,16 @@ enum BreezSDKMapper { successAction = try asSuccessActionProcessed(successActionProcessed: successActionTmp) } +<<<<<<< HEAD guard let paymentTmp = lnUrlPaySuccessData["payment"] as? [String: Any?] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "payment", typeName: "LnUrlPaySuccessData")) } let payment = try asPayment(payment: paymentTmp) +======= + guard let paymentHash = lnUrlPaySuccessData["paymentHash"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "paymentHash", typeName: "LnUrlPaySuccessData")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return LnUrlPaySuccessData( successAction: successAction, @@ -1758,6 +1948,15 @@ enum BreezSDKMapper { guard let host = lspInformation["host"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "host", typeName: "LspInformation")) } +<<<<<<< HEAD +======= + guard let channelCapacity = lspInformation["channelCapacity"] as? Int64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "channelCapacity", typeName: "LspInformation")) + } + guard let targetConf = lspInformation["targetConf"] as? Int32 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "targetConf", typeName: "LspInformation")) + } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) guard let baseFeeMsat = lspInformation["baseFeeMsat"] as? Int64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "baseFeeMsat", typeName: "LspInformation")) } @@ -1979,9 +2178,12 @@ enum BreezSDKMapper { guard let onchainBalanceMsat = nodeState["onchainBalanceMsat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "onchainBalanceMsat", typeName: "NodeState")) } +<<<<<<< HEAD guard let pendingOnchainBalanceMsat = nodeState["pendingOnchainBalanceMsat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "pendingOnchainBalanceMsat", typeName: "NodeState")) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) guard let utxosTmp = nodeState["utxos"] as? [[String: Any?]] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "utxos", typeName: "NodeState")) } @@ -2095,12 +2297,17 @@ enum BreezSDKMapper { } static func asOpenChannelFeeRequest(openChannelFeeRequest: [String: Any?]) throws -> OpenChannelFeeRequest { +<<<<<<< HEAD var amountMsat: UInt64? if hasNonNilKey(data: openChannelFeeRequest, key: "amountMsat") { guard let amountMsatTmp = openChannelFeeRequest["amountMsat"] as? UInt64 else { throw SdkError.Generic(message: errUnexpectedValue(fieldName: "amountMsat")) } amountMsat = amountMsatTmp +======= + guard let amountMsat = openChannelFeeRequest["amountMsat"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountMsat", typeName: "OpenChannelFeeRequest")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } var expiry: UInt32? if hasNonNilKey(data: openChannelFeeRequest, key: "expiry") { @@ -2141,12 +2348,21 @@ enum BreezSDKMapper { } static func asOpenChannelFeeResponse(openChannelFeeResponse: [String: Any?]) throws -> OpenChannelFeeResponse { +<<<<<<< HEAD var feeMsat: UInt64? if hasNonNilKey(data: openChannelFeeResponse, key: "feeMsat") { guard let feeMsatTmp = openChannelFeeResponse["feeMsat"] as? UInt64 else { throw SdkError.Generic(message: errUnexpectedValue(fieldName: "feeMsat")) } feeMsat = feeMsatTmp +======= + guard let feeMsat = openChannelFeeResponse["feeMsat"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feeMsat", typeName: "OpenChannelFeeResponse")) + } + var usedFeeParams: OpeningFeeParams? + if let usedFeeParamsTmp = openChannelFeeResponse["usedFeeParams"] as? [String: Any?] { + usedFeeParams = try asOpeningFeeParams(openingFeeParams: usedFeeParamsTmp) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } guard let feeParamsTmp = openChannelFeeResponse["feeParams"] as? [String: Any?] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feeParams", typeName: "OpenChannelFeeResponse")) @@ -2274,6 +2490,7 @@ enum BreezSDKMapper { return openingFeeParamsMenuList.map { v -> [String: Any?] in dictionaryOf(openingFeeParamsMenu: v) } } +<<<<<<< HEAD static func asPayOnchainRequest(payOnchainRequest: [String: Any?]) throws -> PayOnchainRequest { guard let recipientAddress = payOnchainRequest["recipientAddress"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "recipientAddress", typeName: "PayOnchainRequest")) @@ -2304,11 +2521,65 @@ enum BreezSDKMapper { list.append(payOnchainRequest) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "PayOnchainRequest")) +======= + static func asPayOfferRequest(payOfferRequest: [String: Any?]) throws -> PayOfferRequest { + guard let offer = payOfferRequest["offer"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "offer", typeName: "PayOfferRequest")) + } + var amountMsat: UInt64? + if hasNonNilKey(data: payOfferRequest, key: "amountMsat") { + guard let amountMsatTmp = payOfferRequest["amountMsat"] as? UInt64 else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "amountMsat")) + } + amountMsat = amountMsatTmp + } + var timeout: Double? + if hasNonNilKey(data: payOfferRequest, key: "timeout") { + guard let timeoutTmp = payOfferRequest["timeout"] as? Double else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "timeout")) + } + timeout = timeoutTmp + } + var payerNote: String? + if hasNonNilKey(data: payOfferRequest, key: "payerNote") { + guard let payerNoteTmp = payOfferRequest["payerNote"] as? String else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "payerNote")) + } + payerNote = payerNoteTmp + } + + return PayOfferRequest( + offer: offer, + amountMsat: amountMsat, + timeout: timeout, + payerNote: payerNote + ) + } + + static func dictionaryOf(payOfferRequest: PayOfferRequest) -> [String: Any?] { + return [ + "offer": payOfferRequest.offer, + "amountMsat": payOfferRequest.amountMsat == nil ? nil : payOfferRequest.amountMsat, + "timeout": payOfferRequest.timeout == nil ? nil : payOfferRequest.timeout, + "payerNote": payOfferRequest.payerNote == nil ? nil : payOfferRequest.payerNote, + ] + } + + static func asPayOfferRequestList(arr: [Any]) throws -> [PayOfferRequest] { + var list = [PayOfferRequest]() + for value in arr { + if let val = value as? [String: Any?] { + var payOfferRequest = try asPayOfferRequest(payOfferRequest: val) + list.append(payOfferRequest) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "PayOfferRequest")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list } +<<<<<<< HEAD static func arrayOf(payOnchainRequestList: [PayOnchainRequest]) -> [Any] { return payOnchainRequestList.map { v -> [String: Any?] in dictionaryOf(payOnchainRequest: v) } } @@ -2344,6 +2615,10 @@ enum BreezSDKMapper { static func arrayOf(payOnchainResponseList: [PayOnchainResponse]) -> [Any] { return payOnchainResponseList.map { v -> [String: Any?] in dictionaryOf(payOnchainResponse: v) } +======= + static func arrayOf(payOfferRequestList: [PayOfferRequest]) -> [Any] { + return payOfferRequestList.map { v -> [String: Any?] in dictionaryOf(payOfferRequest: v) } +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } static func asPayment(payment: [String: Any?]) throws -> Payment { @@ -2369,6 +2644,7 @@ enum BreezSDKMapper { } let status = try asPaymentStatus(paymentStatus: statusTmp) +<<<<<<< HEAD var error: String? if hasNonNilKey(data: payment, key: "error") { guard let errorTmp = payment["error"] as? String else { @@ -2376,6 +2652,8 @@ enum BreezSDKMapper { } error = errorTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var description: String? if hasNonNilKey(data: payment, key: "description") { guard let descriptionTmp = payment["description"] as? String else { @@ -2761,6 +3039,85 @@ enum BreezSDKMapper { return prepareRefundResponseList.map { v -> [String: Any?] in dictionaryOf(prepareRefundResponse: v) } } +<<<<<<< HEAD +======= + static func asPrepareSweepRequest(prepareSweepRequest: [String: Any?]) throws -> PrepareSweepRequest { + guard let toAddress = prepareSweepRequest["toAddress"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "toAddress", typeName: "PrepareSweepRequest")) + } + guard let satsPerVbyte = prepareSweepRequest["satsPerVbyte"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "satsPerVbyte", typeName: "PrepareSweepRequest")) + } + + return PrepareSweepRequest( + toAddress: toAddress, + satsPerVbyte: satsPerVbyte + ) + } + + static func dictionaryOf(prepareSweepRequest: PrepareSweepRequest) -> [String: Any?] { + return [ + "toAddress": prepareSweepRequest.toAddress, + "satsPerVbyte": prepareSweepRequest.satsPerVbyte, + ] + } + + static func asPrepareSweepRequestList(arr: [Any]) throws -> [PrepareSweepRequest] { + var list = [PrepareSweepRequest]() + for value in arr { + if let val = value as? [String: Any?] { + var prepareSweepRequest = try asPrepareSweepRequest(prepareSweepRequest: val) + list.append(prepareSweepRequest) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareSweepRequest")) + } + } + return list + } + + static func arrayOf(prepareSweepRequestList: [PrepareSweepRequest]) -> [Any] { + return prepareSweepRequestList.map { v -> [String: Any?] in dictionaryOf(prepareSweepRequest: v) } + } + + static func asPrepareSweepResponse(prepareSweepResponse: [String: Any?]) throws -> PrepareSweepResponse { + guard let sweepTxWeight = prepareSweepResponse["sweepTxWeight"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "sweepTxWeight", typeName: "PrepareSweepResponse")) + } + guard let sweepTxFeeSat = prepareSweepResponse["sweepTxFeeSat"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "sweepTxFeeSat", typeName: "PrepareSweepResponse")) + } + + return PrepareSweepResponse( + sweepTxWeight: sweepTxWeight, + sweepTxFeeSat: sweepTxFeeSat + ) + } + + static func dictionaryOf(prepareSweepResponse: PrepareSweepResponse) -> [String: Any?] { + return [ + "sweepTxWeight": prepareSweepResponse.sweepTxWeight, + "sweepTxFeeSat": prepareSweepResponse.sweepTxFeeSat, + ] + } + + static func asPrepareSweepResponseList(arr: [Any]) throws -> [PrepareSweepResponse] { + var list = [PrepareSweepResponse]() + for value in arr { + if let val = value as? [String: Any?] { + var prepareSweepResponse = try asPrepareSweepResponse(prepareSweepResponse: val) + list.append(prepareSweepResponse) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "PrepareSweepResponse")) + } + } + return list + } + + static func arrayOf(prepareSweepResponseList: [PrepareSweepResponse]) -> [Any] { + return prepareSweepResponseList.map { v -> [String: Any?] in dictionaryOf(prepareSweepResponse: v) } + } + +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) static func asRate(rate: [String: Any?]) throws -> Rate { guard let coin = rate["coin"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "coin", typeName: "Rate")) @@ -3212,6 +3569,7 @@ enum BreezSDKMapper { } sendAmountSat = sendAmountSatTmp } +<<<<<<< HEAD var claimTxFeerate: UInt32? if hasNonNilKey(data: reverseSwapFeesRequest, key: "claimTxFeerate") { guard let claimTxFeerateTmp = reverseSwapFeesRequest["claimTxFeerate"] as? UInt32 else { @@ -3219,6 +3577,8 @@ enum BreezSDKMapper { } claimTxFeerate = claimTxFeerateTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return ReverseSwapFeesRequest( sendAmountSat: sendAmountSat, @@ -3336,12 +3696,21 @@ enum BreezSDKMapper { guard let feesClaim = reverseSwapPairInfo["feesClaim"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feesClaim", typeName: "ReverseSwapPairInfo")) } +<<<<<<< HEAD var totalFees: UInt64? if hasNonNilKey(data: reverseSwapPairInfo, key: "totalFees") { guard let totalFeesTmp = reverseSwapPairInfo["totalFees"] as? UInt64 else { throw SdkError.Generic(message: errUnexpectedValue(fieldName: "totalFees")) } totalFees = totalFeesTmp +======= + var totalEstimatedFees: UInt64? + if hasNonNilKey(data: reverseSwapPairInfo, key: "totalEstimatedFees") { + guard let totalEstimatedFeesTmp = reverseSwapPairInfo["totalEstimatedFees"] as? UInt64 else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "totalEstimatedFees")) + } + totalEstimatedFees = totalEstimatedFeesTmp +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } return ReverseSwapPairInfo( @@ -3570,8 +3939,13 @@ enum BreezSDKMapper { } static func asSendPaymentRequest(sendPaymentRequest: [String: Any?]) throws -> SendPaymentRequest { +<<<<<<< HEAD guard let bolt11 = sendPaymentRequest["bolt11"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "bolt11", typeName: "SendPaymentRequest")) +======= + guard let invoice = sendPaymentRequest["invoice"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "invoice", typeName: "SendPaymentRequest")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } var amountMsat: UInt64? if hasNonNilKey(data: sendPaymentRequest, key: "amountMsat") { @@ -3580,6 +3954,7 @@ enum BreezSDKMapper { } amountMsat = amountMsatTmp } +<<<<<<< HEAD var label: String? if hasNonNilKey(data: sendPaymentRequest, key: "label") { guard let labelTmp = sendPaymentRequest["label"] as? String else { @@ -3592,12 +3967,18 @@ enum BreezSDKMapper { bolt11: bolt11, amountMsat: amountMsat, label: label +======= + + return SendPaymentRequest( + invoice: invoice, + amountMsat: amountMsat +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) ) } static func dictionaryOf(sendPaymentRequest: SendPaymentRequest) -> [String: Any?] { return [ - "bolt11": sendPaymentRequest.bolt11, + "invoice": sendPaymentRequest.invoice, "amountMsat": sendPaymentRequest.amountMsat == nil ? nil : sendPaymentRequest.amountMsat, "label": sendPaymentRequest.label == nil ? nil : sendPaymentRequest.label, ] @@ -3660,6 +4041,7 @@ enum BreezSDKMapper { guard let amountMsat = sendSpontaneousPaymentRequest["amountMsat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountMsat", typeName: "SendSpontaneousPaymentRequest")) } +<<<<<<< HEAD var extraTlvs: [TlvEntry]? if let extraTlvsTmp = sendSpontaneousPaymentRequest["extraTlvs"] as? [[String: Any?]] { extraTlvs = try asTlvEntryList(arr: extraTlvsTmp) @@ -3672,6 +4054,8 @@ enum BreezSDKMapper { } label = labelTmp } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return SendSpontaneousPaymentRequest( nodeId: nodeId, @@ -3907,8 +4291,13 @@ enum BreezSDKMapper { } bolt11 = bolt11Tmp } +<<<<<<< HEAD guard let paidMsat = swapInfo["paidMsat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "paidMsat", typeName: "SwapInfo")) +======= + guard let paidSats = swapInfo["paidSats"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "paidSats", typeName: "SwapInfo")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } guard let unconfirmedSats = swapInfo["unconfirmedSats"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "unconfirmedSats", typeName: "SwapInfo")) @@ -3916,9 +4305,12 @@ enum BreezSDKMapper { guard let confirmedSats = swapInfo["confirmedSats"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "confirmedSats", typeName: "SwapInfo")) } +<<<<<<< HEAD guard let totalIncomingTxs = swapInfo["totalIncomingTxs"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "totalIncomingTxs", typeName: "SwapInfo")) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) guard let statusTmp = swapInfo["status"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "status", typeName: "SwapInfo")) } @@ -3939,9 +4331,12 @@ enum BreezSDKMapper { guard let maxAllowedDeposit = swapInfo["maxAllowedDeposit"] as? Int64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "maxAllowedDeposit", typeName: "SwapInfo")) } +<<<<<<< HEAD guard let maxSwapperPayable = swapInfo["maxSwapperPayable"] as? Int64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "maxSwapperPayable", typeName: "SwapInfo")) } +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) var lastRedeemError: String? if hasNonNilKey(data: swapInfo, key: "lastRedeemError") { guard let lastRedeemErrorTmp = swapInfo["lastRedeemError"] as? String else { @@ -4036,6 +4431,79 @@ enum BreezSDKMapper { return swapInfoList.map { v -> [String: Any?] in dictionaryOf(swapInfo: v) } } +<<<<<<< HEAD +======= + static func asSweepRequest(sweepRequest: [String: Any?]) throws -> SweepRequest { + guard let toAddress = sweepRequest["toAddress"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "toAddress", typeName: "SweepRequest")) + } + guard let feeRateSatsPerVbyte = sweepRequest["feeRateSatsPerVbyte"] as? UInt32 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "feeRateSatsPerVbyte", typeName: "SweepRequest")) + } + + return SweepRequest( + toAddress: toAddress, + feeRateSatsPerVbyte: feeRateSatsPerVbyte + ) + } + + static func dictionaryOf(sweepRequest: SweepRequest) -> [String: Any?] { + return [ + "toAddress": sweepRequest.toAddress, + "feeRateSatsPerVbyte": sweepRequest.feeRateSatsPerVbyte, + ] + } + + static func asSweepRequestList(arr: [Any]) throws -> [SweepRequest] { + var list = [SweepRequest]() + for value in arr { + if let val = value as? [String: Any?] { + var sweepRequest = try asSweepRequest(sweepRequest: val) + list.append(sweepRequest) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "SweepRequest")) + } + } + return list + } + + static func arrayOf(sweepRequestList: [SweepRequest]) -> [Any] { + return sweepRequestList.map { v -> [String: Any?] in dictionaryOf(sweepRequest: v) } + } + + static func asSweepResponse(sweepResponse: [String: Any?]) throws -> SweepResponse { + guard let txid = sweepResponse["txid"] as? [UInt8] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "txid", typeName: "SweepResponse")) + } + + return SweepResponse( + txid: txid) + } + + static func dictionaryOf(sweepResponse: SweepResponse) -> [String: Any?] { + return [ + "txid": sweepResponse.txid, + ] + } + + static func asSweepResponseList(arr: [Any]) throws -> [SweepResponse] { + var list = [SweepResponse]() + for value in arr { + if let val = value as? [String: Any?] { + var sweepResponse = try asSweepResponse(sweepResponse: val) + list.append(sweepResponse) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "SweepResponse")) + } + } + return list + } + + static func arrayOf(sweepResponseList: [SweepResponse]) -> [Any] { + return sweepResponseList.map { v -> [String: Any?] in dictionaryOf(sweepResponse: v) } + } + +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) static func asSymbol(symbol: [String: Any?]) throws -> Symbol { var grapheme: String? if hasNonNilKey(data: symbol, key: "grapheme") { @@ -4229,6 +4697,7 @@ enum BreezSDKMapper { return urlSuccessActionDataList.map { v -> [String: Any?] in dictionaryOf(urlSuccessActionData: v) } } +<<<<<<< HEAD static func asAesSuccessActionDataResult(aesSuccessActionDataResult: [String: Any?]) throws -> AesSuccessActionDataResult { let type = aesSuccessActionDataResult["type"] as! String if type == "decrypted" { @@ -4265,10 +4734,48 @@ enum BreezSDKMapper { return [ "type": "errorStatus", "reason": reason, +======= + static func asAmount(amount: [String: Any?]) throws -> Amount { + let type = amount["type"] as! String + if type == "bitcoin" { + guard let _amountMsat = amount["amountMsat"] as? UInt64 else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "amountMsat", typeName: "Amount")) + } + return Amount.bitcoin(amountMsat: _amountMsat) + } + if type == "currency" { + guard let _iso4217Code = amount["iso4217Code"] as? String else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "iso4217Code", typeName: "Amount")) + } + return Amount.currency(iso4217Code: _iso4217Code) + } + + throw SdkError.Generic(message: "Unexpected type \(type) for enum Amount") + } + + static func dictionaryOf(amount: Amount) -> [String: Any?] { + switch amount { + case let .bitcoin( + amountMsat + ): + return [ + "type": "bitcoin", + "amountMsat": amountMsat, + ] + + case let .currency( + iso4217Code, fractionalAmount + ): + return [ + "type": "currency", + "iso4217Code": iso4217Code, + "fractionalAmount": fractionalAmount, +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) ] } } +<<<<<<< HEAD static func arrayOf(aesSuccessActionDataResultList: [AesSuccessActionDataResult]) -> [Any] { return aesSuccessActionDataResultList.map { v -> [String: Any?] in dictionaryOf(aesSuccessActionDataResult: v) } } @@ -4281,6 +4788,20 @@ enum BreezSDKMapper { list.append(aesSuccessActionDataResult) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "AesSuccessActionDataResult")) +======= + static func arrayOf(amountList: [Amount]) -> [Any] { + return amountList.map { v -> [String: Any?] in dictionaryOf(amount: v) } + } + + static func asAmountList(arr: [Any]) throws -> [Amount] { + var list = [Amount]() + for value in arr { + if let val = value as? [String: Any?] { + var amount = try asAmount(amount: val) + list.append(amount) + } else { + throw SdkError.Generic(message: errUnexpectedType(typeName: "Amount")) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -4594,6 +5115,7 @@ enum BreezSDKMapper { list.append(feeratePreset) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "FeeratePreset")) +<<<<<<< HEAD } } return list @@ -4639,6 +5161,8 @@ enum BreezSDKMapper { list.append(healthCheckStatus) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "HealthCheckStatus")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -4662,6 +5186,14 @@ enum BreezSDKMapper { return InputType.bolt11(invoice: _invoice) } + if type == "bolt12Offer" { + guard let offerTmp = inputType["offer"] as? [String: Any?] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "offer", typeName: "InputType")) + } + let _offer = try asLnOffer(lnOffer: offerTmp) + + return InputType.bolt12Offer(offer: _offer) + } if type == "nodeId" { guard let _nodeId = inputType["nodeId"] as? String else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "nodeId", typeName: "InputType")) @@ -4728,6 +5260,14 @@ enum BreezSDKMapper { "invoice": dictionaryOf(lnInvoice: invoice), ] + case let .bolt12Offer( + offer + ): + return [ + "type": "bolt12Offer", + "offer": dictionaryOf(lnOffer: offer), + ] + case let .nodeId( nodeId ): @@ -5085,6 +5625,7 @@ enum BreezSDKMapper { list.append(nodeConfig) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "NodeConfig")) +<<<<<<< HEAD } } return list @@ -5128,6 +5669,8 @@ enum BreezSDKMapper { list.append(nodeCredentials) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "NodeCredentials")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -5322,6 +5865,7 @@ enum BreezSDKMapper { list.append(paymentTypeFilter) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "PaymentTypeFilter")) +<<<<<<< HEAD } } return list @@ -5365,6 +5909,8 @@ enum BreezSDKMapper { list.append(reportIssueRequest) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "ReportIssueRequest")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list @@ -5430,10 +5976,17 @@ enum BreezSDKMapper { static func asSuccessActionProcessed(successActionProcessed: [String: Any?]) throws -> SuccessActionProcessed { let type = successActionProcessed["type"] as! String if type == "aes" { +<<<<<<< HEAD guard let resultTmp = successActionProcessed["result"] as? [String: Any?] else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "result", typeName: "SuccessActionProcessed")) } let _result = try asAesSuccessActionDataResult(aesSuccessActionDataResult: resultTmp) +======= + guard let dataTmp = successActionProcessed["data"] as? [String: Any?] else { + throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "data", typeName: "SuccessActionProcessed")) + } + let _data = try asAesSuccessActionDataDecrypted(aesSuccessActionDataDecrypted: dataTmp) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) return SuccessActionProcessed.aes(result: _result) } @@ -5497,6 +6050,7 @@ enum BreezSDKMapper { list.append(successActionProcessed) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "SuccessActionProcessed")) +<<<<<<< HEAD } } return list @@ -5536,6 +6090,8 @@ enum BreezSDKMapper { list.append(swapAmountType) } else { throw SdkError.Generic(message: errUnexpectedType(typeName: "SwapAmountType")) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) } } return list diff --git a/libs/sdk-react-native/ios/RNBreezSDK.m b/libs/sdk-react-native/ios/RNBreezSDK.m index 01ad19eeb..01dd0c9d8 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.m +++ b/libs/sdk-react-native/ios/RNBreezSDK.m @@ -338,4 +338,16 @@ @interface RCT_EXTERN_MODULE(RNBreezSDK, RCTEventEmitter) reject: (RCTPromiseRejectBlock)reject ) +RCT_EXTERN_METHOD( + createOffer: (NSDictionary*)req + resolve: (RCTPromiseResolveBlock)resolve + reject: (RCTPromiseRejectBlock)reject +) + +RCT_EXTERN_METHOD( + payOffer: (NSDictionary*)req + resolve: (RCTPromiseResolveBlock)resolve + reject: (RCTPromiseRejectBlock)reject +) + @end \ No newline at end of file diff --git a/libs/sdk-react-native/ios/RNBreezSDK.swift b/libs/sdk-react-native/ios/RNBreezSDK.swift index c56b381ac..b5ce3a218 100644 --- a/libs/sdk-react-native/ios/RNBreezSDK.swift +++ b/libs/sdk-react-native/ios/RNBreezSDK.swift @@ -148,10 +148,18 @@ class RNBreezSDK: RCTEventEmitter { } do { +<<<<<<< HEAD let connectRequest = try BreezSDKMapper.asConnectRequest(connectRequest: req) try ensureWorkingDir(workingDir: connectRequest.config.workingDir) breezServices = try BreezSDK.connect(req: connectRequest, listener: BreezSDKListener()) +======= + let configTmp = try BreezSDKMapper.asConfig(config: config) + + try ensureWorkingDir(workingDir: configTmp.workingDir) + + breezServices = try BreezSDK.connect(config: configTmp, seed: seed, listener: BreezSDKListener(emitter: self)) +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) resolve(["status": "ok"]) } catch let err { rejectErr(err: err, reject: reject) @@ -163,6 +171,7 @@ class RNBreezSDK: RCTEventEmitter { do { try getBreezServices().disconnect() breezServices = nil +<<<<<<< HEAD resolve(["status": "ok"]) } catch let err { rejectErr(err: err, reject: reject) @@ -174,6 +183,8 @@ class RNBreezSDK: RCTEventEmitter { do { let configureNodeRequest = try BreezSDKMapper.asConfigureNodeRequest(configureNodeRequest: req) try getBreezServices().configureNode(req: configureNodeRequest) +======= +>>>>>>> 76cb54aa (Squash and rebase Bolt12 implementation) resolve(["status": "ok"]) } catch let err { rejectErr(err: err, reject: reject) @@ -711,6 +722,28 @@ class RNBreezSDK: RCTEventEmitter { } } + @objc(createOffer:resolve:reject:) + func createOffer(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + do { + let createOfferRequest = try BreezSDKMapper.asCreateOfferRequest(createOfferRequest: req) + var res = try getBreezServices().createOffer(req: createOfferRequest) + resolve(res) + } catch let err { + rejectErr(err: err, reject: reject) + } + } + + @objc(payOffer:resolve:reject:) + func payOffer(_ req: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + do { + let payOfferRequest = try BreezSDKMapper.asPayOfferRequest(payOfferRequest: req) + var res = try getBreezServices().payOffer(req: payOfferRequest) + resolve(BreezSDKMapper.dictionaryOf(sendPaymentResponse: res)) + } catch let err { + rejectErr(err: err, reject: reject) + } + } + func rejectErr(err: Error, reject: @escaping RCTPromiseRejectBlock) { var errorName = "Generic" var message = "\(err)" diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index d36f32cf3..af13efa2b 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -663,6 +663,7 @@ export enum HealthCheckStatus { export enum InputTypeVariant { BITCOIN_ADDRESS = "bitcoinAddress", BOLT11 = "bolt11", + BOLT12_OFFER = "bolt12Offer", NODE_ID = "nodeId", URL = "url", LN_URL_PAY = "lnUrlPay", @@ -677,6 +678,9 @@ export type InputType = { } | { type: InputTypeVariant.BOLT11, invoice: LnInvoice +} | { + type: InputTypeVariant.BOLT12_OFFER, + offer: LnOffer } | { type: InputTypeVariant.NODE_ID, nodeId: string @@ -1141,3 +1145,13 @@ export const prepareRedeemOnchainFunds = async (req: PrepareRedeemOnchainFundsRe const response = await BreezSDK.prepareRedeemOnchainFunds(req) return response } + +export const createOffer = async (req: CreateOfferRequest): Promise => { + const response = await BreezSDK.createOffer(req) + return response +} + +export const payOffer = async (req: PayOfferRequest): Promise => { + const response = await BreezSDK.payOffer(req) + return response +} diff --git a/tools/sdk-cli/Cargo.lock b/tools/sdk-cli/Cargo.lock index 497ec177e..ef5670e71 100644 --- a/tools/sdk-cli/Cargo.lock +++ b/tools/sdk-cli/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -184,7 +184,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -195,7 +195,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -268,9 +268,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" [[package]] name = "cfg-if" @@ -654,7 +654,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -807,7 +807,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -818,7 +818,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -860,6 +860,16 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "difflib" version = "0.4.0" @@ -894,7 +904,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1019,7 +1029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ae6b3d9530211fb3b12a95374b8b0823be812f53d09e18c5675c0146b09642" dependencies = [ "cfg-if", - "rustix 0.37.27", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -1162,7 +1172,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1230,9 +1240,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "gl-client" @@ -1284,9 +1294,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.26" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -1294,7 +1304,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.0.0", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -1609,7 +1619,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.27", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -1716,6 +1726,15 @@ dependencies = [ "regex", ] +[[package]] +name = "lightning" +version = "0.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cec5fa9382154fe9671e8df93095b800c7d77abc66e2a5ef839d672521c5e" +dependencies = [ + "bitcoin 0.29.2", +] + [[package]] name = "lightning-invoice" version = "0.24.0" @@ -1725,7 +1744,21 @@ dependencies = [ "bech32", "bitcoin 0.29.2", "bitcoin_hashes 0.11.0", - "lightning", + "lightning 0.0.116", + "num-traits", + "secp256k1 0.24.3", +] + +[[package]] +name = "lightning-invoice" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb24878b0f4ef75f020976c886d9ad1503867802329cc963e0ab4623ea3b25c" +dependencies = [ + "bech32", + "bitcoin 0.29.2", + "bitcoin_hashes 0.11.0", + "lightning 0.0.118", "num-traits", "secp256k1 0.24.3", ] @@ -1793,9 +1826,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi", @@ -1900,6 +1933,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -1931,9 +1970,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "memchr", ] @@ -1961,9 +2000,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ "bitflags 2.4.0", "cfg-if", @@ -1982,7 +2021,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -1993,18 +2032,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.2.3+3.2.1" +version = "300.1.3+3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" +checksum = "cd2c101a165fff9935e34def4669595ab1c7847943c42be86e21503e482be107" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", @@ -2103,7 +2142,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -2147,6 +2186,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2195,9 +2240,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -2270,9 +2315,9 @@ checksum = "9318ead08c799aad12a55a3e78b82e0b6167271ffd1f627b758891282f739187" [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2492,9 +2537,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -2513,9 +2558,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.27" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags 1.3.2", "errno", @@ -2631,7 +2676,7 @@ checksum = "5a32af5427251d2e4be14fc151eabe18abb4a7aad5efee7044da9f096c906a43" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -2676,8 +2721,8 @@ dependencies = [ "bitcoin 0.29.2", "cbc", "hex", - "lightning", - "lightning-invoice", + "lightning 0.0.118", + "lightning-invoice 0.26.0", "log", "prost", "querystring", @@ -2766,9 +2811,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.163" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -2787,13 +2832,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -2821,11 +2866,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" +checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" dependencies = [ - "base64 0.21.2", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -2839,14 +2884,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.6.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" +checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -2966,7 +3011,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -2988,9 +3033,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -3044,22 +3089,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -3073,11 +3118,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.21" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -3085,16 +3133,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -3169,7 +3218,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -3330,7 +3379,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ] [[package]] @@ -3439,9 +3488,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -3456,9 +3505,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "serde", ] @@ -3477,9 +3526,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vls-core" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1210aae1bc771b5ff39372466cf94ea23130a9d3ed0bbbafb6ee4443976de945" +checksum = "7e930b25c7dd20dabbff7f564f6a33729ed59c85d759ecfe026d3723c492601b" dependencies = [ "anyhow", "backtrace", @@ -3491,8 +3540,8 @@ dependencies = [ "hashbrown 0.8.2", "hex", "itertools", - "lightning", - "lightning-invoice", + "lightning 0.0.116", + "lightning-invoice 0.24.0", "log", "scopeguard", "serde", @@ -3504,9 +3553,9 @@ dependencies = [ [[package]] name = "vls-persist" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a9de079c84145fd4df1f826970d140f1a364fbd0f68f1944d16149988a3931" +checksum = "bd59da7c08b3ec90791c4acc13a590a32b7cfef17c58f42690f1ae1cb2a39e7a" dependencies = [ "hex", "log", @@ -3519,9 +3568,9 @@ dependencies = [ [[package]] name = "vls-protocol" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01ad8baa041296e8d715fd34d052d00ee5210038cc755e0f993c8c827935a85" +checksum = "931878f2eaa91810f7cc183cd9909d6db5c967bda6b7a317aafe710a3e14d30c" dependencies = [ "as-any", "bitcoin-consensus-derive", @@ -3534,9 +3583,9 @@ dependencies = [ [[package]] name = "vls-protocol-signer" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4435ed40d9bab3350f0caa305685bc3ac95e268e9c3b3f09bc08b002fac19ba" +checksum = "bfd8e85b22aa3fd45097652a6064e85963ac66f95ce027fe9a5cc87c571ba453" dependencies = [ "bit-vec", "log", @@ -3581,7 +3630,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -3615,7 +3664,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3745,7 +3794,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -3780,18 +3829,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -3808,9 +3857,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -3826,9 +3875,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -3844,15 +3893,15 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -3868,9 +3917,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -3886,9 +3935,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -3904,9 +3953,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -3922,9 +3971,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winreg" @@ -4006,5 +4055,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.68", ]