forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 21
/
inscriptions.rs
42 lines (33 loc) Β· 1.13 KB
/
inscriptions.rs
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
use super::*;
#[derive(Serialize, Deserialize)]
pub struct Output {
pub inscription: InscriptionId,
pub location: SatPoint,
pub explorer: String,
pub postage: u64,
}
pub(crate) fn run(wallet: String, options: Options) -> SubcommandResult {
let index = Index::open(&options)?;
index.update()?;
let client = bitcoin_rpc_client_for_wallet_command(wallet, &options)?;
let unspent_outputs = get_unspent_outputs(&client, &index)?;
let inscriptions = index.get_inscriptions(&unspent_outputs)?;
let explorer = match options.chain() {
Chain::Mainnet => "https://ordinals.com/inscription/",
Chain::Regtest => "http:https://localhost/inscription/",
Chain::Signet => "https://signet.ordinals.com/inscription/",
Chain::Testnet => "https://testnet.ordinals.com/inscription/",
};
let mut output = Vec::new();
for (location, inscription) in inscriptions {
if let Some(postage) = unspent_outputs.get(&location.outpoint) {
output.push(Output {
location,
inscription,
explorer: format!("{explorer}{inscription}"),
postage: postage.to_sat(),
})
}
}
Ok(Some(Box::new(output)))
}