Skip to content

Conversation

@jannotti
Copy link
Contributor

Allow the various key-ish fields of a keyreg txn to be bytes

Previously, these fields were required to be base64 encoded, which
seems like a strange requirement.

Added a few doc string cleanups.

@jannotti jannotti self-assigned this Dec 11, 2023
@jannotti jannotti requested a review from jasonpaulos December 11, 2023 18:00
@jannotti jannotti changed the title Keyreg bytes DX: Keyreg bytes Dec 11, 2023
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 good and nice code cleanup. Consider my suggestion optional but encouraged

return None
if isinstance(key, (bytes, bytearray)) and len(key) == size:
return base64.b64encode(key)
if len(base64.b64decode(key)) == size:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe also add isinstance(key, str) otherwise b64decode will probably throw an exception (did not check tho)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose it will, but that's life in a dynamic language, I think. Before you could have stuffed something crazy in that field, and you'd get an exception somewhere when we tried to serialize. Now it happens earlier, which I think is better.

But I don't want to try to turn Python into Go and insert type checks all over the place.

@jannotti jannotti merged commit 3e64019 into algorand:develop Dec 11, 2023
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.

9 participants