invoice-canister icon indicating copy to clipboard operation
invoice-canister copied to clipboard

Prevent arithmetic overflow when amount in TransferArgs is below 10_000

Open seb-icp opened this issue 2 years ago • 2 comments

Currently when requesting a transfer with an amount in TransferArgs below 10_000 e8s the invoice canister will trap on an arithmetic overflow, due to this line :

amount = {
                // Total amount, minus the fee
                e8s = Nat64.sub(Nat64.fromNat(args.amount), 10000);
              };

Is it expected behaviour? I would rather have a specific error indicating that the amount is too low to pay for the fee. For the context, I have a function (called periodically) that check the balance in the invoice canister and request a transfer to another wallet.

seb-icp avatar Apr 14 '22 07:04 seb-icp

I've had this issue a ton. I worked around it by adding 10,000 extra.

Trunkzz avatar Apr 14 '22 21:04 Trunkzz

Some better error handling here would be worthwhile

krpeacock avatar Jun 23 '22 22:06 krpeacock