FFiber WebLN
API / Provider / provider.getBalance

provider.getBalance

Core

Aggregate spendable and receivable channel capacity by asset.

Signature

function getBalance(assetId?: string): Promise<Balance[]>
PERMISSION

Requires enable(). No additional confirmation prompt in the reference providers.

Parameters

NameTypeDescription
assetIdstring

Reserved filter for a native CKB or UDT asset identifier. Current reference providers return all assets.

Response

NameTypeDescription
assetIdrequiredstring

CKB or a provider-defined UDT type-script identifier.

spendablerequiredHex

Total local balance available for outbound payments.

receivablerequiredHex

Total remote balance available for inbound payments.

Example

const balances = await fiber.getBalance();

for (const balance of balances) {
  console.log(balance.assetId, balance.spendable);
}

Provider behavior

W

WASM node

Calls fiber-js listChannels() and groups local_balance / remote_balance by funding UDT type script.

R

Remote fnn

Calls fnn list_channels and aggregates the returned channel balances. Its current UDT grouping is less granular than WASM-node.

Notes

  • Amounts are hexadecimal strings to avoid JavaScript integer precision loss.
  • An empty array means the node has no channel balance to report.

Errors