getBalance

Returns the balance in satoshi.

Type

;() => Promise<{ balance: bigint; confirmed: bigint; unconfirmed: bigint }>

Return Value

The current balance in Satoshi.

Description

Returns the confirmed balance in Satoshi, the unconfirmed balance, and the total balance in satoshi.

Example

import { Computer } from '@bitcoin-computer/lib'
import { chain, expect, network, url } from '../../utils/index.js'

describe('getBalance', () => {
  it('Should return the balance', async () => {
    // Create and fund wallet
    const computer = new Computer({ chain, network, url })
    await computer.faucet(1e6)

    // Check wallet
    expect(await computer.getBalance()).to.deep.eq({
      confirmed: 0n,
      unconfirmed: BigInt(1e6),
      balance: BigInt(1e6),
    })
  })
})

Source