Rename the crate to just "magical"
This commit is contained in:
parent
ac06e35c49
commit
43cb0331bf
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "magical-bitcoin-wallet"
|
name = "magical"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
authors = ["Alekos Filini <alekos.filini@gmail.com>", "Riccardo Casatta <riccardo@casatta.it>"]
|
authors = ["Alekos Filini <alekos.filini@gmail.com>", "Riccardo Casatta <riccardo@casatta.it>"]
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use magical_bitcoin_wallet::bitcoin;
|
use magical::bitcoin;
|
||||||
use magical_bitcoin_wallet::database::MemoryDatabase;
|
use magical::database::MemoryDatabase;
|
||||||
use magical_bitcoin_wallet::descriptor::HDKeyPaths;
|
use magical::descriptor::HDKeyPaths;
|
||||||
use magical_bitcoin_wallet::wallet::address_validator::{AddressValidator, AddressValidatorError};
|
use magical::wallet::address_validator::{AddressValidator, AddressValidatorError};
|
||||||
use magical_bitcoin_wallet::ScriptType;
|
use magical::ScriptType;
|
||||||
use magical_bitcoin_wallet::{OfflineWallet, Wallet};
|
use magical::{OfflineWallet, Wallet};
|
||||||
|
|
||||||
use bitcoin::hashes::hex::FromHex;
|
use bitcoin::hashes::hex::FromHex;
|
||||||
use bitcoin::util::bip32::Fingerprint;
|
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 descriptor = "sh(and_v(v:pk(tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/*),after(630000)))";
|
||||||
let mut wallet: OfflineWallet<_> =
|
let mut wallet: OfflineWallet<_> =
|
||||||
Wallet::new_offline(descriptor, None, Network::Regtest, MemoryDatabase::new())?;
|
Wallet::new_offline(descriptor, None, Network::Regtest, MemoryDatabase::new())?;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
extern crate bitcoin;
|
extern crate bitcoin;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate magical_bitcoin_wallet;
|
extern crate magical;
|
||||||
extern crate miniscript;
|
extern crate miniscript;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ use bitcoin::Network;
|
|||||||
use miniscript::policy::Concrete;
|
use miniscript::policy::Concrete;
|
||||||
use miniscript::Descriptor;
|
use miniscript::Descriptor;
|
||||||
|
|
||||||
use magical_bitcoin_wallet::database::memory::MemoryDatabase;
|
use magical::database::memory::MemoryDatabase;
|
||||||
use magical_bitcoin_wallet::{OfflineWallet, ScriptType, Wallet};
|
use magical::{OfflineWallet, ScriptType, Wallet};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init_from_env(
|
env_logger::init_from_env(
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
extern crate magical_bitcoin_wallet;
|
extern crate magical;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use magical_bitcoin_wallet::bitcoin::util::bip32::ChildNumber;
|
use magical::bitcoin::util::bip32::ChildNumber;
|
||||||
use magical_bitcoin_wallet::bitcoin::*;
|
use magical::bitcoin::*;
|
||||||
use magical_bitcoin_wallet::descriptor::*;
|
use magical::descriptor::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let desc = "wsh(or_d(\
|
let desc = "wsh(or_d(\
|
||||||
|
@ -36,11 +36,11 @@ use log::{debug, error, info, trace, LevelFilter};
|
|||||||
|
|
||||||
use bitcoin::Network;
|
use bitcoin::Network;
|
||||||
|
|
||||||
use magical_bitcoin_wallet::bitcoin;
|
use magical::bitcoin;
|
||||||
use magical_bitcoin_wallet::blockchain::compact_filters::*;
|
use magical::blockchain::compact_filters::*;
|
||||||
use magical_bitcoin_wallet::cli;
|
use magical::cli;
|
||||||
use magical_bitcoin_wallet::sled;
|
use magical::sled;
|
||||||
use magical_bitcoin_wallet::Wallet;
|
use magical::Wallet;
|
||||||
|
|
||||||
fn prepare_home_dir() -> PathBuf {
|
fn prepare_home_dir() -> PathBuf {
|
||||||
let mut dir = PathBuf::new();
|
let mut dir = PathBuf::new();
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! # use std::sync::Arc;
|
//! # use std::sync::Arc;
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! # use magical_bitcoin_wallet::blockchain::compact_filters::*;
|
//! # use magical::blockchain::compact_filters::*;
|
||||||
//! let num_threads = 4;
|
//! let num_threads = 4;
|
||||||
//!
|
//!
|
||||||
//! let mempool = Arc::new(Mempool::default());
|
//! let mempool = Arc::new(Mempool::default());
|
||||||
@ -55,7 +55,7 @@
|
|||||||
//! ))
|
//! ))
|
||||||
//! .collect::<Result<_, _>>()?;
|
//! .collect::<Result<_, _>>()?;
|
||||||
//! let blockchain = CompactFiltersBlockchain::new(peers, "./wallet-filters", Some(500_000))?;
|
//! let blockchain = CompactFiltersBlockchain::new(peers, "./wallet-filters", Some(500_000))?;
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::error::Error>(())
|
//! # Ok::<(), magical::error::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```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 client = electrum_client::Client::new("ssl://electrum.blockstream.info:50002", None)?;
|
||||||
//! let blockchain = ElectrumBlockchain::from(client);
|
//! let blockchain = ElectrumBlockchain::from(client);
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
|
//! # Ok::<(), magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
//! ## Example
|
//! ## Example
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! # use magical_bitcoin_wallet::blockchain::esplora::EsploraBlockchain;
|
//! # use magical::blockchain::esplora::EsploraBlockchain;
|
||||||
//! let blockchain = EsploraBlockchain::new("https://blockstream.info/testnet/");
|
//! let blockchain = EsploraBlockchain::new("https://blockstream.info/testnet/");
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
|
//! # Ok::<(), magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # use std::sync::Arc;
|
//! # 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 desc = "wsh(and_v(v:pk(cV3oCth6zxZ1UVsHLnGothsWNsaoxRhC6aeNi5VbSdFpwUkgkEci),or_d(pk(cVMTy7uebJgvFaSBwcgvwk8qn8xSLc97dKow4MBetjrrahZoimm2),older(12960))))";
|
||||||
//!
|
//!
|
||||||
//! let (extended_desc, key_map) = ExtendedDescriptor::parse_secret(desc)?;
|
//! let (extended_desc, key_map) = ExtendedDescriptor::parse_secret(desc)?;
|
||||||
@ -40,7 +40,7 @@
|
|||||||
//! let signers = Arc::new(key_map.into());
|
//! let signers = Arc::new(key_map.into());
|
||||||
//! let policy = extended_desc.extract_policy(signers)?;
|
//! let policy = extended_desc.extract_policy(signers)?;
|
||||||
//! println!("policy: {}", serde_json::to_string(&policy)?);
|
//! println!("policy: {}", serde_json::to_string(&policy)?);
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
|
//! # Ok::<(), magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
@ -42,9 +42,9 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! # use std::sync::Arc;
|
//! # use std::sync::Arc;
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use magical_bitcoin_wallet::address_validator::*;
|
//! # use magical::address_validator::*;
|
||||||
//! # use magical_bitcoin_wallet::database::*;
|
//! # use magical::database::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! struct PrintAddressAndContinue;
|
//! struct PrintAddressAndContinue;
|
||||||
//!
|
//!
|
||||||
//! impl AddressValidator for PrintAddressAndContinue {
|
//! impl AddressValidator for PrintAddressAndContinue {
|
||||||
@ -71,7 +71,7 @@
|
|||||||
//!
|
//!
|
||||||
//! let address = wallet.get_new_address()?;
|
//! let address = wallet.get_new_address()?;
|
||||||
//! println!("Address: {}", address);
|
//! println!("Address: {}", address);
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
|
//! # Ok::<(), magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
//! # use std::str::FromStr;
|
//! # use std::str::FromStr;
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use bitcoin::consensus::serialize;
|
//! # use bitcoin::consensus::serialize;
|
||||||
//! # use magical_bitcoin_wallet::wallet::coin_selection::*;
|
//! # use magical::wallet::coin_selection::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! #[derive(Debug)]
|
//! #[derive(Debug)]
|
||||||
//! struct AlwaysSpendEverything;
|
//! struct AlwaysSpendEverything;
|
||||||
//!
|
//!
|
||||||
@ -57,7 +57,7 @@
|
|||||||
//! amount_needed: u64,
|
//! amount_needed: u64,
|
||||||
//! input_witness_weight: usize,
|
//! input_witness_weight: usize,
|
||||||
//! fee_amount: f32,
|
//! 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 selected_amount = utxos.iter().fold(0, |acc, utxo| acc + utxo.txout.value);
|
||||||
//! let all_utxos_selected = utxos
|
//! let all_utxos_selected = utxos
|
||||||
//! .into_iter()
|
//! .into_iter()
|
||||||
@ -77,7 +77,7 @@
|
|||||||
//! let additional_fees = additional_weight as f32 * fee_rate.as_sat_vb() / 4.0;
|
//! 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 {
|
//! 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 {
|
//! 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, ...
|
//! // create wallet, sync, ...
|
||||||
//!
|
//!
|
||||||
//! let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
//! let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
||||||
@ -99,7 +99,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // inspect, sign, broadcast, ...
|
//! // inspect, sign, broadcast, ...
|
||||||
//!
|
//!
|
||||||
//! # Ok::<(), magical_bitcoin_wallet::Error>(())
|
//! # Ok::<(), magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use bitcoin::consensus::encode::serialize;
|
use bitcoin::consensus::encode::serialize;
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! # use std::str::FromStr;
|
//! # use std::str::FromStr;
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use magical_bitcoin_wallet::database::*;
|
//! # use magical::database::*;
|
||||||
//! # use magical_bitcoin_wallet::wallet::export::*;
|
//! # use magical::wallet::export::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! let import = r#"{
|
//! let import = r#"{
|
||||||
//! "descriptor": "wpkh([c258d2e4\/84h\/1h\/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe\/0\/*)",
|
//! "descriptor": "wpkh([c258d2e4\/84h\/1h\/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe\/0\/*)",
|
||||||
//! "blockheight":1782088,
|
//! "blockheight":1782088,
|
||||||
@ -44,15 +44,15 @@
|
|||||||
//!
|
//!
|
||||||
//! let import = WalletExport::from_str(import)?;
|
//! let import = WalletExport::from_str(import)?;
|
||||||
//! let wallet: OfflineWallet<_> = Wallet::new_offline(&import.descriptor(), import.change_descriptor().as_deref(), Network::Testnet, MemoryDatabase::default())?;
|
//! 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`
|
//! ### Export a `Wallet`
|
||||||
//! ```
|
//! ```
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use magical_bitcoin_wallet::database::*;
|
//! # use magical::database::*;
|
||||||
//! # use magical_bitcoin_wallet::wallet::export::*;
|
//! # use magical::wallet::export::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! let wallet: OfflineWallet<_> = Wallet::new_offline(
|
//! let wallet: OfflineWallet<_> = Wallet::new_offline(
|
||||||
//! "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/0/*)",
|
//! "wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/0/*)",
|
||||||
//! Some("wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/1/*)"),
|
//! Some("wpkh([c258d2e4/84h/1h/0h]tpubDD3ynpHgJQW8VvWRzQ5WFDCrs4jqVFGHB3vLC3r49XHJSqP8bHKdK4AriuUKLccK68zfzowx7YhmDN8SiSkgCDENUFx9qVw65YyqM78vyVe/1/*)"),
|
||||||
@ -61,10 +61,10 @@
|
|||||||
//! )?;
|
//! )?;
|
||||||
//! let export = WalletExport::export_wallet(&wallet, "exported wallet", true)
|
//! let export = WalletExport::export_wallet(&wallet, "exported wallet", true)
|
||||||
//! .map_err(ToString::to_string)
|
//! .map_err(ToString::to_string)
|
||||||
//! .map_err(magical_bitcoin_wallet::Error::Generic)?;
|
//! .map_err(magical::Error::Generic)?;
|
||||||
//!
|
//!
|
||||||
//! println!("Exported: {}", export.to_string());
|
//! println!("Exported: {}", export.to_string());
|
||||||
//! # Ok::<_, magical_bitcoin_wallet::Error>(())
|
//! # Ok::<_, magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -229,8 +229,8 @@ where
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// # use bitcoin::*;
|
/// # use bitcoin::*;
|
||||||
/// # use magical_bitcoin_wallet::*;
|
/// # use magical::*;
|
||||||
/// # use magical_bitcoin_wallet::database::*;
|
/// # use magical::database::*;
|
||||||
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
||||||
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
||||||
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
/// # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
||||||
@ -238,7 +238,7 @@ where
|
|||||||
/// TxBuilder::with_recipients(vec![(to_address.script_pubkey(), 50_000)])
|
/// TxBuilder::with_recipients(vec![(to_address.script_pubkey(), 50_000)])
|
||||||
/// )?;
|
/// )?;
|
||||||
/// // sign and broadcast ...
|
/// // sign and broadcast ...
|
||||||
/// # Ok::<(), magical_bitcoin_wallet::Error>(())
|
/// # Ok::<(), magical::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn create_tx<Cs: coin_selection::CoinSelectionAlgorithm>(
|
pub fn create_tx<Cs: coin_selection::CoinSelectionAlgorithm>(
|
||||||
&self,
|
&self,
|
||||||
@ -453,8 +453,8 @@ where
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// # use bitcoin::*;
|
/// # use bitcoin::*;
|
||||||
/// # use magical_bitcoin_wallet::*;
|
/// # use magical::*;
|
||||||
/// # use magical_bitcoin_wallet::database::*;
|
/// # use magical::database::*;
|
||||||
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
||||||
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
||||||
/// let txid = Txid::from_str("faff0a466b70f5d5f92bd757a92c1371d4838bdd5bc53a06764e2488e51ce8f8").unwrap();
|
/// let txid = Txid::from_str("faff0a466b70f5d5f92bd757a92c1371d4838bdd5bc53a06764e2488e51ce8f8").unwrap();
|
||||||
@ -463,7 +463,7 @@ where
|
|||||||
/// TxBuilder::new().fee_rate(FeeRate::from_sat_per_vb(5.0)),
|
/// TxBuilder::new().fee_rate(FeeRate::from_sat_per_vb(5.0)),
|
||||||
/// )?;
|
/// )?;
|
||||||
/// // sign and broadcast ...
|
/// // sign and broadcast ...
|
||||||
/// # Ok::<(), magical_bitcoin_wallet::Error>(())
|
/// # Ok::<(), magical::Error>(())
|
||||||
/// ```
|
/// ```
|
||||||
// TODO: support for merging multiple transactions while bumping the fees
|
// 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
|
// TODO: option to force addition of an extra output? seems bad for privacy to update the
|
||||||
@ -691,13 +691,13 @@ where
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// # use bitcoin::*;
|
/// # use bitcoin::*;
|
||||||
/// # use magical_bitcoin_wallet::*;
|
/// # use magical::*;
|
||||||
/// # use magical_bitcoin_wallet::database::*;
|
/// # use magical::database::*;
|
||||||
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
/// # let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/*)";
|
||||||
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
/// # let wallet: OfflineWallet<_> = Wallet::new_offline(descriptor, None, Network::Testnet, MemoryDatabase::default())?;
|
||||||
/// # let (psbt, _) = wallet.create_tx(TxBuilder::new())?;
|
/// # let (psbt, _) = wallet.create_tx(TxBuilder::new())?;
|
||||||
/// let (signed_psbt, finalized) = wallet.sign(psbt, None)?;
|
/// 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> {
|
pub fn sign(&self, mut psbt: PSBT, assume_height: Option<u32>) -> Result<(PSBT, bool), Error> {
|
||||||
// this helps us doing our job later
|
// this helps us doing our job later
|
||||||
self.add_input_hd_keypaths(&mut psbt)?;
|
self.add_input_hd_keypaths(&mut psbt)?;
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use bitcoin::util::psbt;
|
//! # use bitcoin::util::psbt;
|
||||||
//! # use bitcoin::util::bip32::Fingerprint;
|
//! # use bitcoin::util::bip32::Fingerprint;
|
||||||
//! # use magical_bitcoin_wallet::signer::*;
|
//! # use magical::signer::*;
|
||||||
//! # use magical_bitcoin_wallet::database::*;
|
//! # use magical::database::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! # #[derive(Debug)]
|
//! # #[derive(Debug)]
|
||||||
//! # struct CustomHSM;
|
//! # struct CustomHSM;
|
||||||
//! # impl CustomHSM {
|
//! # impl CustomHSM {
|
||||||
@ -85,7 +85,7 @@
|
|||||||
//! Arc::new(Box::new(custom_signer))
|
//! Arc::new(Box::new(custom_signer))
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! # Ok::<_, magical_bitcoin_wallet::Error>(())
|
//! # Ok::<_, magical::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//! # use std::str::FromStr;
|
//! # use std::str::FromStr;
|
||||||
//! # use bitcoin::*;
|
//! # use bitcoin::*;
|
||||||
//! # use magical_bitcoin_wallet::*;
|
//! # use magical::*;
|
||||||
//! # let to_address = Address::from_str("2N4eQYCbKUHCCTUjBJeHcJp9ok6J2GZsTDt").unwrap();
|
//! # 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
|
//! // 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
|
//! // of 5.0 satoshi/vbyte, only spending non-change outputs and with RBF signaling
|
||||||
|
@ -44,7 +44,7 @@ pub fn magical_blockchain_tests(attr: TokenStream, item: TokenStream) -> TokenSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parse2::<syn::ExprPath>(quote! { magical_bitcoin_wallet }).unwrap()
|
parse2::<syn::ExprPath>(quote! { magical }).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
match parse::<syn::ItemFn>(item) {
|
match parse::<syn::ItemFn>(item) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user