Thanks to visit codestin.com
Credit goes to github.com

Skip to content

parseSatoshis converts integer satoshi to BTC and breaks sendBitcoin #5339

@lomocc

Description

@lomocc
  • File: packages/adapters/bitcoin/src/utils/UnitsUtil.ts

  • Issue: parseSatoshis divides the incoming integer satoshi by 10**decimals and returns a formatted decimal string. sendBitcoin expects an integer satoshi amount, so using parseSatoshis before sending results in the wrong on‑chain amount.

  • Repro: parseSatoshis("100000000", decimals=8) => "1" — if passed to sendBitcoin this will send 1 satoshi instead of 100,000,000.

  • Suggested fix: separate display vs send logic. Rename to formatSatoshis (display only) and implement using BigInt (avoid parseFloat). Ensure sendBitcoin receives raw satoshi (string/BigInt) or provide a precise converter that returns the exact decimal string required by any RPC.

  • Severity: High — can cause incorrect transfers.

const value = parseFloat(amount) / 10 ** network.nativeCurrency.decimals

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions