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.
This commit is contained in:
parent
16a96ebfc9
commit
8ba4d46767
1 changed files with 18 additions and 0 deletions
|
|
@ -82,6 +82,24 @@ export class PaymentService extends BaseService {
|
||||||
return wallets.find((wallet: any) => wallet.balance_msat > 0)
|
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
|
* Generate QR code for Lightning payment request
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue