RooSoft
Why does dialyxir pretends this function can't return?
Trying to clean dialyzer messages in a new Bitcoin open source library…
Why does it pretend that this function can’t return?
lib/key/address.ex:39:no_return
Function to_public_key_hash/1 has no local return.
Here is the function out of context…
@doc """
Extracts the public key hash from an address, and make sure the checkum is ok
## Examples
iex> address = "mwYKDe7uJcgqyVHJAPURddeZvM5zBVQj5L"
...> BitcoinLib.Key.Address.to_public_key_hash(address)
{:ok, <<0xafc3e518577316386188af748a816cd14ce333f2::160>>, :p2pkh}
"""
@spec to_public_key_hash(binary()) :: {:ok, <<_::160>>, atom()} | {:error, binary()}
def to_public_key_hash(address) do
<<prefix::8, public_key_hash::bitstring-160, checksum::bitstring-32>> =
address
|> Base58.decode()
address_type = get_address_type_from_prefix(prefix)
case test_checksum(prefix, public_key_hash, checksum) do
{:ok} -> {:ok, public_key_hash, address_type}
{:error, message} -> {:error, message}
end
end
I made a test aside from the doctest above, and both succeed…
test "convert an address to a public key hash" do
address = "mtzUk1zTJzTdyC8Pz6PPPyCHTEL5RLVyDJ"
{:ok, public_key_hash, :p2pkh} =
address
|> Address.to_public_key_hash()
assert <<_::160>> = public_key_hash
end
Marked As Solved
LostKobrakai
It’s likely an incorrect typespec either on this function, or anything in the callstack of it.
1
Last Post!
RooSoft
That’s right, test_checksum/3 below was typespec’d with an integer() as the third argument while to_public_key_hash/1 was calling it with a bitstring()…
Thanks @LostKobrakai!
0
Popular in Questions
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Other popular topics
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Hello everyone,
Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










