Skip to content

Data Types Reference

Minsc runtime values are represented using the minsc::Value enum consisting of the Core and Bitcoin data types, with additional Virtual types built on top of these.

Values are dynamically typed, with implicit coercion between compatible runtime types that allows functions to accept values in multiple representations and reduces the need for explicit conversions in common cases.

This page documents the runtime data types available in Minsc and the coercions supported between them.

The Minsc reference uses an informal type and function-signature notation to describe expected arguments and return values. This notation is purely for documentation purposes and does not correspond to a type system in Minsc.

Core Types

There are 8 core data types:

Type Underlying Repr Coerces From
Bool bool None
Int i64 None
Float f64 None
String String Any
Bytes Vec<u8> String | Transaction | Script | Psbt | PubKey | SecKey | Bool | Int
Array minsc::Array None
Function minsc::Function None
Symbol minsc::Symbol None

Explicit conversions are available using int(), float(), str() and bytes().

Bitcoin Types

Minsc comes with the following first-class Bitcoin-specific data types:

Type Underlying Repr Coerces From
Transaction bitcoin::Transaction Bytes | Psbt | [ "version": …, ]
Script bitcoin::ScriptBuf Bytes
Psbt bitcoin::Psbt Transaction | Bytes | String | [ ]
Address bitcoin::Address String
Network bitcoin::Network None
PubKey miniscript::DescriptorPublicKey Bytes<32|33|78> | SecKey
SecKey miniscript::DescriptorSecretKey Bytes<32|78>
Descriptor miniscript::Descriptor None
Policy miniscript::Policy PubKey | SecKey
TapInfo bitcoin::TaprootSpendInfo Descriptor<Tr,Definite>
WshInfo minsc::WshInfo None

Explicit conversions are available using tx(), script(), psbt(), address(), pubkey(), seckey(), descriptor(), tapinfo() and wsh().

Virtual Types

Some additional Bitcoin-specific data types used on the Rust side do not have a dedicated first-class type in the Minsc runtime, and are instead represented using other first-class types.

When a virtual type is returned from a function, it is always represented using its canonical Runtime Repr. When a virtual type is accepted as a function argument, it can be provided using the Runtime Repr or any of the Coerces From representations.

Virtual Type Underlying Repr Runtime Repr Coerces From
OutPoint bitcoin::OutPoint [ "txid": Txid , "vout": Int ] Txid:Int
TxIn bitcoin::TxIn [ "prevout": OutPoint, "sequence": Int?, "witness": Array?, "script_sig": Script? ] OutPoint | Txid:Int
TxOut bitcoin::TxOut [ "script_pubkey": ScriptPubKey, "amount": Int ] ScriptPubKey:Int
Txid bitcoin::Txid Bytes<32> Transaction | Psbt
ScriptPubKey bitcoin::ScriptBuf Script Descriptor<Definite> | Address | TapInfo | WshInfo
KeySource bitcoin::KeySource Bytes<4>:Array<Int> PubKey:Array<Int> | Bytes<32|33|78>:Array<Int>
TapNode minsc::TapNode Script | Bytes<32> | TapNode:TapNode
TapLeafHash bitcoin::TapLeafHash Bytes<32> Script | Policy
TapLeafVersion bitcoin::LeafVersion Bytes<1> Int<u8>
PsbtInput psbt::Input [ ] TxIn | OutPoint | Txid:Int
PsbtOutput psbt::Output [ ] TxOut | ScriptPubKey:Int
PsbtPropKey psbt::ProprietaryKey [ String, Int<u8>, Bytes ] &8288;
PsbtRawKey psbt::Key [ Int<u8>, Bytes ] &8288;
SortedMulti miniscript::SortedMulti [ "sortedmulti", Int, Array<PubKey> ]

Type Fields

Core types don't have any fields, except for tagged arrays with custom fields.

Bitcoin types have the following fields:

Type Fields
Transaction txid wtxid version locktime inputs outputs weight vsize size
Script instructions minimal_instructions is_parsable parse_error is_minimal is_witness_program witness_version is_p2pk is_p2pkh is_p2sh is_p2wpkh is_p2wsh is_p2tr is_multisig is_op_return is_push_only count_sigops count_sigops_legacy dust_value
Psbt unsigned_tx version inputs outputs xpub proprietary unknown txid utxos fee
Address script_pubkey address_type witness_program qr_uri
PubKey identifier fingerprint is_xpub is_definite is_wildcard is_multipath is_xonly master_fingerprint derivation_path derivation_paths chain_code
SecKey pubkey is_xpriv ...
Descriptor descriptor_type address_type max_weight singles is_safe is_multipath is_wildcard is_definite script_pubkey explicit_script witness_program internal_key miniscripts miniscript_tree output_key output_key_parity merkle_root scripts script_tree
Policy keys is_definite is_wildcard is_multipath is_valid is_safe is_nonmalleable
TapInfo script_pubkey witness_program internal_key output_key output_key_parity merkle_root script_tree scripts is_definite address_type
WshInfo script_pubkey explicit_script witness_program address_type is_definite

Virtual types (represented as tagged arrays) have the following fields:

Virtual Type Fields
OutPoint txid vout
TxIn prevout sequence witness script_sig
TxOut script_pubkey amount
PsbtInput utxo non_witness_utxo bip32_derivation witness_script redeem_script sighash_type partial_sigs final_scriptsig final_script_witness tap_internal_key tap_merkle_root tap_key_origins tap_scripts tap_key_sig tap_script_sigs sha256_preimages hash256_preimages ripemd160_preimages hash160_preimages proprietary unknown
PsbtOutput bip32_derivation witness_script redeem_script tap_internal_key tap_key_origins tap_tree proprietary unknown