Skip to content

types: Reject non canonical addresses in DecodeAddress#595

Merged
algochoi merged 2 commits intodevelopfrom
non-canon-addr-check
Aug 22, 2023
Merged

types: Reject non canonical addresses in DecodeAddress#595
algochoi merged 2 commits intodevelopfrom
non-canon-addr-check

Conversation

@algochoi
Copy link
Copy Markdown
Contributor

@algochoi algochoi commented Aug 21, 2023

Checks that the address to decode is a canonical representation (least significant bit is 00, i.e. the ending character is one of "AEIMQUY4"). Adds a test to check that non-canonical addresses are rejected.

Note that the server (and most goal commands) will reject non-canonical addresses, but our SDK clients don't seem to check this.

Closes #274

@algochoi algochoi self-assigned this Aug 21, 2023
@algochoi algochoi changed the title Reject non canonical addresses in DecodeAddress types: Reject non canonical addresses in DecodeAddress Aug 21, 2023
Comment thread types/address.go
// Checksum is good, copy address bytes into output
copy(a[:], addressBytes)

// Check if address is canonical
Copy link
Copy Markdown
Contributor Author

@algochoi algochoi Aug 21, 2023

Choose a reason for hiding this comment

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

@algochoi algochoi marked this pull request as ready for review August 21, 2023 15:58
@algochoi algochoi requested review from a team, Eric-Warehime, shiqizng, tzaffi and winder and removed request for a team August 22, 2023 14:05
Copy link
Copy Markdown
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

Approving as this looks very good.

Minor nit: consider modding "correct, and ..." to "correct and canonical, and ..." in the function comment.

Comment thread types/address.go
// DecodeAddress turns a checksum address string into an Address object. It
// checks that the checksum is correct, and returns an error if it's not.
// checks that the checksum is correct and whether the address is canonical,
// and returns an error if it's not.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@algochoi algochoi merged commit 92cfa33 into develop Aug 22, 2023
@algochoi algochoi deleted the non-canon-addr-check branch August 22, 2023 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add canonical check

3 participants