Getting the node state

At any point we can fetch our balance from the node and check the lightning and onchain balances.

Rust
let node_state = sdk.node_info()?;
let balance_ln = node_state.channels_balance_msat;
let balance_onchain = node_state.onchain_balance_msat;
Swift
if let nodeInfo = try? sdk.nodeInfo() {
    let lnBalance = nodeInfo.channelsBalanceMsat
    let onchainBalance = nodeInfo.onchainBalanceMsat
    print(lnBalance);
    print(onchainBalance);
}
Kotlin
try {
    val nodeInfo = sdk.nodeInfo()
    val lnBalance = nodeInfo?.channelsBalanceMsat
    val onchainBalance = nodeInfo?.onchainBalanceMsat
} catch (e: Exception) {
    // handle error
}
React Native
try {
  const nodeState = await nodeInfo()
  const balanceLn = nodeState.channelsBalanceMsat
  const balanceOnchain = nodeState.onchainBalanceMsat
} catch (err) {
  console.error(err)
}
Dart
NodeState? nodeInfo = await breezSDK.nodeInfo();
if (nodeInfo != null) {
  int lnBalance = nodeInfo.channelsBalanceMsat;
  int onchainBalance = nodeInfo.onchainBalanceMsat;
  print(lnBalance);
  print(onchainBalance);
}
Python
node_info = sdk_services.node_info()
ln_balance = node_info.channels_balance_msat
onchain_balance = node_info.onchain_balance_msat
Go
if nodeInfo, err := sdk.NodeInfo(); err == nil {
    lnBalance := nodeInfo.ChannelsBalanceMsat
    onchainBalance := nodeInfo.OnchainBalanceMsat

    log.Printf("%#v %#v", lnBalance, onchainBalance)
}
C#
try
{
    var nodeInfo = sdk.NodeInfo();
    var lnBalance = nodeInfo?.channelsBalanceMsat;
    var onchainBalance = nodeInfo?.onchainBalanceMsat;
}
catch (Exception)
{
    // Handle error
}

You are now ready to receive a Lightning payment.