Library for decoding and validating CashAddr btc cash addresses. Implements CashAddr encoding and decoding specified by Address format for Bitcoin Cash v 1.0 as well as CashToken aware addresses CashToken.
The package can be installed by adding cashaddr
to your list of dependencies in mix.exs
:
def deps do
[
{:cashaddr, "~> 0.1.0"}
]
end
encode
and decode
transform CashAddr into prefix and payload.
CashAddr.encode("prefix", "hełło")
"prefix:dpjutqk9sfhsx5tgjch6"
CashAddr.decode("bitcoincash:qph5kuz78czq00e3t85ugpgd7xmer5kr7c5f6jdpwk")
{:ok, {"bitcoincash",
<<0, 111, 75, 112, 94, 62, 4, 7, 191, 49, 89, 233, 196, 5, 13, 241, 183, 145, 210, 195, 246>>}}
encode_payload
and decode_payload
transform payload into version and hash.
CashAddr.encode_payload(0, <<118, 160, 64, 83, 189, 160, 168, 139, 218, 81, 119, 184, 106, 21, 195, 178, 159, 85, 152, 115>>)
<<0, 118, 160, 64, 83, 189, 160, 168, 139, 218, 81, 119, 184, 106, 21, 195, 178, 159, 85, 152, 115>>
CashAddr.decode_payload(<<0, 118, 160, 64, 83, 189, 160, 168, 139, 218, 81, 119, 184, 106, 21, 195, 178, 159, 85, 152, 115>>)
{:ok, {0, 160, <<118, 160, 64, 83, 189, 160, 168, 139, 218, 81, 119, 184, 106, 21, 195, 178, 159, 85, 152, 115>>}}
Docs can be found at https://hexdocs.pm/cashaddr.
CashAddr source code is released under MIT License. Check LICENSE file for more information.