js-sys = "0.3"
[features]
+default = ["std"]
+std = []
compiler = ["miniscript/compiler"]
all-keys = ["keys-bip39"]
keys-bip39 = ["bip39"]
[[example]]
name = "policy"
path = "examples/policy.rs"
+required-features = ["std"]
[[example]]
name = "mnemonic_to_descriptors"
pub use bitcoincore_rpc::bitcoincore_rpc_json::AddressType;
use bitcoincore_rpc::jsonrpc::serde_json::{self, json};
pub use bitcoincore_rpc::{Auth, Client as RpcClient, Error as RpcError, RpcApi};
+use core::ops::Deref;
use core::str::FromStr;
+use core::time::Duration;
use electrsd::bitcoind::BitcoinD;
use electrsd::{bitcoind, ElectrsD};
pub use electrum_client::{Client as ElectrumClient, ElectrumApi};
#[allow(unused_imports)]
use log::{debug, error, info, log_enabled, trace, Level};
use std::env;
-use std::ops::Deref;
-use std::time::Duration;
pub struct TestClient {
pub bitcoind: BitcoinD,
//! checksum of a descriptor
use crate::descriptor::DescriptorError;
+use alloc::string::String;
const INPUT_CHARSET: &[u8] = b"0123456789()[],'/*abcdefgh@:$%{}IJKLMNOPQRSTUVWXYZ&+-.;<=>?!^_|~ijklmnopqrstuvwxyzABCDEFGH`#\"\\ ";
const CHECKSUM_CHARSET: &[u8] = b"qpzry9x8gf2tvdw0s3jn54khce6mua7l";
#[test]
fn test_calc_checksum_invalid_character() {
- let sparkle_heart = unsafe { std::str::from_utf8_unchecked(&[240, 159, 146, 150]) };
+ let sparkle_heart = unsafe { core::str::from_utf8_unchecked(&[240, 159, 146, 150]) };
let invalid_desc = format!("wpkh(tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcL{}fjdi5qUvw3VDfgYiH5mNsj5izuiu2N/1/2/*)", sparkle_heart);
assert_matches!(
};
( $inner_struct:ident, $constructor:ident, $sortedmulti_constructor:ident, $ctx:ident, sortedmulti $( $inner:tt )* ) => {{
- use std::marker::PhantomData;
+ use core::marker::PhantomData;
use $crate::miniscript::descriptor::{$inner_struct, Descriptor, DescriptorPublicKey};
use $crate::miniscript::$ctx;
$crate::impl_sortedmulti!(build_desc, sortedmulti $( $inner )*)
}};
( $inner_struct:ident, $constructor:ident, $sortedmulti_constructor:ident, $ctx:ident, sortedmulti_vec $( $inner:tt )* ) => {{
- use std::marker::PhantomData;
+ use core::marker::PhantomData;
use $crate::miniscript::descriptor::{$inner_struct, Descriptor, DescriptorPublicKey};
use $crate::miniscript::$ctx;
a_keymap.extend(b_keymap.into_iter());
let minisc = $crate::miniscript::Miniscript::from_ast($crate::miniscript::miniscript::decode::Terminal::$terminal_variant(
- std::sync::Arc::new(a_minisc),
- std::sync::Arc::new(b_minisc),
+ alloc::sync::Arc::new(a_minisc),
+ alloc::sync::Arc::new(b_minisc),
))?;
minisc.check_miniscript()?;
let networks = $crate::keys::merge_networks(&networks, &c_networks);
let minisc = $crate::miniscript::Miniscript::from_ast($crate::miniscript::miniscript::decode::Terminal::$terminal_variant(
- std::sync::Arc::new(a_minisc),
- std::sync::Arc::new(b_minisc),
- std::sync::Arc::new(c_minisc),
+ alloc::sync::Arc::new(a_minisc),
+ alloc::sync::Arc::new(b_minisc),
+ alloc::sync::Arc::new(c_minisc),
))?;
minisc.check_miniscript()?;
)*
];
- keys.into_iter().collect::<Result<Vec<_>, _>>()
+ keys.into_iter().collect::<Result<alloc::vec::Vec<_>, _>>()
.map_err($crate::descriptor::DescriptorError::Key)
.and_then(|keys| $crate::keys::make_sortedmulti($thresh, keys, $build_desc, &secp))
});
#[macro_export]
macro_rules! parse_tap_tree {
( @merge $tree_a:expr, $tree_b:expr) => {{
- use std::sync::Arc;
+ use alloc::sync::Arc;
use $crate::miniscript::descriptor::TapTree;
$tree_a
// Single leaf
( $op:ident ( $( $minisc:tt )* ) ) => {{
- use std::sync::Arc;
+ use alloc::sync::Arc;
use $crate::miniscript::descriptor::TapTree;
$crate::fragment!( $op ( $( $minisc )* ) )
.and_then(|(minisc, keymap, networks)| {
let minisc = $crate::miniscript::Miniscript::from_ast(
$crate::miniscript::miniscript::decode::Terminal::$terminal_variant(
- std::sync::Arc::new(minisc),
+ alloc::sync::Arc::new(minisc),
),
)?;
$inner.and_then(|(a_minisc, a_keymap, a_networks)| {
$crate::impl_leaf_opcode_value_two!(
AndV,
- std::sync::Arc::new(a_minisc),
- std::sync::Arc::new($crate::fragment!(true).unwrap().0)
+ alloc::sync::Arc::new(a_minisc),
+ alloc::sync::Arc::new($crate::fragment!(true).unwrap().0)
)
.map(|(minisc, _, _)| (minisc, a_keymap, a_networks))
})
$inner.and_then(|(a_minisc, a_keymap, a_networks)| {
$crate::impl_leaf_opcode_value_two!(
OrI,
- std::sync::Arc::new($crate::fragment!(false).unwrap().0),
- std::sync::Arc::new(a_minisc)
+ alloc::sync::Arc::new($crate::fragment!(false).unwrap().0),
+ alloc::sync::Arc::new(a_minisc)
)
.map(|(minisc, _, _)| (minisc, a_keymap, a_networks))
})
$inner.and_then(|(a_minisc, a_keymap, a_networks)| {
$crate::impl_leaf_opcode_value_two!(
OrI,
- std::sync::Arc::new(a_minisc),
- std::sync::Arc::new($crate::fragment!(false).unwrap().0)
+ alloc::sync::Arc::new(a_minisc),
+ alloc::sync::Arc::new($crate::fragment!(false).unwrap().0)
)
.map(|(minisc, _, _)| (minisc, a_keymap, a_networks))
})
)*
];
- keys.into_iter().collect::<Result<Vec<_>, _>>()
+ keys.into_iter().collect::<Result<alloc::vec::Vec<_>, _>>()
.map_err($crate::descriptor::DescriptorError::Key)
}};
}
( thresh_vec ( $thresh:expr, $items:expr ) ) => ({
use $crate::miniscript::descriptor::KeyMap;
- let (items, key_maps_networks): (Vec<_>, Vec<_>) = $items.into_iter().map(|(a, b, c)| (a, (b, c))).unzip();
- let items = items.into_iter().map(std::sync::Arc::new).collect();
+ let (items, key_maps_networks): (alloc::vec::Vec<_>, alloc::vec::Vec<_>) = $items.into_iter().map(|(a, b, c)| (a, (b, c))).unzip();
+ let items = items.into_iter().map(alloc::sync::Arc::new).collect();
let (key_maps, valid_networks) = key_maps_networks.into_iter().fold((KeyMap::default(), $crate::keys::any_network()), |(mut keys_acc, net_acc), (key, net)| {
keys_acc.extend(key.into_iter());
( thresh ( $thresh:expr, $( $inner:tt )* ) ) => ({
let items = $crate::fragment_internal!( @v $( $inner )* );
- items.into_iter().collect::<Result<Vec<_>, _>>()
+ items.into_iter().collect::<Result<alloc::vec::Vec<_>, _>>()
.and_then(|items| $crate::fragment!(thresh_vec($thresh, items)))
});
( multi_vec ( $thresh:expr, $keys:expr ) ) => ({
#[cfg(test)]
mod test {
+ use alloc::string::ToString;
use bitcoin::hashes::hex::ToHex;
use bitcoin::secp256k1::Secp256k1;
use miniscript::descriptor::{DescriptorPublicKey, KeyMap};
use miniscript::{Descriptor, Legacy, Segwitv0};
- use std::str::FromStr;
+ use core::str::FromStr;
use crate::descriptor::{DescriptorError, DescriptorMeta};
use crate::keys::{DescriptorKey, IntoDescriptorKey, ValidNetworks};
}
}
+#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl_error!(bitcoin::util::bip32::Error, Bip32);
//! This module contains generic utilities to work with descriptors, plus some re-exported types
//! from [`miniscript`].
-use std::collections::BTreeMap;
+use crate::collections::BTreeMap;
+use alloc::string::String;
+use alloc::vec::Vec;
use bitcoin::util::bip32::{ChildNumber, DerivationPath, ExtendedPubKey, Fingerprint, KeySource};
use bitcoin::util::{psbt, taproot};
#[cfg(test)]
mod test {
- use std::str::FromStr;
+ use alloc::string::ToString;
+ use core::str::FromStr;
use assert_matches::assert_matches;
use bitcoin::consensus::encode::deserialize;
//! # Ok::<(), bdk::Error>(())
//! ```
-use std::cmp::max;
-use std::collections::{BTreeMap, HashSet, VecDeque};
-use std::fmt;
+use crate::collections::{BTreeMap, HashSet, VecDeque};
+use alloc::string::String;
+use alloc::vec::Vec;
+use core::cmp::max;
+use core::fmt;
use serde::ser::SerializeMap;
use serde::{Serialize, Serializer};
}
}
+#[cfg(feature = "std")]
impl std::error::Error for PolicyError {}
impl Policy {
use crate::descriptor::policy::SatisfiableItem::{EcdsaSignature, Multisig, Thresh};
use crate::keys::{DescriptorKey, IntoDescriptorKey};
use crate::wallet::signer::SignersContainer;
+ use alloc::{string::ToString, sync::Arc};
use assert_matches::assert_matches;
use bitcoin::secp256k1::Secp256k1;
use bitcoin::util::bip32;
use bitcoin::Network;
- use std::str::FromStr;
- use std::sync::Arc;
+ use core::str::FromStr;
const TPRV0_STR:&str = "tprv8ZgxMBicQKsPdZXrcHNLf5JAJWFAoJ2TrstMRdSKtEggz6PddbuSkvHKM9oKJyFgZV1B7rw8oChspxyYbtmEXYyg1AjfWbL3ho3XHDpHRZf";
const TPRV1_STR:&str = "tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcLNfjdi5qUvw3VDfgYiH5mNsj5izuiu2N";
.into_wallet_descriptor(&secp, Network::Testnet)
.unwrap();
let signers_container = Arc::new(SignersContainer::build(keymap, &wallet_desc, &secp));
- let policy = wallet_desc
+ let _policy = wallet_desc
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)
.unwrap()
.unwrap();
- println!("desc policy = {:?}", policy); // TODO remove
- // TODO how should this fail with mixed timelocks?
+ // println!("desc policy = {:?}", policy); // TODO remove
+ // TODO how should this fail with mixed timelocks?
}
// - multiple timelocks of the same type should be correctly merged together
.into_wallet_descriptor(&secp, Network::Testnet)
.unwrap();
let signers_container = Arc::new(SignersContainer::build(keymap, &wallet_desc, &secp));
- let policy = wallet_desc
+ let _policy = wallet_desc
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)
.unwrap()
.unwrap();
- println!("desc policy = {:?}", policy); // TODO remove
- // TODO how should this merge timelocks?
+ // println!("desc policy = {:?}", policy); // TODO remove
+ // TODO how should this merge timelocks?
let (prvkey1, _pubkey1, _fingerprint1) = setup_keys(TPRV0_STR, PATH, &secp);
let locktime_seconds0 = 500000100;
let locktime_seconds1 = 500000200;
.into_wallet_descriptor(&secp, Network::Testnet)
.unwrap();
let signers_container = Arc::new(SignersContainer::build(keymap, &wallet_desc, &secp));
- let policy = wallet_desc
+ let _policy = wallet_desc
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)
.unwrap()
.unwrap();
- println!("desc policy = {:?}", policy); // TODO remove
+ // println!("desc policy = {:?}", policy); // TODO remove
// TODO how should this merge timelocks?
}
keychain: KeychainKind,
network: Network,
) -> Result<impl IntoDescriptorKey<$ctx>, DescriptorError> {
- let mut derivation_path = Vec::with_capacity(4);
+ let mut derivation_path = alloc::vec::Vec::with_capacity(4);
derivation_path.push(bip32::ChildNumber::from_hardened_idx(bip)?);
match network {
mod test {
// test existing descriptor templates, make sure they are expanded to the right descriptors
- use std::str::FromStr;
+ use alloc::{string::ToString, vec::Vec};
+ use core::str::FromStr;
use super::*;
use crate::descriptor::{DescriptorError, DescriptorMeta};
// You may not use this file except in accordance with one or both of these
// licenses.
-use std::fmt;
-
use crate::bitcoin::Network;
use crate::{descriptor, wallet};
+use alloc::{string::String, vec::Vec};
use bitcoin::{OutPoint, Txid};
+use core::fmt;
/// Errors that can be thrown by the [`Wallet`](crate::wallet::Wallet)
#[derive(Debug)]
}
}
+#[cfg(feature = "std")]
impl std::error::Error for Error {}
macro_rules! impl_error {
impl_error!($from, $to, Error);
};
( $from:ty, $to:ident, $impl_for:ty ) => {
- impl std::convert::From<$from> for $impl_for {
+ impl core::convert::From<$from> for $impl_for {
fn from(err: $from) -> Self {
<$impl_for>::$to(err)
}
// TODO: maybe write our own implementation of bip39? Seems stupid to have an extra dependency for
// something that should be fairly simple to re-implement.
+use alloc::string::String;
use bitcoin::util::bip32;
use bitcoin::Network;
#[cfg(test)]
mod test {
- use std::str::FromStr;
+ use alloc::string::ToString;
+ use core::str::FromStr;
use bitcoin::util::bip32;
//! Key formats
-use std::any::TypeId;
-use std::collections::HashSet;
-use std::marker::PhantomData;
-use std::ops::Deref;
-use std::str::FromStr;
+use crate::collections::HashSet;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::any::TypeId;
+use core::marker::PhantomData;
+use core::ops::Deref;
+use core::str::FromStr;
use bitcoin::secp256k1::{self, Secp256k1, Signing};
///
/// ```compile_fail
/// use bdk::bitcoin::PublicKey;
-/// use std::str::FromStr;
+/// use core::str::FromStr;
///
/// use bdk::keys::{DescriptorKey, IntoDescriptorKey, KeyError};
///
/// Extra options required by the `generate_with_entropy`
type Options;
/// Returned error in case of failure
- type Error: std::fmt::Debug;
+ type Error: core::fmt::Debug;
/// Generate a key given the extra options and the entropy
fn generate_with_entropy(
}
}
+#[cfg(feature = "std")]
impl std::error::Error for KeyError {}
#[cfg(test)]
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// You may not use this file except in accordance with one or both of these
// licenses.
-
+//
// rustdoc will warn if there are missing docs
#![warn(missing_docs)]
// only enables the `doc_cfg` feature when
//! ## Sign a transaction
//!
//! ```no_run
-//! use std::str::FromStr;
+//! use core::str::FromStr;
//!
//! use bitcoin::util::psbt::PartiallySignedTransaction as Psbt;
//!
//! * `keys-bip39`: [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonic codes for generating deterministic keys
//!
+#![no_std]
+#[cfg(feature = "std")]
+#[macro_use]
+extern crate std;
+
+#[macro_use]
+extern crate alloc;
+
pub extern crate bitcoin;
#[cfg(feature = "hardware-signer")]
pub extern crate hwi;
}
pub use bdk_chain as chain;
+pub(crate) use bdk_chain::collections;
//! Additional functions on the `rust-bitcoin` `PartiallySignedTransaction` structure.
use crate::FeeRate;
+use alloc::vec::Vec;
use bitcoin::util::psbt::PartiallySignedTransaction as Psbt;
use bitcoin::TxOut;
use crate::wallet::AddressIndex;
use crate::wallet::AddressIndex::New;
use crate::{psbt, FeeRate, SignOptions};
- use std::str::FromStr;
+ use core::str::FromStr;
// from bip 174
const PSBT_STR: &str = "cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA";
// You may not use this file except in accordance with one or both of these
// licenses.
-use std::convert::AsRef;
-use std::ops::Sub;
+use alloc::boxed::Box;
+use core::convert::AsRef;
+use core::ops::Sub;
use bdk_chain::ConfirmationTime;
use bitcoin::blockdata::transaction::{OutPoint, Transaction, TxOut};
}
}
-impl std::default::Default for FeeRate {
+impl Default for FeeRate {
fn default() -> Self {
FeeRate::default_min_relay_fee()
}
}
impl PartialOrd for TransactionDetails {
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for TransactionDetails {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.confirmation_time
.cmp(&other.confirmation_time)
.then_with(|| self.txid.cmp(&other.txid))
}
}
-impl std::fmt::Display for Balance {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl core::fmt::Display for Balance {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(
f,
"{{ immature: {}, trusted_pending: {}, untrusted_pending: {}, confirmed: {} }}",
}
}
-impl std::ops::Add for Balance {
+impl core::ops::Add for Balance {
type Output = Self;
fn add(self, other: Self) -> Self {
}
}
-impl std::iter::Sum for Balance {
+impl core::iter::Sum for Balance {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(
Balance {
use crate::WeightedUtxo;
use crate::{error::Error, Utxo};
+use alloc::vec::Vec;
use bitcoin::consensus::encode::serialize;
use bitcoin::Script;
#[cfg(test)]
use assert_matches::assert_matches;
+use core::convert::TryInto;
use rand::seq::SliceRandom;
#[cfg(not(test))]
use rand::thread_rng;
-#[cfg(test)]
-use std::convert::TryInto;
/// Default coin selection algorithm used by [`TxBuilder`](super::tx_builder::TxBuilder) if not
/// overridden
/// selection algorithm when it creates transactions.
///
/// For an example see [this module](crate::wallet::coin_selection)'s documentation.
-pub trait CoinSelectionAlgorithm: std::fmt::Debug {
+pub trait CoinSelectionAlgorithm: core::fmt::Debug {
/// Perform the coin selection
///
/// - `database`: a reference to the wallet's database that can be used to lookup additional
#[cfg(test)]
mod test {
- use std::str::FromStr;
+ use core::str::FromStr;
use bdk_chain::ConfirmationTime;
use bitcoin::{OutPoint, Script, TxOut};
//! # Ok::<_, bdk::Error>(())
//! ```
-use std::str::FromStr;
+use core::str::FromStr;
+use alloc::string::{String, ToString};
use bdk_chain::sparse_chain::ChainPosition;
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod test {
- use std::str::FromStr;
+ use core::str::FromStr;
use bdk_chain::{BlockId, ConfirmationTime};
use bitcoin::hashes::Hash;
//! Wallet
//!
//! This module defines the [`Wallet`] structure.
-use bdk_chain::chain_graph;
-use bdk_chain::{keychain::KeychainTracker, sparse_chain, BlockId, ConfirmationTime};
+use crate::collections::{BTreeMap, HashMap, HashSet};
+use alloc::{
+ boxed::Box,
+ string::{String, ToString},
+ sync::Arc,
+ vec::Vec,
+};
+use bdk_chain::{keychain::KeychainTracker, sparse_chain, BlockId, ConfirmationTime, chain_graph};
use bitcoin::secp256k1::Secp256k1;
+use core::fmt;
+use core::ops::Deref;
use core::convert::TryInto;
-use std::collections::{BTreeMap, HashMap, HashSet};
-use std::fmt;
-use std::ops::Deref;
-use std::sync::Arc;
use bitcoin::consensus::encode::serialize;
use bitcoin::util::psbt;
/// [`TxBuilder`]: crate::TxBuilder
pub fn build_tx(&mut self) -> TxBuilder<'_, DefaultCoinSelectionAlgorithm, CreateTx> {
TxBuilder {
- wallet: std::rc::Rc::new(core::cell::RefCell::new(self)),
+ wallet: alloc::rc::Rc::new(core::cell::RefCell::new(self)),
params: TxParams::default(),
coin_selection: DefaultCoinSelectionAlgorithm::default(),
phantom: core::marker::PhantomData,
};
Ok(TxBuilder {
- wallet: std::rc::Rc::new(std::cell::RefCell::new(self)),
+ wallet: alloc::rc::Rc::new(core::cell::RefCell::new(self)),
params,
coin_selection: DefaultCoinSelectionAlgorithm::default(),
phantom: core::marker::PhantomData,
macro_rules! from_str {
($e:expr, $t:ty) => {{
- use std::str::FromStr;
+ use core::str::FromStr;
<$t>::from_str($e).unwrap()
}};
#[test]
fn test_create_tx_input_hd_keypaths() {
use bitcoin::util::bip32::{DerivationPath, Fingerprint};
- use std::str::FromStr;
+ use core::str::FromStr;
let (mut wallet, _) = get_funded_wallet("wpkh([d34db33f/44'/0'/0']tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)");
let addr = wallet.get_address(New);
#[test]
fn test_create_tx_output_hd_keypaths() {
use bitcoin::util::bip32::{DerivationPath, Fingerprint};
- use std::str::FromStr;
+ use core::str::FromStr;
let (mut wallet, _) = get_funded_wallet("wpkh([d34db33f/44'/0'/0']tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)");
#[test]
fn test_get_address_no_reuse_single_descriptor() {
+ use crate::collections::HashSet;
use crate::descriptor::template::Bip84;
- use std::collections::HashSet;
let key = bitcoin::util::bip32::ExtendedPrivKey::from_str("tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy").unwrap();
let mut wallet =
//! through the [`Wallet::add_signer`](super::Wallet::add_signer) function.
//!
//! ```
-//! # use std::sync::Arc;
-//! # use std::str::FromStr;
+//! # use alloc::sync::Arc;
+//! # use core::str::FromStr;
//! # use bitcoin::secp256k1::{Secp256k1, All};
//! # use bitcoin::*;
//! # use bitcoin::util::psbt;
//! # Ok::<_, bdk::Error>(())
//! ```
-use std::cmp::Ordering;
-use std::collections::BTreeMap;
-use std::fmt;
-use std::ops::{Bound::Included, Deref};
-use std::sync::Arc;
+use crate::collections::BTreeMap;
+use alloc::sync::Arc;
+use alloc::vec::Vec;
+use core::cmp::Ordering;
+use core::fmt;
+use core::ops::{Bound::Included, Deref};
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::script::Builder as ScriptBuilder;
}
}
+#[cfg(feature = "std")]
impl std::error::Error for SignerError {}
/// Signing context
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq)]
pub struct SignerOrdering(pub usize);
-impl std::default::Default for SignerOrdering {
+impl Default for SignerOrdering {
fn default() -> Self {
SignerOrdering(100)
}
use bitcoin::secp256k1::{All, Secp256k1};
use bitcoin::util::bip32;
use bitcoin::Network;
+ use core::str::FromStr;
use miniscript::ScriptContext;
- use std::str::FromStr;
fn is_equal(this: &Arc<dyn TransactionSigner>, that: &Arc<DummySigner>) -> bool {
let secp = Secp256k1::new();
//! # Ok::<(), bdk::Error>(())
//! ```
-use std::cell::RefCell;
-use std::collections::BTreeMap;
-use std::collections::HashSet;
-use std::default::Default;
-use std::marker::PhantomData;
-use std::rc::Rc;
+use crate::collections::BTreeMap;
+use crate::collections::HashSet;
+use alloc::{boxed::Box, rc::Rc, string::String, vec::Vec};
+use core::cell::RefCell;
+use core::marker::PhantomData;
use bitcoin::util::psbt::{self, PartiallySignedTransaction as Psbt};
use bitcoin::{LockTime, OutPoint, Script, Sequence, Transaction};
};
use crate::{Error, Utxo, Wallet};
/// Context in which the [`TxBuilder`] is valid
-pub trait TxBuilderContext: std::fmt::Debug + Default + Clone {}
+pub trait TxBuilderContext: core::fmt::Debug + Default + Clone {}
/// Marker type to indicate the [`TxBuilder`] is being used to create a new transaction (as opposed
/// to bumping the fee of an existing one).
FeeAmount(u64),
}
-impl std::default::Default for FeePolicy {
+impl Default for FeePolicy {
fn default() -> Self {
FeePolicy::FeeRate(FeeRate::default_min_relay_fee())
}
#[test]
fn test_output_ordering_bip69() {
- use std::str::FromStr;
+ use core::str::FromStr;
let original_tx = ordering_test_tx!();
let mut tx = original_tx;
use super::{check_nsequence_rbf, IsDust};
use crate::bitcoin::{Address, Sequence};
- use std::str::FromStr;
+ use core::str::FromStr;
#[test]
fn test_is_dust() {