Skip to content

update base58 to have simpler logic and more tests#1

Merged
leishman merged 2 commits into
masterfrom
leishman--add-base-58-tests
May 27, 2019
Merged

update base58 to have simpler logic and more tests#1
leishman merged 2 commits into
masterfrom
leishman--add-base-58-tests

Conversation

@leishman

Copy link
Copy Markdown
Member

In this PR I update the base58 module to rely more on built-in Elixir functions inspired by the approach taken here, which I think is very elegant (https://github.com/comboy/bitcoin-elixir/blob/develop/lib/bitcoin/base58_check.ex).

This is still a WIP with more tests to write and cleanups around the public functions, along with documentation and fixing some compile bugs due to usage in other modules.

@bruteforcecat what do you think about these changes?

@kafaichoi

Copy link
Copy Markdown
Contributor

look good to me. Would you want to add typespec and implement encode for Base58Check?

@leishman leishman force-pushed the leishman--add-base-58-tests branch from 518a149 to 249d883 Compare May 26, 2019 05:02
@leishman leishman changed the title WIP: update base58 to have simpler logic and more test update base58 to have simpler logic and more test May 26, 2019
@leishman

Copy link
Copy Markdown
Member Author

@bruteforcecat I have updated the branch with a lot of improvements and all tests are passing.

@leishman leishman changed the title update base58 to have simpler logic and more test update base58 to have simpler logic and more tests May 26, 2019
Comment thread lib/base58_check.ex Outdated
|> encode_base()
end

@spec encode_base(binary) :: binary

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.

overlapping typespec should change this to @spec encode_base(binary) :: String.t() and remove the one below

Comment thread lib/base58_check.ex Outdated
end

@doc """
Encode a byte array into a base58 encoded string

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.

it should be a binary instead byte array which is list(byte)

Comment thread lib/base58_check.ex
@type byte_list :: list(byte())

@doc """
Decode a base58 check encoded string into a byte array and validate checksum

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.

binary instead of byte array

Comment thread lib/base58_check.ex
end

@doc """
Decode a base58 encoded string into a byte array

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.

binary instead of byte array

@kafaichoi

Copy link
Copy Markdown
Contributor

Look super awesome! just leave some comment about doc and typespec. please merge it after fixing them

@kafaichoi kafaichoi self-requested a review May 27, 2019 06:47
@leishman leishman force-pushed the leishman--add-base-58-tests branch from 7d4a256 to 6a94cef Compare May 27, 2019 06:48
@leishman

Copy link
Copy Markdown
Member Author

fixed. thanks for the great comments. will merge

@leishman leishman merged commit 178bed5 into master May 27, 2019
@leishman leishman deleted the leishman--add-base-58-tests branch May 27, 2019 06:49
kafaichoi pushed a commit to kafaichoi/bitcoinex that referenced this pull request Apr 21, 2021
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.

2 participants