Skip to main content

ark_core/
lib.rs

1use bitcoin::Amount;
2use bitcoin::OutPoint;
3use bitcoin::ScriptBuf;
4use bitcoin::TxOut;
5
6pub mod arknote;
7pub mod batch;
8pub mod boarding_output;
9pub mod coin_select;
10pub mod conversions;
11pub mod history;
12pub mod intent;
13pub mod script;
14pub mod send;
15pub mod server;
16pub mod unilateral_exit;
17pub mod vhtlc;
18pub mod vtxo;
19
20mod ark_address;
21mod error;
22mod tree_tx_output_script;
23mod tx_graph;
24mod vtxo_list;
25
26pub use ark_address::ArkAddress;
27pub use arknote::ArkNote;
28pub use boarding_output::BoardingOutput;
29pub use error::Error;
30pub use error::ErrorContext;
31pub use script::extract_sequence_from_csv_sig_script;
32pub use tx_graph::TxGraph;
33pub use tx_graph::TxGraphChunk;
34pub use unilateral_exit::build_anchor_tx;
35pub use unilateral_exit::build_unilateral_exit_tree_txids;
36pub use unilateral_exit::SelectedUtxo;
37pub use unilateral_exit::UtxoCoinSelection;
38pub use vtxo::Vtxo;
39pub use vtxo_list::VtxoList;
40
41pub const UNSPENDABLE_KEY: &str =
42    "0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0";
43
44pub const VTXO_INPUT_INDEX: usize = 0;
45
46/// The byte value corresponds to the string "taptree".
47pub const VTXO_TAPROOT_KEY: [u8; 7] = [116, 97, 112, 116, 114, 101, 101];
48
49/// The byte value corresponds to the string "condition".
50pub const VTXO_CONDITION_KEY: [u8; 9] = [99, 111, 110, 100, 105, 116, 105, 111, 110];
51
52/// The byte value corresponds to the string "expiry".
53pub const VTXO_TREE_EXPIRY_PSBT_KEY: [u8; 6] = [101, 120, 112, 105, 114, 121];
54
55/// The cosigner PKs that sign a VTXO TX input are included in the `unknown` key-value map field of
56/// that input in the VTXO PSBT. Since the `unknown` field can be used for any purpose, we know that
57/// a value is a cosigner PK if the corresponding key starts with this prefix.
58///
59/// The byte value corresponds to the string "cosigner".
60pub const VTXO_COSIGNER_PSBT_KEY: [u8; 8] = [99, 111, 115, 105, 103, 110, 101, 114];
61
62pub const DEFAULT_DERIVATION_PATH: &str = "m/83696968'/11811'/0";
63
64const ANCHOR_SCRIPT_PUBKEY: [u8; 4] = [0x51, 0x02, 0x4e, 0x73];
65
66/// Information a UTXO that may be extracted from an on-chain explorer.
67#[derive(Clone, Copy, Debug)]
68pub struct ExplorerUtxo {
69    pub outpoint: OutPoint,
70    pub amount: Amount,
71    pub confirmation_blocktime: Option<u64>,
72    pub is_spent: bool,
73}
74
75pub fn anchor_output() -> TxOut {
76    let script_pubkey = ScriptBuf::from_bytes(ANCHOR_SCRIPT_PUBKEY.to_vec());
77
78    TxOut {
79        value: Amount::ZERO,
80        script_pubkey,
81    }
82}