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

Input properties of a partially signed bitcoin transaction.

Link to this section Summary

Functions

Adds a field to an input map. Accepted fields

Combines two input maps (BIP-174 Combiner).

Attempts to finalize this input (the BIP-174 Input Finalizer role), given the transaction input that references it (used to locate the scriptPubKey and to validate any non-witness UTXO). Returns the finalized input, or the input unchanged if it cannot be finalized (best-effort, matching Bitcoin Core).

Returns true if this input has been finalized (has a final scriptSig and/or scriptWitness).

Returns an empty input map.

Link to this section Types

Link to this type

hash_preimage_record()

View Source
@type hash_preimage_record() :: %{hash: binary(), preimage: binary()}
@type key_value_record() :: %{key: binary(), value: binary()}
@type t() :: %Bitcoinex.PSBT.In{
  bip32_derivation:
    [
      %{
        public_key: Bitcoinex.Secp256k1.Point.t(),
        origin: Bitcoinex.PSBT.KeyOrigin.t()
      }
    ]
    | nil,
  final_scriptsig: Bitcoinex.Script.t() | nil,
  final_scriptwitness: Bitcoinex.Transaction.Witness.t() | nil,
  hash160: [hash_preimage_record()] | nil,
  hash256: [hash_preimage_record()] | nil,
  non_witness_utxo: Bitcoinex.Transaction.t() | nil,
  partial_sig:
    [
      %{
        public_key: Bitcoinex.Secp256k1.Point.t(),
        signature: binary(),
        sighash_flag: non_neg_integer()
      }
    ]
    | nil,
  por_commitment: binary() | nil,
  proprietary: [key_value_record()] | nil,
  redeem_script: Bitcoinex.Script.t() | nil,
  ripemd160: [hash_preimage_record()] | nil,
  sha256: [hash_preimage_record()] | nil,
  sighash_type: non_neg_integer() | nil,
  unknown: [key_value_record()] | nil,
  witness_script: Bitcoinex.Script.t() | nil,
  witness_utxo: Bitcoinex.Transaction.Out.t() | nil
}

Link to this section Functions

Link to this function

add_field(input, arg2, tx)

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

Adds a field to an input map. Accepted fields:

  • :non_witness_utxo — a Transaction.t()
  • :witness_utxo — a Transaction.Out.t()
  • :partial_sig%{public_key: Point.t(), signature: binary(), sighash_flag: flag} (repeatable), where signature is the raw DER-encoded ECDSA signature (stored verbatim, so it round-trips byte-for-byte) and flag (like :sighash_type) must be one of the valid sighash flags 0x01/0x02/0x03 optionally | 0x80
  • :sighash_type — one of the valid sighash flag integers
  • :redeem_script / :witness_script / :final_scriptsig — a Script.t() or its hex/binary
  • :bip32_derivation%{public_key: Point.t(), origin: KeyOrigin.t()} (repeatable)
  • :final_scriptwitness — a Transaction.Witness.t()
  • :por_commitment — a binary
  • :ripemd160 / :sha256 / :hash160 / :hash256%{hash: binary(), preimage: binary()} (repeatable); the hash must be the digest of the preimage under the named algorithm, else {:error, :invalid_hash_preimage}
  • :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
Link to this function

combine(input_a, input_b)

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

Combines two input maps (BIP-174 Combiner).

Link to this function

finalize(input, tx_input)

View Source
@spec finalize(t(), Bitcoinex.Transaction.In.t()) :: t()

Attempts to finalize this input (the BIP-174 Input Finalizer role), given the transaction input that references it (used to locate the scriptPubKey and to validate any non-witness UTXO). Returns the finalized input, or the input unchanged if it cannot be finalized (best-effort, matching Bitcoin Core).

@spec finalized?(t()) :: boolean()

Returns true if this input has been finalized (has a final scriptSig and/or scriptWitness).

@spec new() :: t()

Returns an empty input map.

Link to this function

parse_inputs(psbt, num_inputs)

View Source
@spec parse_inputs(binary(), non_neg_integer()) ::
  {:ok, {[t()], binary()}} | {:error, term()}
Link to this function

serialize_inputs(inputs)

View Source
@spec serialize_inputs([t()] | nil) :: binary()