From 8ba4d467679abf87cbdd8cf01f9307a5fe5c2b08 Mon Sep 17 00:00:00 2001 From: padreug Date: Sun, 14 Sep 2025 17:59:17 +0200 Subject: [PATCH] Add methods to PaymentService for preferred wallet selection - Introduced getPreferredWallet() to consistently retrieve the first wallet from userWallets. - Added getPreferredWalletAdminKey() to obtain the admin key of the preferred wallet for administrative tasks. These enhancements improve wallet management and ensure consistent wallet selection across the application. --- src/core/services/PaymentService.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core/services/PaymentService.ts b/src/core/services/PaymentService.ts index ad35dde..4d890c5 100644 --- a/src/core/services/PaymentService.ts +++ b/src/core/services/PaymentService.ts @@ -82,6 +82,24 @@ export class PaymentService extends BaseService { return wallets.find((wallet: any) => wallet.balance_msat > 0) } + /** + * Get the preferred wallet for operations (always use wallets[0] for consistency) + * This ensures consistent wallet selection across all modules + */ + getPreferredWallet(): any | null { + const wallets = this.userWallets + if (!wallets.length) return null + return wallets[0] + } + + /** + * Get the preferred wallet's admin key for administrative operations + */ + getPreferredWalletAdminKey(): string | null { + const wallet = this.getPreferredWallet() + return wallet?.adminkey || null + } + /** * Generate QR code for Lightning payment request */