Rename the crate to just "magical"

This commit is contained in:
Alekos Filini
2020-09-04 17:01:33 +02:00
parent ac06e35c49
commit 43cb0331bf
16 changed files with 63 additions and 63 deletions

View File

@@ -42,8 +42,8 @@
//! ```no_run
//! # use std::sync::Arc;
//! # use bitcoin::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical_bitcoin_wallet::blockchain::compact_filters::*;
//! # use magical::*;
//! # use magical::blockchain::compact_filters::*;
//! let num_threads = 4;
//!
//! let mempool = Arc::new(Mempool::default());
@@ -55,7 +55,7 @@
//! ))
//! .collect::<Result<_, _>>()?;
//! let blockchain = CompactFiltersBlockchain::new(peers, "./wallet-filters", Some(500_000))?;
//! # Ok::<(), magical_bitcoin_wallet::error::Error>(())
//! # Ok::<(), magical::error::Error>(())
//! ```
use std::collections::HashSet;

View File

@@ -31,10 +31,10 @@
//! ## Example
//!
//! ```no_run
//! # use magical_bitcoin_wallet::blockchain::electrum::ElectrumBlockchain;
//! # use magical::blockchain::electrum::ElectrumBlockchain;
//! let client = electrum_client::Client::new("ssl://electrum.blockstream.info:50002", None)?;
//! let blockchain = ElectrumBlockchain::from(client);
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
//! # Ok::<(), magical::Error>(())
//! ```
use std::collections::HashSet;

View File

@@ -30,9 +30,9 @@
//! ## Example
//!
//! ```no_run
//! # use magical_bitcoin_wallet::blockchain::esplora::EsploraBlockchain;
//! # use magical::blockchain::esplora::EsploraBlockchain;
//! let blockchain = EsploraBlockchain::new("https://blockstream.info/testnet/");
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
//! # Ok::<(), magical::Error>(())
//! ```
use std::collections::{HashMap, HashSet};

View File

@@ -31,7 +31,7 @@
//!
//! ```
//! # use std::sync::Arc;
//! # use magical_bitcoin_wallet::descriptor::*;
//! # use magical::descriptor::*;
//! let desc = "wsh(and_v(v:pk(cV3oCth6zxZ1UVsHLnGothsWNsaoxRhC6aeNi5VbSdFpwUkgkEci),or_d(pk(cVMTy7uebJgvFaSBwcgvwk8qn8xSLc97dKow4MBetjrrahZoimm2),older(12960))))";
//!
//! let (extended_desc, key_map) = ExtendedDescriptor::parse_secret(desc)?;
@@ -40,7 +40,7 @@
//! let signers = Arc::new(key_map.into());
//! let policy = extended_desc.extract_policy(signers)?;
//! println!("policy: {}", serde_json::to_string(&policy)?);
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
//! # Ok::<(), magical::Error>(())
//! ```
use std::cmp::max;

View File

@@ -42,9 +42,9 @@
//! ```
//! # use std::sync::Arc;
//! # use bitcoin::*;
//! # use magical_bitcoin_wallet::address_validator::*;
//! # use magical_bitcoin_wallet::database::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::address_validator::*;
//! # use magical::database::*;
//! # use magical::*;
//! struct PrintAddressAndContinue;
//!
//! impl AddressValidator for PrintAddressAndContinue {
@@ -71,7 +71,7 @@
//!
//! let address = wallet.get_new_address()?;
//! println!("Address: {}", address);
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
//! # Ok::<(), magical::Error>(())
//! ```
use std::fmt;

View File

@@ -43,8 +43,8 @@
//! # use std::str::FromStr;
//! # use bitcoin::*;
//! # use bitcoin::consensus::serialize;
//! # use magical_bitcoin_wallet::wallet::coin_selection::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::wallet::coin_selection::*;
//! # use magical::*;
//! #[derive(Debug)]
//! struct AlwaysSpendEverything;
//!
@@ -57,7 +57,7 @@
//! amount_needed: u64,
//! input_witness_weight: usize,
//! fee_amount: f32,
//! ) -> Result<CoinSelectionResult, magical_bitcoin_wallet::Error> {
//! ) -> Result<CoinSelectionResult, magical::Error> {
//! let selected_amount = utxos.iter().fold(0, |acc, utxo| acc + utxo.txout.value);
//! let all_utxos_selected = utxos
//! .into_iter()
@@ -77,7 +77,7 @@
//! let additional_fees = additional_weight as f32 * fee_rate.as_sat_vb() / 4.0;
//!
//! if (fee_amount + additional_fees).ceil() as u64 + amount_needed > selected_amount {
//! return Err(magical_bitcoin_wallet::Error::InsufficientFunds);
//! return Err(magical::Error::InsufficientFunds);
//! }
//!
//! Ok(CoinSelectionResult {
@@ -88,7 +88,7 @@
//! }
//! }
//!
//! # let wallet: OfflineWallet<_> = Wallet::new_offline("", None, Network::Testnet, magical_bitcoin_wallet::database::MemoryDatabase::default())?;
//! # let wallet: OfflineWallet<_> = Wallet::new_offline("", None, Network::Testnet, magical::database::MemoryDatabase::default())?;
//! // create wallet, sync, ...
//!
//! let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
@@ -99,7 +99,7 @@
//!
//! // inspect, sign, broadcast, ...
//!
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
//! # Ok::<(), magical::Error>(())
//! ```
use bitcoin::consensus::encode::serialize;

