SHOWING: First 60
pointer: Option<u64>,
metaprotocol: Option<String>,
metadata: Option<Vec<u8>>,
compress: bool,
) -> Result<Self, Error> {
let path = path.as_ref();
let body = fs::read(path).with_context(|| format!("io error reading {}", path.display()))?;
let (content_type, compression_mode) = Media::content_type_for_path(path)?;
let (body, content_encoding) = if compress {
let mut compressed = Vec::new();
{
CompressorWriter::with_params(
&mut compressed,
body.len(),
&BrotliEncoderParams {
lgblock: 24,
lgwin: 24,
mode: compression_mode,
quality: 11,
size_hint: body.len(),
..Default::default()
},
)
.write_all(&body)?;
let mut decompressor = brotli::Decompressor::new(compressed.as_slice(), compressed.len());
let mut decompressed = Vec::new();
decompressor.read_to_end(&mut decompressed)?;
ensure!(decompressed == body, "decompression roundtrip failed");
#45,023,366text );
}
#[test]
fn select_cardinal_utxo_ignores_locked_utxos() {
let utxos = vec![
(outpoint(1), Amount::from_sat(500)),
(outpoint(2), Amount::from_sat(500)),
];
let locked_utxos = vec![outpoint(1)];
let mut tx_builder = TransactionBuilder::new(
satpoint(0, 0),
BTreeMap::new(),
utxos.into_iter().collect(),
locked_utxos.into_iter().collect(),
recipient(),
[change(0), change(1)],
FeeRate::try_from(1.0).unwrap(),
Target::Value(Amount::from_sat(10_000)),
);
assert_eq!(
tx_builder
.select_cardinal_utxo(Amount::from_sat(500), false)
.unwrap()
.0,
outpoint(2),
);
}
}
#45,001,655textuse {super::*, crate::wallet::Wallet, std::collections::BTreeSet};
#[derive(Serialize, Deserialize)]
pub struct CardinalUtxo {
pub output: OutPoint,
pub amount: u64,
}
pub(crate) fn run(options: Options) -> SubcommandResult {
let index = Index::open(&options)?;
index.update()?;
let unspent_outputs = index.get_unspent_outputs(Wallet::load(&options)?)?;
let inscribed_utxos = index
.get_inscriptions(&unspent_outputs)?
.keys()
.map(|satpoint| satpoint.outpoint)
.collect::<BTreeSet<OutPoint>>();
let cardinal_utxos = unspent_outputs
.iter()
.filter_map(|(output, amount)| {
if inscribed_utxos.contains(output) {
None
} else {
Some(CardinalUtxo {
output: *output,
amount: amount.to_sat(),
})
}
})
.collect::<Vec<CardinalUtxo>>();
Ok(Box::new(cardinal_utxos))
}
#44,989,184text for i in 0..start / COIN_VALUE {
writeln!(tsv, "{}", i * COIN_VALUE).expect("writing to string should succeed");
}
let start = Instant::now();
assert_eq!(
sats_from_tsv(utxos, &tsv)
.unwrap()
.into_iter()
.map(|(outpoint, s)| (outpoint, s.parse().unwrap()))
.collect::<Vec<(OutPoint, u64)>>(),
results
);
assert!(Instant::now() - start < Duration::from_secs(10));
}
}
#44,986,362textsource = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets 0.48.5",
]
[[package]]
name = "ciborium"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
dependencies = [
"ciborium-io",
"ciborium-ll",
"serde",
]
[[package]]
name = "ciborium-io"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
[[package]]
name = "ciborium-ll"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
#44,976,608text]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniscript"
version = "10.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1eb102b66b2127a872dbcc73095b7b47aeb9d92f7b03c2b2298253ffc82c7594"
dependencies = [
"bitcoin",
"bitcoin-private",
]
[[package]]
name = "miniz_oxide"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
[[package]]
name = "mio"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
dependencies = [
"libc",
"wasi",
"windows-sys 0.48.0",
]
[[package]]
name = "mp4"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
#44,976,600text