This guide helps users understand how to build Bitcoin Lightning Network applications using the OneKey Lightning Network Provider API.
- Accepting Lightning Network payments
- decentralized identity applications
Download the OneKey Wallet. Install the OneKey browser extension.
- The OneKey browser extension injects
Provider API
into visited websites. - Two types of APIs are provided:
window.webln
andwindow.$onekey.webln
. - It is recommended to use
window.$onekey.webln
.
Both APIs have the same functionality, just different names.
Before you start using WebLN you need to check for browser support by checking if the variable window.webln
is defined:
const provider = (window.$onekey && window.$onekey.webln) || window.webln;
if (!provider) {
alert("No Provider available.");
}
Before using the following API, you first need to use the provider.enable
method to request the user to access the relevant account.
const provider = (window.$onekey && window.$onekey.webln) || window.webln;
provider.enable()
Other APIs can be called only after user authorization.
Clarify Needs: Identify required functionalities, call relevant interfaces
- Get user's Bitcoin Lightning node information:
provider.getInfo
- Send a payment:
provider.sendPayment
- Request an invoice to receive payment:
provider.makeInvoice
- Request signature for any message:
provider.signMessage
More Interfaces: View Details
- Key Operations: Such as account switching
- More Information: View More