Skip to content

Minus amount , is a huge miss #16

@jehadja

Description

@jehadja

Hi, thanks you for the Course, but i mention the it's possible to send minus or 0 value on amount and i think it's will be very danger.
specially for people will really run it as a production.

you can send minus amount on create Transaction eg
image
it will rise sender balance :) for sure -- = +
fix need 2 tests + 2 fix on classes
wallet / index.test.js

			it("throws an error on mins", () => {
				expect(() => {
					wallet.createTransaction({
						recipient: "arabto2-recipient",
						amount: -100,
					});
				}).toThrow("incorrect amount value");
			});

wallet/ index.js

		if (amount <= 0) {
			throw new Error("incorrect amount value");
		} 

------ also on update transaction -----
wallet/transaction.test.js

			it("throws an error on mins", () => {
				expect(() => {
					transaction.update({
						senderWallet,
						recipient: "arabto2-recipient",
						amount: -100,
					});
				}).toThrow("incorrect amount value");
			});

wallet/transaction.js

		if (amount <= 0) {
			throw new Error("incorrect amount value");
		}

also i think it balance shall not accept minus value , the amount also accept alphabet so i even suggest to have method on util to validate the number

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions