Function vmNumberToBigInt

  • This method attempts to decode a VM Number, a format in which numeric values are represented on the stack. (The Satoshi implementation calls this CScriptNum.)

    If bytes is a valid VM Number, this method returns the represented number in BigInt format. If bytes is not valid, a VmNumberError is returned.

    All common operations accepting numeric parameters or pushing numeric values to the stack currently use the VM Number format. The binary format of numbers wouldn't be important if they could only be operated on by arithmetic operators, but since the results of these operations may become input to other operations (e.g. hashing), the specific representation is consensus- critical.

    For the reverse, see bigIntToVmNumber.

    Parameters

    • bytes: Uint8Array

      a Uint8Array from the stack

    • __namedParameters: {
          maximumVmNumberByteLength?: number;
          requireMinimalEncoding?: boolean;
      } = ...
      • Optional maximumVmNumberByteLength?: number

        The maximum valid number of bytes in a VM Number.

      • Optional requireMinimalEncoding?: boolean

        If true, this method returns an error when parsing non-minimally encoded VM Numbers.

    Returns bigint | VmNumberError

Generated using TypeDoc