Connect to the BitPocket LN Wallet
"Connecting" or "logging in" to BitPocket Wallet effectively means "to access the user's LN account".
You should only initiate a connection request in response to direct user action, such as clicking a button. You should always disable the "connect" button while the connection request is pending. You should never initiate a connection request on page load.
We recommend that you provide a button to allow the user to connect BitPocket Wallet to your dapp. Clicking this button should call the following method:
Methods
requestAccounts
window.bitpocket.ln.requestAccounts()
Connect the current account.
Parameters
none
Returns
Promisereturnsstring[]: Address of current account.
try {
let accounts = await window.bitpocket.ln.requestAccounts();
console.log('connect success', accounts);
} catch (e) {
console.log('connect failed');
}
> connect success ['bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr@bitbooom.fun']
disconnect
bitpocket.ln.disconnect()
Disconnect the current account.
Parameters
none
Returns
Promisereturnsvoid
window.bitpocket.ln.disconnect();