View Source BitcoinLib

Bitcoin Elixir

Want to interact with the Bitcoin network through a DIY app? Look no further, this library is about doing it with Elixir in a very abstract way. It keeps the cryptography jargon to a minimum, while sticking to the Bitcoin glossary.

how-to-use

How to use

First, make sure you've got elixir set up and that you know the language's basics.

Then, create a project and add the dependency in mix.exs.

def deps do
  [
    {:bitcoinlib, "~> 0.2.0-pre1"}
  ]
end

Finally, head to the private key creation documentation to get started.

Here are the most useful links

technicalities

Technicalities

this-lib-can

This lib can

  • Generate entropy with dice rolls
  • Create private keys
  • Derive public keys from private keys
  • Handle Hierarchical Deterministic (HD) Wallets, including
    • Mnemonic Phrases
    • Derivation Paths
  • Serialize/Deserialize Private Keys (xprv, yprv, zprv)
  • Serialize/Deserialize Public Keys (xpub, ypub, zpub)
  • Generate Addresses
  • Sign P2PKH transactions

Mid term goals

  • Sign Transactions (PSBT)
  • Taproot support

supported-address-types

Supported address types

Address TypeDescriptionStarts WithSupported
P2PKHPay to Primary Key Hash1
P2WPKH-nested-in-P2SHNested Segwit3
P2WPKHNative Segwitbc1q
P2TRTaprootbc1pEventually...

referenced-bips

Referenced bips

A bip is a Bitcoin Improvement Proposal. Here is a list of those that are at least partially implemented in this library:

  • bip13 - Address Format for pay-to-script-hash
  • bip16 - Pay to Script Hash
  • bip32 - Hierarchical Deterministic Wallets
  • bip39 - Mnemonic code for generating deterministic keys
  • bip44 - Multi-Account Hierarchy for Deterministic Wallets
  • bip49 - Derivation scheme for P2WPKH-nested-in-P2SH based accounts
  • bip84 - Derivation scheme for P2WPKH based accounts
  • bip141 - Segregated Witness (Consensus layer)
  • bip173 - Base32 address format for native v0-16 witness outputs
  • bip174 - Partially Signed Bitcoin Transaction Format

PSBT bips, in the process of being implemented

running-static-analysis

Running static analysis

$ mix deps.get
$ mix test
$ mix dialyzer