Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow only positive transfer values #153

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Conversation

platfowner
Copy link
Member

Change summary:

  • Allow only positive transfer values

Related issues:

@@ -256,6 +256,9 @@ export default class Wallet {
transfer(input: {to: string, value: number, from?: string, nonce?: number, gas_price?: number}, isDryrun: boolean = false): Promise<any> {
const address = this.getImpliedAddress(input.from);
const toAddress = Ain.utils.toChecksumAddress(input.to);
if (!(input.value > 0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to check value is positive number? I know, If value is 0 or negative number, blockchain will throw error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this saves user's tx fee though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, if the transaction fails, does the user still have to pay the transaction fee?

Copy link
Member Author

@platfowner platfowner Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good quesiton.
It depends on the conditions the transaction breaks.
If the're prechecks or skipFees = true, tx fee is not charged (see https://github.com/ainblockchain/ain-blockchain/blob/master/db/index.js#L1955).

Basically, for the failed transactions included in blocks, tx fee is charged.
It's for handling dos attacks using failed transactions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the detailed explanation!

Copy link
Member

@woomurf woomurf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some question. Thanks!

@platfowner
Copy link
Member Author

Thanks for the review! @woomurf Now merging..

@platfowner platfowner merged commit 4deee26 into develop Oct 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants