1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! # ord-rs
//!
//! A library for working with Ordinal inscriptions.
//!
//! This library provides a set of tools for working with Ordinal inscriptions, including creating, parsing, and signing transactions.
//! It allows you to work with both BRC20, runes and generic inscriptions.
//!
//! # Get started
//!
//! Add the following to your `Cargo.toml`:
//!
//! ```toml
//! ord-rs = "0.3.0"
//! ```
//!
//! In case you want to enable runes support, you can add the following feature:
//!
//! ```toml
//! ord-rs = { version = "0.3.0", features = ["rune"] }
//! ```
//!
//! ## Example
//!
//! An example for creating a BRC20 inscription:
//!
//! ```rust
//! use bitcoin::secp256k1::Secp256k1;
//! use bitcoin::{Address, Amount, FeeRate, Network, PrivateKey, Txid};
//! use ord_rs::wallet::{
//! CreateCommitTransactionArgs, RevealTransactionArgs, SignCommitTransactionArgs,
//! };
//! use ord_rs::{Brc20, OrdTransactionBuilder, Utxo};
//!
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!
//! let network = Network::Testnet;
//! let ticker = "ordi".to_string();
//! let amount = 1_000;
//!
//! let private_key = PrivateKey::from_wif("cVkWbHmoCx6jS8AyPNQqvFr8V9r2qzDHJLaxGDQgDJfxT73w6fuU")?;
//! let public_key = private_key.public_key(&Secp256k1::new());
//! let sender_address = Address::p2wpkh(&public_key, network).unwrap();
//!
//! let mut builder = OrdTransactionBuilder::p2tr(private_key);
//!
//! let inputs = vec![Utxo {
//! id: Txid::from_str("791b415dc6946d864d368a0e5ec5c09ee2ad39cf298bc6e3f9aec293732cfda7")
//! .unwrap(), // the transaction that funded our wallet
//! index: 1,
//! amount: Amount::from_sat(8_000),
//! }];
//!
//! let commit_tx = builder
//! .build_commit_transaction(
//! network,
//! sender_address.clone(),
//! CreateCommitTransactionArgs {
//! fee_rate: FeeRate::from_sat_per_vb(1).unwrap(),
//! inputs: inputs.clone(),
//! inscription: Brc20::transfer(ticker, amount),
//! txin_script_pubkey: sender_address.script_pubkey(),
//! leftovers_recipient: sender_address.clone(),
//! derivation_path: None,
//! multisig_config: None,
//! },
//! )
//! .await?;
//!
//! let signed_commit_tx = builder
//! .sign_commit_transaction(
//! commit_tx.unsigned_tx,
//! SignCommitTransactionArgs {
//! inputs,
//! txin_script_pubkey: sender_address.script_pubkey(),
//! derivation_path: None,
//! },
//! )
//! .await?;
//!
//! let commit_txid = signed_commit_tx.txid();
//! // TODO: send commit_tx to the network
//!
//! let reveal_transaction = builder
//! .build_reveal_transaction(RevealTransactionArgs {
//! input: ord_rs::wallet::Utxo {
//! id: commit_txid,
//! index: 0,
//! amount: commit_tx.reveal_balance,
//! },
//! recipient_address: sender_address, // NOTE: it's correct, see README.md to read about how transfer works
//! redeem_script: commit_tx.redeem_script,
//! derivation_path: None,
//! })
//! .await?;
//!
//! Ok(())
//! }
//! ```
//!
extern crate log;
extern crate serde;
pub use bitcoin;
pub use ;
pub use Brc20;
pub use InscriptionId;
pub use Nft;
pub use Inscription;
pub use OrdResult;
pub use ;
pub use ;
pub use ;