Build and parse payment links (BIP21 with CashAddr), such as
bitcoincash:qq…?amount=0.0015&label=Enkaji. Amounts are handled as whole
satoshis, never floats.
iex> BitcoinElixir.PaymentURI.build("bitcoincash:qq8hepxlmyfelgyfy985tw80r8pe805gfv230d2ufw", amount: 150_000, label: "Order EK-1")
"bitcoincash:qq8hepxlmyfelgyfy985tw80r8pe805gfv230d2ufw?amount=0.0015&label=Order%20EK-1"
Summary
Functions
A payment link for an address. Options: :amount in satoshis, :label,
:message, and :params for any other query parameters.
Satoshis as a decimal coin amount, without trailing zeros: 150_000 → "0.0015".
Parse a payment link, or a bare address. The amount comes back in satoshis; an amount with more than 8 decimals, or not a plain decimal, is refused.
A decimal coin amount as satoshis: "0.0015" → {:ok, 150_000}.
Types
Functions
A payment link for an address. Options: :amount in satoshis, :label,
:message, and :params for any other query parameters.
@spec format_amount(non_neg_integer()) :: String.t()
Satoshis as a decimal coin amount, without trailing zeros: 150_000 → "0.0015".
Parse a payment link, or a bare address. The amount comes back in satoshis; an amount with more than 8 decimals, or not a plain decimal, is refused.
@spec parse_amount(String.t() | nil) :: {:ok, non_neg_integer() | nil} | {:error, :bad_amount}
A decimal coin amount as satoshis: "0.0015" → {:ok, 150_000}.