Skip to content

Basic Postgres bech32 encoder/decoder extension based on pg_bitcoin_address

License

Notifications You must be signed in to change notification settings

cardano-community/pg_bech32

Repository files navigation

pg_bech32

This is a basic bech32 encode/decode PostgreSQL extension (stripped down from pg_bitcoin_address - making it a bit more generic bech32 encoder/decoder extension. Most of the files are untouched from original repository, removing everything other than references for bech32 itself.

Complete credit for original work for this extension should go to whitslack

Building

You need pkg-config and PostgreSQL installed. Then building and installing this extension is simply clone the repo, go to the folder and run the below:

make
sudo make install

Instantiating

You can instantiate the extension in your default schema:

=> CREATE EXTENSION pg_bech32;
CREATE EXTENSION

Or you can create a dedicated schema to host the extension:

=> CREATE EXTENSION pg_bech32 WITH SCHEMA grest;
CREATE EXTENSION

Functions

Bech32/Bech32m encoding/decoding

  • b32_encode(pre text, bytea text)text
    Encodes a bit bytea string using Bech32 with the given human-readable prefix.
  • b32_decode(encodedstr text)bytea Decodes bech32 encoded string to bytea
  • bech32_hrp(text)text
    Returns the human-readable prefix of the given Bech32/Bech32m encoding.
    • bech32_hrp('pool12fclephansjkz0qn339w7mu9jwef2ty439as08avaw7fuyk56j6')pool

About

Basic Postgres bech32 encoder/decoder extension based on pg_bitcoin_address

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published