diff --git a/apps/desktop/src/bun/lib/monero/index.ts b/apps/desktop/src/bun/lib/monero/index.ts
index 9621ea3..fe4ccae 100644
--- a/apps/desktop/src/bun/lib/monero/index.ts
+++ b/apps/desktop/src/bun/lib/monero/index.ts
@@ -16,6 +16,7 @@ export {
getFeeEstimate,
getDaemonHeight,
transfer,
+ sweepAll,
isWalletOpen,
isConnected,
listWallets,
diff --git a/apps/desktop/src/bun/lib/monero/wallet.ts b/apps/desktop/src/bun/lib/monero/wallet.ts
index 27e0f6b..f68be4f 100644
--- a/apps/desktop/src/bun/lib/monero/wallet.ts
+++ b/apps/desktop/src/bun/lib/monero/wallet.ts
@@ -423,6 +423,33 @@ export async function getDaemonHeight(
}
}
+export async function sweepAll(
+ state: MoneroWalletState,
+ address: string,
+ priority: number = 0,
+ accountIndex: number = 0,
+): Promise<{ txHash: string; fee: string; amount: string }> {
+ if (!state.wallet) throw new Error('Wallet RPC not started')
+ console.log(
+ `[monero] sweepAll: ${address} priority=${priority} account=${accountIndex}`,
+ )
+ const result = await rawRpc(state, 'sweep_all', {
+ address,
+ priority,
+ account_index: accountIndex,
+ get_tx_keys: true,
+ get_tx_hex: false,
+ get_tx_metadata: false,
+ })
+ const txHash = result.tx_hash_list?.[0] ?? ''
+ const fee = result.fee_list?.[0]?.toString() ?? '0'
+ const amount = result.amount_list?.[0]?.toString() ?? '0'
+ console.log(
+ `[monero] sweepAll result: tx_hash=${txHash} fee=${fee} amount=${amount}`,
+ )
+ return { txHash, fee, amount }
+}
+
export async function transfer(
state: MoneroWalletState,
address: string,
diff --git a/apps/desktop/src/bun/rpc/monero/index.ts b/apps/desktop/src/bun/rpc/monero/index.ts
index 655fb17..fe43338 100644
--- a/apps/desktop/src/bun/rpc/monero/index.ts
+++ b/apps/desktop/src/bun/rpc/monero/index.ts
@@ -17,6 +17,7 @@ import {
getDaemonHeight as walletGetDaemonHeight,
getFeeEstimate as walletGetFeeEstimate,
transfer as walletTransfer,
+ sweepAll as walletSweepAll,
isWalletOpen,
isConnected,
} from '../../lib/monero'
@@ -231,6 +232,30 @@ export function createMoneroHandlers(state: {
console.log('[rpc] moneroTransfer complete:', result.txHash)
return result
},
+ moneroSweepAll: async ({
+ address,
+ priority,
+ accountIndex,
+ }: {
+ address: string
+ priority?: number
+ accountIndex?: number
+ }) => {
+ console.log('[rpc] moneroSweepAll:', {
+ address,
+ priority,
+ })
+ if (!state.manager)
+ throw new Error('Monero wallet RPC not started')
+ const result = await walletSweepAll(
+ state.manager,
+ address,
+ priority ?? 0,
+ accountIndex ?? 0,
+ )
+ console.log('[rpc] moneroSweepAll complete:', result.txHash)
+ return result
+ },
moneroGetTransferDetails: async ({ txid }: { txid: string }) => {
console.log('[rpc] moneroGetTransferDetails:', txid)
if (!state.manager)
diff --git a/apps/desktop/src/lib/rpc-schema.ts b/apps/desktop/src/lib/rpc-schema.ts
index e1bec27..8b56554 100644
--- a/apps/desktop/src/lib/rpc-schema.ts
+++ b/apps/desktop/src/lib/rpc-schema.ts
@@ -179,6 +179,7 @@ export type MoneroRpcRequests = {
moneroGetAccounts: { params: {}; response: MoneroAccountEntry[] }
moneroListWallets: { params: {}; response: string[] }
moneroTransfer: { params: { address: string; amount: string; priority?: number; accountIndex?: number }; response: MoneroSendResult }
+ moneroSweepAll: { params: { address: string; priority?: number; accountIndex?: number }; response: MoneroSendResult }
moneroGetTransferDetails: { params: { txid: string }; response: MoneroTransferDetails | null }
moneroGetFeeEstimate: { params: {}; response: MoneroFeeEstimate | null }
}
diff --git a/apps/desktop/src/lib/states/monero-wallet.svelte.ts b/apps/desktop/src/lib/states/monero-wallet.svelte.ts
index 62a1bae..004c14f 100644
--- a/apps/desktop/src/lib/states/monero-wallet.svelte.ts
+++ b/apps/desktop/src/lib/states/monero-wallet.svelte.ts
@@ -293,6 +293,21 @@ export const MoneroWallet = () => {
return result
}
+ const sendAll = async (
+ address: string,
+ priority?: number,
+ accountIndex?: number,
+ ): Promise
@@ -490,6 +502,11 @@ class="font-mono text-muted-foreground/50 truncate mt-0.5"> {sub.address}
+Amount exceeds unlocked balance