Skip to content

Negative AI3 check is redundant, but also technically incorrect #6

@teor2345

Description

@teor2345

The negative check will give an incorrect result for values like -0.1, which is parsed as -0*AI3 + 0.1*AI3:

if (result <= 0n) throw new Error('Amount must be > 0');

But all negative values are excluded by the regexes, so this is not an issue in practice:

if (!/^[0-9]+(\.[0-9]+)?$/.test(s)) throw new Error('Invalid AI3 amount');

if (!/^[0-9]+$/.test(s)) throw new Error('Invalid amount: only digits allowed (shannons)');

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