View File

@@ -33,9 +33,9 @@
//! ```
//! # use std::str::FromStr;
//! # use bitcoin::*;
//! # use magical_bitcoin_wallet::database::*;
//! # use magical_bitcoin_wallet::wallet::export::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::database::*;
//! # use magical::wallet::export::*;
//! # use magical::*;
//! let import = r#"{
//! "descriptor": "wpkh([c258d2e4\/84h\/1h\/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe\/0\/*)",
//! "blockheight":1782088,
@@ -44,15 +44,15 @@
//!
//! let import = WalletExport::from_str(import)?;
//! let wallet: OfflineWallet<_> = Wallet::new_offline(&import.descriptor(), import.change_descriptor().as_deref(), Network::Testnet, MemoryDatabase::default())?;
//! # Ok::<_, magical_bitcoin_wallet::Error>(())
//! # Ok::<_, magical::Error>(())
//! ```
//!
//! ### Export a `Wallet`
//! ```
//! # use bitcoin::*;
//! # use magical_bitcoin_wallet::database::*;
//! # use magical_bitcoin_wallet::wallet::export::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::database::*;
//! # use magical::wallet::export::*;
//! # use magical::*;
//! let wallet: OfflineWallet<_> = Wallet::new_offline(
//! "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/0/*)",
//! Some("wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/1/*)"),
@@ -61,10 +61,10 @@
//! )?;
//! let export = WalletExport::export_wallet(&wallet, "exported wallet", true)
//! .map_err(ToString::to_string)
//! .map_err(magical_bitcoin_wallet::Error::Generic)?;
//! .map_err(magical::Error::Generic)?;
//!
//! println!("Exported: {}", export.to_string());
//! # Ok::<_, magical_bitcoin_wallet::Error>(())
//! # Ok::<_, magical::Error>(())
//! ```
use std::str::FromStr;

View File

@@ -229,8 +229,8 @@ where
/// ```no_run
/// # use std::str::FromStr;
/// # use bitcoin::*;
/// # use magical_bitcoin_wallet::*;
/// # use magical_bitcoin_wallet::database::*;
/// # use magical::*;
/// # use magical::database::*;
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
@@ -238,7 +238,7 @@ where
/// TxBuilder::with_recipients(vec![(to_address.script_pubkey(), 50_000)])
/// )?;
/// // sign and broadcast ...
/// # Ok::<(), magical_bitcoin_wallet::Error>(())
/// # Ok::<(), magical::Error>(())
/// ```
pub fn create_tx<Cs: coin_selection::CoinSelectionAlgorithm>(
&self,
@@ -453,8 +453,8 @@ where
/// ```no_run
/// # use std::str::FromStr;
/// # use bitcoin::*;
/// # use magical_bitcoin_wallet::*;
/// # use magical_bitcoin_wallet::database::*;
/// # use magical::*;
/// # use magical::database::*;
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
/// let txid = Txid::from_str("faff0a466b70f5d5f92bd757a92c1371d4838bdd5bc53a06764e2488e51ce8f8").unwrap();
@@ -463,7 +463,7 @@ where
/// TxBuilder::new().fee_rate(FeeRate::from_sat_per_vb(5.0)),
/// )?;
/// // sign and broadcast ...
/// # Ok::<(), magical_bitcoin_wallet::Error>(())
/// # Ok::<(), magical::Error>(())
/// ```
// TODO: support for merging multiple transactions while bumping the fees
// TODO: option to force addition of an extra output? seems bad for privacy to update the
@@ -691,13 +691,13 @@ where
/// ```no_run
/// # use std::str::FromStr;
/// # use bitcoin::*;
/// # use magical_bitcoin_wallet::*;
/// # use magical_bitcoin_wallet::database::*;
/// # use magical::*;
/// # use magical::database::*;
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
/// # let (psbt, _) = wallet.create_tx(TxBuilder::new())?;
/// let (signed_psbt, finalized) = wallet.sign(psbt, None)?;
/// # Ok::<(), magical_bitcoin_wallet::Error>(())
/// # Ok::<(), magical::Error>(())
pub fn sign(&self, mut psbt: PSBT, assume_height: Option<u32>) -> Result<(PSBT, bool), Error> {
// this helps us doing our job later
self.add_input_hd_keypaths(&mut psbt)?;

View File

@@ -33,9 +33,9 @@
//! # use bitcoin::*;
//! # use bitcoin::util::psbt;
//! # use bitcoin::util::bip32::Fingerprint;
//! # use magical_bitcoin_wallet::signer::*;
//! # use magical_bitcoin_wallet::database::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::signer::*;
//! # use magical::database::*;
//! # use magical::*;
//! # #[derive(Debug)]
//! # struct CustomHSM;
//! # impl CustomHSM {
@@ -85,7 +85,7 @@
//! Arc::new(Box::new(custom_signer))
//! );
//!
//! # Ok::<_, magical_bitcoin_wallet::Error>(())
//! # Ok::<_, magical::Error>(())
//! ```
use std::cmp::Ordering;

View File

@@ -29,7 +29,7 @@
//! ```
//! # use std::str::FromStr;
//! # use bitcoin::*;
//! # use magical_bitcoin_wallet::*;
//! # use magical::*;
//! # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
//! // Create a transaction with one output to `to_address` of 50_000 satoshi, with a custom fee rate
//! // of 5.0 satoshi/vbyte, only spending non-change outputs and with RBF signaling