mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import {
|
|
BreezEvent,
|
|
connect,
|
|
defaultConfig,
|
|
EnvironmentType,
|
|
mnemonicToSeed,
|
|
NodeConfig,
|
|
NodeConfigVariant,
|
|
nodeInfo
|
|
} from "@breeztech/react-native-breez-sdk"
|
|
|
|
const exampleGettingStarted = async () => {
|
|
// ANCHOR: init-sdk
|
|
// SDK events listener
|
|
const onBreezEvent = (e: BreezEvent) => {
|
|
console.log(`Received event ${e.type}`)
|
|
}
|
|
|
|
// Create the default config
|
|
const seed = await mnemonicToSeed("<mnemonics words>")
|
|
const inviteCode = "<invite code>"
|
|
const apiKey = "<api key>"
|
|
const nodeConfig: NodeConfig = {
|
|
type: NodeConfigVariant.GREENLIGHT,
|
|
config: {
|
|
inviteCode
|
|
}
|
|
}
|
|
|
|
const config = await defaultConfig(
|
|
EnvironmentType.PRODUCTION,
|
|
apiKey,
|
|
nodeConfig
|
|
)
|
|
|
|
// Connect to the Breez SDK make it ready for use
|
|
await connect(config, seed, onBreezEvent)
|
|
// ANCHOR_END: init-sdk
|
|
}
|
|
|
|
const exampleFetchNodeInfo = async () => {
|
|
// ANCHOR: fetch-balance
|
|
const nodeState = await nodeInfo()
|
|
const balanceLn = nodeState.channelsBalanceMsat
|
|
const balanceOnchain = nodeState.onchainBalanceMsat
|
|
// ANCHOR_END: fetch-balance
|
|
}
|