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
No known key found for this signature in database
GPG Key ID: 5E8AFC3034FDFA4F
16 changed files with 63 additions and 63 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "magical-bitcoin-wallet"
name = "magical"
version = "0.1.0"
edition = "2018"
authors = ["Alekos Filini <alekos.filini@gmail.com>", "Riccardo Casatta <riccardo@casatta.it>"]

View File

@ -24,12 +24,12 @@
use std::sync::Arc;
use magical_bitcoin_wallet::bitcoin;
use magical_bitcoin_wallet::database::MemoryDatabase;
use magical_bitcoin_wallet::descriptor::HDKeyPaths;
use magical_bitcoin_wallet::wallet::address_validator::{AddressValidator, AddressValidatorError};
use magical_bitcoin_wallet::ScriptType;
use magical_bitcoin_wallet::{OfflineWallet, Wallet};
use magical::bitcoin;
use magical::database::MemoryDatabase;
use magical::descriptor::HDKeyPaths;
use magical::wallet::address_validator::{AddressValidator, AddressValidatorError};
use magical::ScriptType;
use magical::{OfflineWallet, Wallet};
use bitcoin::hashes::hex::FromHex;
use bitcoin::util::bip32::Fingerprint;
@ -57,7 +57,7 @@ impl AddressValidator for DummyValidator {
}
}
fn main() -> Result<(), magical_bitcoin_wallet::Error> {
fn main() -> Result<(), magical::Error> {
let descriptor = "sh(and_v(v:pk(tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/*),after(630000)))";
let mut wallet: OfflineWallet<_> =
Wallet::new_offline(descriptor, None, Network::Regtest, MemoryDatabase::new())?;

View File

@ -25,7 +25,7 @@
extern crate bitcoin;
extern crate clap;
extern crate log;
extern crate magical_bitcoin_wallet;
extern crate magical;
extern crate miniscript;
extern crate serde_json;
@ -39,8 +39,8 @@ use bitcoin::Network;
use miniscript::policy::Concrete;
use miniscript::Descriptor;
use magical_bitcoin_wallet::database::memory::MemoryDatabase;
use magical_bitcoin_wallet::{OfflineWallet, ScriptType, Wallet};
use magical::database::memory::MemoryDatabase;
use magical::{OfflineWallet, ScriptType, Wallet};
fn main() {
env_logger::init_from_env(

View File

@ -22,14 +22,14 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
extern crate magical_bitcoin_wallet;
extern crate magical;
extern crate serde_json;
use std::sync::Arc;
use magical_bitcoin_wallet::bitcoin::util::bip32::ChildNumber;
use magical_bitcoin_wallet::bitcoin::*;
use magical_bitcoin_wallet::descriptor::*;
use magical::bitcoin::util::bip32::ChildNumber;
use magical::bitcoin::*;
use magical::descriptor::*;
fn main() {
let desc = "wsh(or_d(\

View File

@ -36,11 +36,11 @@ use log::{debug, error, info, trace, LevelFilter};
use bitcoin::Network;
use magical_bitcoin_wallet::bitcoin;
use magical_bitcoin_wallet::blockchain::compact_filters::*;
use magical_bitcoin_wallet::cli;
use magical_bitcoin_wallet::sled;
use magical_bitcoin_wallet::Wallet;
use magical::bitcoin;
use magical::blockchain::compact_filters::*;
use magical::cli;
use magical::sled;
use magical::Wallet;
fn prepare_home_dir() -> PathBuf {
let mut dir = PathBuf::new();

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

View File

@ -44,7 +44,7 @@ pub fn magical_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenSt
}
}
} else {
parse2::<syn::ExprPath>(quote! { magical_bitcoin_wallet }).unwrap()
parse2::<syn::ExprPath>(quote! { magical }).unwrap()
};
match parse::<syn::ItemFn>(item) {