View Source Bitcoinex.PSBT.Global (bitcoinex v0.3.0)

Global properties of a partially signed bitcoin transaction.

Link to this section Summary

Functions

Adds a field to a Global map. Accepted fields

Combines two Global maps (BIP-174 Combiner). Callers guarantee the two unsigned_tx values are equal.

Builds a Global map wrapping an unsigned transaction.

Link to this section Types

@type t() :: %Bitcoinex.PSBT.Global{
  proprietary: [%{key: binary(), value: binary()}] | nil,
  unknown: [%{key: binary(), value: binary()}] | nil,
  unsigned_tx: Bitcoinex.Transaction.t() | nil,
  version: non_neg_integer() | nil,
  xpub:
    [%{xkey: Bitcoinex.ExtendedKey.t(), origin: Bitcoinex.PSBT.KeyOrigin.t()}]
    | nil
}

Link to this section Functions

Link to this function

add_field(global, arg2, tx)

View Source
@spec add_field(t(), atom(), any()) :: {:ok, t()} | {:error, atom()}

Adds a field to a Global map. Accepted fields:

  • :unsigned_tx — a Transaction.t()
  • :xpub%{xkey: ExtendedKey.t(), origin: KeyOrigin.t()} (repeatable); the key must be an extended public key ({:error, :private_key_not_allowed})
  • :version0 (only PSBT v0 is supported; any other integer is {:error, :unsupported_version})
  • :proprietary / :unknown%{key: binary(), value: binary()} (repeatable); a :proprietary key must carry the 0xFC type byte, and an :unknown key must be non-empty and must not use a type byte this map already parses into a dedicated field, nor 0xFC ({:error, :invalid_key_format}) — such a record could not survive a decode round-trip

Repeatable fields reject a record whose key is already present ({:error, :duplicate_key}): a PSBT map may not contain duplicate keys, so the Updater must not create one its own decoder would reject.

Link to this function

combine(global_a, global_b)

View Source
@spec combine(t(), t()) :: {:ok, t()} | {:error, atom()}

Combines two Global maps (BIP-174 Combiner). Callers guarantee the two unsigned_tx values are equal.

@spec from_unsigned_tx(Bitcoinex.Transaction.t()) :: t()

Builds a Global map wrapping an unsigned transaction.

@spec parse_global(binary()) :: {:ok, {t(), binary()}} | {:error, term()}
Link to this function

serialize_global(global)

View Source
@spec serialize_global(t()) :: binary()