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()andbytes().
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()andwsh().
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.
Type Fields¶
Core types don't have any fields, except for tagged arrays with custom fields.
Bitcoin types have the following fields:
Virtual types (represented as tagged arrays) have the following fields: