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

adding condition for allowing rcv to be none if close to is set #317

Merged
merged 7 commits into from
Apr 27, 2022

Conversation

barnjamin
Copy link
Contributor

@barnjamin barnjamin commented Apr 21, 2022

closes #316

This should still raise a useful error in the case that close to is also zero since that is likely user error.

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

Looks fine to me

nit: not sure if ZERO_ADDRESS should live in transaction.py or constants.py. I don't have a strong opinion so I'll just leave it as a thought.

@barnjamin
Copy link
Contributor Author

nit: not sure if ZERO_ADDRESS should live in transaction.py or constants.py. I don't have a strong opinion so I'll just leave it as a thought.

Good point, moved it.

Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

This seems like a good idea but it does open up a new edge case: what if amount is > 0? In that case the amount gets sent to the receiver (which is the zero address now), and the account balance minus that amount gets sent to the close to address.

Perhaps the condition should be close_remainder_to is not None and not amt?

@jasonpaulos
Copy link
Contributor

To clarify, is this change meant to fix decoding transactions properly from a block, or to let users instantiate transactions in a more useful way?

@barnjamin
Copy link
Contributor Author

This seems like a good idea but it does open up a new edge case: what if amount is > 0? In that case the amount gets sent to the receiver (which is the zero address now), and the account balance minus that amount gets sent to the close to address.

Good point, I guess your suggestion of checking amt >0 should also be implemented.

To clarify, is this change meant to fix decoding transactions properly from a block, or to let users instantiate transactions in a more useful way?

In this case the bug report I got was when decoding a transaction included in a block where apparently no rcv was set. Locally they can just patch it to set the zero address if it isnt already present

@jasonpaulos
Copy link
Contributor

Thanks for addressing the concerns I raised offline. This looks good, but it would be amazing if you could also add a test to test_unit.py that makes sure calling future_msgpack_decode on a txn where the receiver is the zero address works properly now

@barnjamin barnjamin requested a review from jasonpaulos April 26, 2022 19:03
Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

Looks great, thanks

@jasonpaulos jasonpaulos merged commit ed15008 into develop Apr 27, 2022
@gmalouf gmalouf deleted the rcv-empty branch June 5, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Payment transaction decode with no Receiver
3 participants