invoice-canister
invoice-canister copied to clipboard
Prevent arithmetic overflow when amount in TransferArgs is below 10_000
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.
I've had this issue a ton. I worked around it by adding 10,000 extra.
Some better error handling here would be worthwhile