Access a user's accounts
Once the dApp successfully connects to the ln wallet, you can use the following method to obtain the ln wallet's address
Method
getAccounts
bitpocket.ln.getAccounts()
Get address of current account
Parameters
none
Returns
Promise- `Objectstring: address of current account
Example
try {
let res = await window.ln.getAccounts();
console.log(res)
} catch (e) {
console.log(e);
}
> "bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr@bitbooom.fun"
Additional Note
- When the ln wallet is not connected, an error will be thrown.
accountsChanged
window.bitpocket.ln.on('accountsChanged', handler: (accounts: Array<string>) => void);
window.bitpocket.ln.removeListener('accountsChanged', handler: (accounts: Array<string>) => void);
The accountsChanged will be emitted whenever the user's exposed account address changes.