diff --git a/android/app/build.gradle b/android/app/build.gradle index 8d7a242a..ab8207b9 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.mutinywallet.mutinywallet" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 66 - versionName "1.7.5" + versionCode 68 + versionName "1.7.7" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 4b7f0a6e..7e3c7eb3 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.7.5; + MARKETING_VERSION = 1.7.7; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = "com.mutinywallet.mutiny-test"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -387,7 +387,7 @@ INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.7.5; + MARKETING_VERSION = 1.7.7; PRODUCT_BUNDLE_IDENTIFIER = com.mutinywallet.mutiny; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/package.json b/package.json index eb998fbc..3fac559d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mutiny-wallet", - "version": "1.7.5", + "version": "1.7.7", "license": "MIT", "packageManager": "pnpm@8.6.6", "scripts": { @@ -56,7 +56,7 @@ "@kobalte/core": "^0.12.6", "@kobalte/tailwindcss": "^0.9.0", "@modular-forms/solid": "^0.20.0", - "@mutinywallet/mutiny-wasm": "1.7.5", + "@mutinywallet/mutiny-wasm": "1.7.7", "@sentry/browser": "^8.7.0", "@sentry/vite-plugin": "^2.18.0", "@solid-primitives/upload": "^0.0.117", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 467cda9c..418fd370 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,8 +54,8 @@ dependencies: specifier: ^0.20.0 version: 0.20.0(solid-js@1.8.16) '@mutinywallet/mutiny-wasm': - specifier: 1.7.5 - version: 1.7.5 + specifier: 1.7.7 + version: 1.7.7 '@sentry/browser': specifier: ^8.7.0 version: 8.7.0 @@ -2177,8 +2177,8 @@ packages: solid-js: 1.8.16 dev: false - /@mutinywallet/mutiny-wasm@1.7.5: - resolution: {integrity: sha512-jMmqbYQfN35u7CWMMUiNKD+bUk8bp6FZKRMLekJHgv0M6hm8heZGxL0YQNWEA0c9rHajxi3O8FFIIO2vowXUmw==} + /@mutinywallet/mutiny-wasm@1.7.7: + resolution: {integrity: sha512-ybJCshjedZGDzSQl4TMDiFDiB4Kq3caqAuwQh3/E9djgSYOHwwiR2lcE8DJ6Vll+eFWxjEzHRPSrBGmwhUPWHQ==} dev: false /@nodelib/fs.scandir@2.1.5: diff --git a/src/routes/SwapLightning.tsx b/src/routes/SwapLightning.tsx index 5fb94aca..ef0df62a 100644 --- a/src/routes/SwapLightning.tsx +++ b/src/routes/SwapLightning.tsx @@ -47,6 +47,7 @@ export function SwapLightning() { ); const [amountSats, setAmountSats] = createSignal(0n); + const [invoice, setInvoice] = createSignal(""); const [feeSats, setFeeSats] = createSignal(0n); const [maxFederationBalanceBeforeSwap, setMaxFederationBalanceBeforeSwap] = createSignal(0n); @@ -69,15 +70,11 @@ export function SwapLightning() { setLoading(true); setFeeEstimateWarning(undefined); - if (isMax()) { - const result = await sw.sweep_federation_balance(undefined); - - setSweepResult({ result: result }); - } else { - const result = await sw.sweep_federation_balance(amountSats()); - - setSweepResult({ result: result }); - } + const result = await sw.sweep_federation_balance_to_invoice( + undefined, + invoice() + ); + setSweepResult({ result: result }); await vibrateSuccess(); } catch (e) { @@ -129,12 +126,20 @@ export function SwapLightning() { setLoading(true); setFeeEstimateWarning(undefined); - const fee = await sw.estimate_sweep_federation_fee( + const mutinyInvoice = await sw.create_sweep_federation_invoice( isMax() ? undefined : amountSats() ); - if (fee) { - setFeeSats(fee); + if (mutinyInvoice.bolt11) { + setInvoice(mutinyInvoice.bolt11); + } else { + console.error("No invoice created"); + // this should never happen + throw new Error("No invoice created"); + } + + if (mutinyInvoice.fees_paid) { + setFeeSats(mutinyInvoice.fees_paid); } setMaxFederationBalanceBeforeSwap(calculateMaxFederation()); diff --git a/src/routes/Transfer.tsx b/src/routes/Transfer.tsx index 66fda217..9f861303 100644 --- a/src/routes/Transfer.tsx +++ b/src/routes/Transfer.tsx @@ -85,24 +85,24 @@ export function Transfer() { if (!fromFed()) throw new Error("No from federation"); if (!toFed()) throw new Error("No to federation"); - if (isMax()) { - const result = await sw.sweep_federation_balance( - undefined, - fromFed()?.federation_id, - toFed()?.federation_id - ); - - setTransferResult({ result: result }); - } else { - const result = await sw.sweep_federation_balance( - amountSats(), - fromFed()?.federation_id, - toFed()?.federation_id - ); - - setTransferResult({ result: result }); + const mutinyInvoice = await sw.create_sweep_federation_invoice( + isMax() ? undefined : amountSats(), + fromFed()?.federation_id, + toFed()?.federation_id + ); + + if (!mutinyInvoice.bolt11) { + // this should never happen + throw new Error("No invoice created"); } + const result = await sw.sweep_federation_balance_to_invoice( + fromFed()?.federation_id, + mutinyInvoice.bolt11 + ); + + setTransferResult({ result: result }); + await vibrateSuccess(); } catch (e) { const error = eify(e); diff --git a/src/workers/walletWorker.ts b/src/workers/walletWorker.ts index 7ebf584a..06cddc05 100644 --- a/src/workers/walletWorker.ts +++ b/src/workers/walletWorker.ts @@ -1588,18 +1588,17 @@ export async function estimate_sweep_channel_open_fee( /** * Sweep the federation balance into a lightning channel - * @param {bigint | undefined} [amount] + * @param {string | undefined} [from_federation_id] + * @param {string} [invoice] * @returns {Promise} */ -export async function sweep_federation_balance( - amount?: bigint, - from_federation_id?: string, - to_federation_id?: string +export async function sweep_federation_balance_to_invoice( + from_federation_id: string | undefined, + invoice: string ): Promise { - const result = await wallet!.sweep_federation_balance( - amount, + const result = await wallet!.sweep_federation_balance_to_invoice( from_federation_id, - to_federation_id + invoice ); return { ...result.value } as FedimintSweepResult; } @@ -1607,12 +1606,21 @@ export async function sweep_federation_balance( /** * Estimate the fee before trying to sweep from federation * @param {bigint | undefined} [amount] - * @returns {Promise} + * @param {string | undefined} [from_federation_id] + * @param {string | undefined} [to_federation_id] + * @returns {Promise} */ -export async function estimate_sweep_federation_fee( - amount?: bigint -): Promise { - return await wallet!.estimate_sweep_federation_fee(amount); +export async function create_sweep_federation_invoice( + amount?: bigint, + from_federation_id?: string, + to_federation_id?: string +): Promise { + const invoice = await wallet!.create_sweep_federation_invoice( + amount, + from_federation_id, + to_federation_id + ); + return destructureInvoice(invoice); } export async function parse_params(params: string): Promise {