strategy:
matrix:
rust:
- - version: 1.65.0 # STABLE
+ - version: stable
clippy: true
- - version: 1.57.0 # MSRV
+ - version: 1.63.0 # MSRV
features:
- default
- minimal
- name: Update toolchain
run: rustup update
- name: Pin dependencies for MSRV
- if: matrix.rust.version == '1.57.0'
+ if: matrix.rust.version == '1.63.0'
run: |
- cargo update -p log --precise "0.4.18"
- cargo update -p tempfile --precise "3.6.0"
- cargo update -p hashlink --precise "0.8.1"
cargo update -p regex --precise "1.7.3"
- cargo update -p zip:0.6.6 --precise "0.6.3"
- cargo update -p rustix --precise "0.37.23"
- cargo update -p tokio --precise "1.29.1"
- cargo update -p tokio-util --precise "0.7.8"
- cargo update -p cc --precise "1.0.81"
- cargo update -p rustls:0.20.9 --precise "0.20.8"
- cargo update -p rustls:0.21.7 --precise "0.21.1"
- cargo update -p flate2:1.0.27 --precise "1.0.26"
- cargo update -p reqwest --precise "0.11.18"
- cargo update -p h2 --precise "0.3.20"
- cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
- cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
- cargo update -p byteorder --precise "1.4.3"
- cargo update -p webpki --precise "0.22.2"
+ cargo update -p home --precise "0.5.5"
- name: Build
- run: cargo build --features ${{ matrix.features }} --no-default-features
+ run: cargo build --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features
- name: Clippy
if: ${{ matrix.rust.clippy }}
- run: cargo clippy --all-targets --features ${{ matrix.features }} --no-default-features -- -D warnings
+ run: cargo clippy --all-targets --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features -- -D warnings
- name: Test
- run: cargo test --features ${{ matrix.features }} --no-default-features
+ run: cargo test --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features
test-readme-examples:
name: Test README.md examples
- name: Update toolchain
run: rustup update
- name: Test
- run: cargo test --features test-md-docs --no-default-features -- doctest::ReadmeDoctests
+ run: cargo test --features bitcoin/std,miniscript/std,test-md-docs --no-default-features -- doctest::ReadmeDoctests
test-blockchains:
name: Blockchain ${{ matrix.blockchain.features }}
blockchain:
- name: electrum
testprefix: blockchain::electrum::test
- features: test-electrum,verify
+ features: test-electrum,verify,bitcoin/std,miniscript/std
- name: rpc
testprefix: blockchain::rpc::test
- features: test-rpc
+ features: test-rpc,bitcoin/std,miniscript/std
- name: rpc-legacy
testprefix: blockchain::rpc::test
- features: test-rpc-legacy
+ features: test-rpc-legacy,bitcoin/std,miniscript/std
- name: esplora
testprefix: esplora
- features: test-esplora,use-esplora-async,verify
+ features: test-esplora,use-esplora-async,verify,bitcoin/std,miniscript/std
- name: esplora
testprefix: esplora
- features: test-esplora,use-esplora-blocking,verify
+ features: test-esplora,use-esplora-blocking,verify,bitcoin/std,miniscript/std
steps:
- name: Checkout
uses: actions/checkout@v2
toolchain: stable
override: true
- name: Test
- run: cargo test --no-default-features --features ${{ matrix.blockchain.features }} ${{ matrix.blockchain.testprefix }}::bdk_blockchain_tests
+ run: cargo test --no-default-features --features bitcoin/std,miniscript/std,${{ matrix.blockchain.features }} ${{ matrix.blockchain.testprefix }}::bdk_blockchain_tests
check-wasm:
name: Check WASM
- run: sudo apt-get update || exit 1
- run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1
- name: Set default toolchain
- run: rustup default 1.65.0 # STABLE
+ run: rustup default stable
- name: Set profile
run: rustup set profile minimal
- name: Add target wasm32
- name: Update toolchain
run: rustup update
- name: Check
- run: cargo check --target wasm32-unknown-unknown --features async-interface,use-esplora-async,dev-getrandom-wasm --no-default-features
+ run: cargo check --target wasm32-unknown-unknown --features bitcoin/no-std,miniscript/no-std,async-interface,use-esplora-async,dev-getrandom-wasm --no-default-features
fmt:
name: Rust fmt
strategy:
matrix:
rust:
- - version: 1.65.0 # STABLE
- - version: 1.57.0 # MSRV
+ - version: stable
+ - version: 1.63.0 # MSRV
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update toolchain
run: rustup update
- name: Pin dependencies for MSRV
- if: matrix.rust.version == '1.57.0'
+ if: matrix.rust.version == '1.63.0'
run: |
- cargo update -p log --precise "0.4.18"
- cargo update -p tempfile --precise "3.6.0"
- cargo update -p hashlink --precise "0.8.1"
- cargo update -p regex --precise "1.7.3"
- cargo update -p zip:0.6.6 --precise "0.6.3"
- cargo update -p rustix --precise "0.37.23"
- cargo update -p tokio --precise "1.29.1"
- cargo update -p tokio-util --precise "0.7.8"
- cargo update -p cc --precise "1.0.81"
- cargo update -p rustls:0.20.9 --precise "0.20.8"
- cargo update -p rustls:0.21.7 --precise "0.21.1"
- cargo update -p flate2:1.0.27 --precise "1.0.26"
- cargo update -p reqwest --precise "0.11.18"
- cargo update -p h2 --precise "0.3.20"
- cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
- cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
- cargo update -p byteorder --precise "1.4.3"
- cargo update -p webpki --precise "0.22.2"
+ cargo update -p regex --precise "1.7.3"
+ cargo update -p home --precise "0.5.5"
- name: Test
run: cargo test --features test-hardware-signer
[package]
name = "bdk"
-version = "0.29.0"
-edition = "2018"
+version = "0.30.0"
authors = ["Alekos Filini <alekos.filini@gmail.com>", "Riccardo Casatta <riccardo@casatta.it>"]
homepage = "https://bitcoindevkit.org"
repository = "https://github.com/bitcoindevkit/bdk"
keywords = ["bitcoin", "wallet", "descriptor", "psbt"]
readme = "README.md"
license = "MIT OR Apache-2.0"
+edition = "2021"
+rust-version = "1.63"
[dependencies]
bdk-macros = "^0.6"
sled = { version = "0.34", optional = true }
electrum-client = { version = "0.18", optional = true }
esplora-client = { version = "0.6", default-features = false, optional = true }
-rusqlite = { version = "0.28.0", optional = true }
-ahash = { version = "0.7.6", optional = true }
+rusqlite = { version = "0.27.0", optional = true }
futures = { version = "0.3", optional = true }
async-trait = { version = "0.1", optional = true }
-rocksdb = { version = "0.14", default-features = false, features = ["snappy"], optional = true }
+rocksdb = { version = "0.18", default-features = false, features = ["snappy"], optional = true }
cc = { version = ">=1.0.64", optional = true }
socks = { version = "0.3", optional = true }
hwi = { version = "0.7", optional = true, features = ["miniscript"] }
# std feature is always required unless building for wasm32-unknown-unknown target
# if building for wasm user must add dependencies bitcoin/no-std,miniscript/no-std
std = ["bitcoin/std", "miniscript/std"]
-sqlite = ["rusqlite", "ahash"]
+sqlite = ["rusqlite"]
sqlite-bundled = ["sqlite", "rusqlite/bundled"]
compact_filters = ["rocksdb", "socks", "cc"]
key-value-db = ["sled"]
<a href="https://github.com/bitcoindevkit/bdk/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk/workflows/CI/badge.svg"></a>
<a href="https://coveralls.io/github/bitcoindevkit/bdk?branch=master"><img src="https://coveralls.io/repos/github/bitcoindevkit/bdk/badge.svg?branch=master"/></a>
<a href="https://docs.rs/bdk"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bdk-green"/></a>
- <a href="https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html"><img alt="Rustc Version 1.57.0+" src="https://img.shields.io/badge/rustc-1.57.0%2B-lightgrey.svg"/></a>
+ <a href="https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html"><img alt="Rustc Version 1.63.0+" src="https://img.shields.io/badge/rustc-1.63.0%2B-lightgrey.svg"/></a>
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
</p>
## Minimum Supported Rust Version (MSRV)
-This library should compile with any combination of features with Rust 1.57.0.
+This library should compile with any combination of features with Rust 1.63.0.
To build with the MSRV you will need to pin dependencies as follows:
```shell
-# log 0.4.19 has MSRV 1.60.0
-cargo update -p log --precise "0.4.18"
-# tempfile 3.7.0 has MSRV 1.63.0
-cargo update -p tempfile --precise "3.6.0"
-# required for sqlite feature, hashlink 0.8.2 has MSRV 1.61.0
-cargo update -p hashlink --precise "0.8.1"
-# required for compact_filters feature, regex after 1.7.3 has MSRV 1.60.0
cargo update -p regex --precise "1.7.3"
-# zip 0.6.3 has MSRV 1.59.0 but still works
-cargo update -p zip:0.6.6 --precise "0.6.3"
-# rustix 0.38.0 has MSRV 1.65.0
-cargo update -p rustix --precise "0.37.23"
-# tokio 1.30 has MSRV 1.63.0+
-cargo update -p tokio --precise "1.29.1"
-# tokio-util 0.7.9 doesn't build with MSRV 1.57.0
-cargo update -p tokio-util --precise "0.7.8"
-# cc 1.0.82 is throwing error with rust 1.57.0, "error[E0599]: no method named `retain_mut`..."
-cargo update -p cc --precise "1.0.81"
-# rustls 0.20.9 has MSRV 1.60.0+
-cargo update -p rustls:0.20.9 --precise "0.20.8"
-# rustls 0.21.2 has MSRV 1.60.0+
-cargo update -p rustls:0.21.7 --precise "0.21.1"
-# flate2 1.0.27 has MSRV 1.63.0+
-cargo update -p flate2:1.0.27 --precise "1.0.26"
-# reqwest 0.11.19 has MSRV 1.63.0+
-cargo update -p reqwest --precise "0.11.18"
-# h2 0.3.21 has MSRV 1.63.0+
-cargo update -p h2 --precise "0.3.20"
-# rustls-webpki 0.100.2 has MSRV 1.60+
-cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
-# rustls-webpki 0.101.6 has MSRV 1.60+
-cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
-# byteorder 1.5.0 has MSRV 1.60.0+
-cargo update -p byteorder --precise "1.4.3"
-# webpki 0.22.4 requires `ring:0.17.2` which has MSRV 1.61.0+
-cargo update -p webpki --precise "0.22.2"
+cargo update -p home --precise "0.5.5"
```
--- /dev/null
+msrv="1.63.0"
\ No newline at end of file
let descriptor = "wpkh(tpubD6NzVbkrYhZ4X2yy78HWrr1M9NT8dKeWfzNiQqDdMqqa9UmmGztGGz6TaLFGsLfdft5iu32gxq1T4eMNxExNNWzVCpf9Y6JZi5TnqoC9wJq/*)";
let database = MemoryDatabase::default();
- let wallet = Arc::new(Wallet::new(descriptor, None, Network::Testnet, database).unwrap());
+ let wallet = Wallet::new(descriptor, None, Network::Testnet, database).unwrap();
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
info!("balance: {}", wallet.get_balance()?);
Ok(())
let filters = cf_filters
.into_iter()
.enumerate()
- .chain(filters_map.into_iter())
+ .chain(filters_map)
.collect();
status = self
.cf_store
let needs_block_height = conftime_req
.request()
.filter_map(|txid| txid_to_height.get(txid).cloned())
- .filter(|height| block_times.get(height).is_none())
+ .filter(|height| block_times.contains_key(height))
.take(chunk_size)
.collect::<HashSet<u32>>();
fn save_txs<'c>(&mut self, txids: impl Iterator<Item = &'c Txid>) -> Result<(), Error> {
let mut need_fetch = vec![];
for txid in txids {
- if self.cache.get(txid).is_some() {
+ if self.cache.contains_key(txid) {
continue;
} else if let Some(transaction) = self.db.get_raw_tx(txid)? {
self.cache.insert(*txid, transaction);
}
fn get(&self, txid: Txid) -> Option<Transaction> {
- self.cache.get(&txid).map(Clone::clone)
+ self.cache.get(&txid).cloned()
}
}
txout: output.clone(),
keychain,
// Is this UTXO in the spent_utxos set?
- is_spent: spent_utxos.get(&outpoint).is_some(),
+ is_spent: spent_utxos.contains(&outpoint),
})?;
}
}
}
utxo_index
- .into_iter()
- .map(|(_, tx)| (tx.txid, tx))
+ .into_values()
+ .map(|tx| (tx.txid, tx))
.collect::<HashMap<_, _>>()
- .into_iter()
- .map(|(_, tx)| tx)
+ .into_values()
.chain(coinbase_txs)
.collect()
}
.map(|o| o.is_some())
}
+ #[allow(unused)]
fn get_raw_tx_or<D>(&self, txid: &Txid, default: D) -> Result<Option<Transaction>, Error>
where
D: FnOnce() -> Result<Option<Transaction>, Error>,
fn is_witness(&self) -> bool;
fn is_taproot(&self) -> bool;
fn get_extended_keys(&self) -> Result<Vec<DescriptorXKey<ExtendedPubKey>>, DescriptorError>;
- fn derive_from_hd_keypaths<'s>(
+ fn derive_from_hd_keypaths(
&self,
hd_keypaths: &HdKeyPaths,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor>;
- fn derive_from_tap_key_origins<'s>(
+ fn derive_from_tap_key_origins(
&self,
tap_key_origins: &TapKeyOrigins,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor>;
- fn derive_from_psbt_key_origins<'s>(
+ fn derive_from_psbt_key_origins(
&self,
key_origins: BTreeMap<Fingerprint, (&DerivationPath, SinglePubKey)>,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor>;
- fn derive_from_psbt_input<'s>(
+ fn derive_from_psbt_input(
&self,
psbt_input: &psbt::Input,
utxo: Option<TxOut>,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor>;
}
Ok(answer)
}
- fn derive_from_psbt_key_origins<'s>(
+ fn derive_from_psbt_key_origins(
&self,
key_origins: BTreeMap<Fingerprint, (&DerivationPath, SinglePubKey)>,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor> {
// Ensure that deriving `xpub` with `path` yields `expected`
let verify_key = |xpub: &DescriptorXKey<ExtendedPubKey>,
})
}
- fn derive_from_hd_keypaths<'s>(
+ fn derive_from_hd_keypaths(
&self,
hd_keypaths: &HdKeyPaths,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor> {
// "Convert" an hd_keypaths map to the format required by `derive_from_psbt_key_origins`
let key_origins = hd_keypaths
self.derive_from_psbt_key_origins(key_origins, secp)
}
- fn derive_from_tap_key_origins<'s>(
+ fn derive_from_tap_key_origins(
&self,
tap_key_origins: &TapKeyOrigins,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor> {
// "Convert" a tap_key_origins map to the format required by `derive_from_psbt_key_origins`
let key_origins = tap_key_origins
self.derive_from_psbt_key_origins(key_origins, secp)
}
- fn derive_from_psbt_input<'s>(
+ fn derive_from_psbt_input(
&self,
psbt_input: &psbt::Input,
utxo: Option<TxOut>,
- secp: &'s SecpCtx,
+ secp: &SecpCtx,
) -> Option<DerivedDescriptor> {
if let Some(derived) = self.derive_from_hd_keypaths(&psbt_input.bip32_derivation, secp) {
return Some(derived);
if let ExtendedDescriptor::Pkh(pkh) = xdesc.0 {
let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
- let purpose = path.get(0).unwrap();
+ let purpose = path.first().unwrap();
assert_matches!(purpose, Hardened { index: 44 });
let coin_type = path.get(1).unwrap();
assert_matches!(coin_type, Hardened { index: 0 });
if let ExtendedDescriptor::Pkh(pkh) = tdesc.0 {
let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
- let purpose = path.get(0).unwrap();
+ let purpose = path.first().unwrap();
assert_matches!(purpose, Hardened { index: 44 });
let coin_type = path.get(1).unwrap();
assert_matches!(coin_type, Hardened { index: 1 });
let (key_map, valid_networks) = key_maps_networks.into_iter().fold(
(KeyMap::default(), any_network()),
|(mut keys_acc, net_acc), (key, net)| {
- keys_acc.extend(key.into_iter());
+ keys_acc.extend(key);
let net_acc = merge_networks(&net_acc, &net);
(keys_acc, net_acc)
#[cfg(feature = "hardware-signer")]
pub extern crate hwi;
-#[cfg(all(feature = "reqwest", feature = "ureq"))]
-compile_error!("Features reqwest and ureq are mutually exclusive and cannot be enabled together");
+#[cfg(all(feature = "use-esplora-async", feature = "use-esplora-blocking"))]
+compile_error!("Features use-esplora-async and use-esplora-blocking are mutually exclusive and cannot be enabled together");
#[cfg(all(feature = "async-interface", feature = "electrum"))]
compile_error!(
"Features async-interface and electrum are mutually exclusive and cannot be enabled together"
);
-#[cfg(all(feature = "async-interface", feature = "ureq"))]
+#[cfg(all(feature = "async-interface", feature = "use-esplora-blocking"))]
compile_error!(
"Features async-interface and ureq are mutually exclusive and cannot be enabled together"
);
.iter()
.map(|wu| wu.utxo.outpoint().txid)
// fold is used so we can skip db query for txid that already exist in hashmap acc
- .fold(Ok(HashMap::new()), |bh_result_acc, txid| {
- bh_result_acc.and_then(|mut bh_acc| {
- if bh_acc.contains_key(&txid) {
- Ok(bh_acc)
- } else {
- database.get_tx(&txid, false).map(|details| {
- bh_acc.insert(
- txid,
- details.and_then(|d| d.confirmation_time.map(|ct| ct.height)),
- );
- bh_acc
- })
- }
- })
+ .try_fold(HashMap::new(), |mut bh_acc, txid| {
+ if bh_acc.contains_key(&txid) {
+ Ok(bh_acc)
+ } else {
+ database.get_tx(&txid, false).map(|details| {
+ bh_acc.insert(
+ txid,
+ details.and_then(|d| d.confirmation_time.map(|ct| ct.height)),
+ );
+ bh_acc
+ })
+ }
})?;
// We put the "required UTXOs" first and make sure the optional UTXOs are sorted from
}
fn get_test_utxos() -> Vec<WeightedUtxo> {
- vec![
- utxo(100_000, 0),
- utxo(FEE_AMOUNT as u64 - 40, 1),
- utxo(200_000, 2),
- ]
+ vec![utxo(100_000, 0), utxo(FEE_AMOUNT - 40, 1), utxo(200_000, 2)]
}
fn setup_database_and_get_oldest_first_test_utxos<D: Database>(
let drain_script = ScriptBuf::default();
let target_amount = 250_000 + FEE_AMOUNT;
- let result = LargestFirstCoinSelection::default()
+ let result = LargestFirstCoinSelection
.coin_select(
&database,
utxos,
let drain_script = ScriptBuf::default();
let target_amount = 20_000 + FEE_AMOUNT;
- let result = LargestFirstCoinSelection::default()
+ let result = LargestFirstCoinSelection
.coin_select(
&database,
utxos,
let drain_script = ScriptBuf::default();
let target_amount = 20_000 + FEE_AMOUNT;
- let result = LargestFirstCoinSelection::default()
+ let result = LargestFirstCoinSelection
.coin_select(
&database,
vec![],
let drain_script = ScriptBuf::default();
let target_amount = 500_000 + FEE_AMOUNT;
- LargestFirstCoinSelection::default()
+ LargestFirstCoinSelection
.coin_select(
&database,
vec![],
let drain_script = ScriptBuf::default();
let target_amount = 250_000 + FEE_AMOUNT;
- LargestFirstCoinSelection::default()
+ LargestFirstCoinSelection
.coin_select(
&database,
vec![],
let drain_script = ScriptBuf::default();
let target_amount = 180_000 + FEE_AMOUNT;
- let result = OldestFirstCoinSelection::default()
+ let result = OldestFirstCoinSelection
.coin_select(
&database,
vec![],
let target_amount = 180_000 + FEE_AMOUNT;
- let result = OldestFirstCoinSelection::default()
+ let result = OldestFirstCoinSelection
.coin_select(
&database,
vec![],
let drain_script = ScriptBuf::default();
let target_amount = 20_000 + FEE_AMOUNT;
- let result = OldestFirstCoinSelection::default()
+ let result = OldestFirstCoinSelection
.coin_select(
&database,
utxos,
let drain_script = ScriptBuf::default();
let target_amount = 20_000 + FEE_AMOUNT;
- let result = OldestFirstCoinSelection::default()
+ let result = OldestFirstCoinSelection
.coin_select(
&database,
vec![],
let drain_script = ScriptBuf::default();
let target_amount = 600_000 + FEE_AMOUNT;
- OldestFirstCoinSelection::default()
+ OldestFirstCoinSelection
.coin_select(
&database,
vec![],
let target_amount: u64 = utxos.iter().map(|wu| wu.utxo.txout().value).sum::<u64>() - 50;
let drain_script = ScriptBuf::default();
- OldestFirstCoinSelection::default()
+ OldestFirstCoinSelection
.coin_select(
&database,
vec![],
//! # Ok::<_, bdk::Error>(())
//! ```
+use std::fmt::{Display, Formatter};
use std::str::FromStr;
use serde::{Deserialize, Serialize};
pub label: String,
}
-impl ToString for FullyNodedExport {
- fn to_string(&self) -> String {
- serde_json::to_string(self).unwrap()
+impl Display for FullyNodedExport {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", serde_json::to_string(self).unwrap())
}
}
.database
.borrow_mut()
.set_script_pubkey(
- &bitcoin::Address::from_str(&tx_meta.output.get(0).unwrap().to_address)
+ &bitcoin::Address::from_str(&tx_meta.output.first().unwrap().to_address)
.unwrap()
.assume_checked()
.script_pubkey(),
.values()
.map(|(script, version)| TapLeafHash::from_script(script, *version))
.collect();
- let included_script_leaves = vec![script_leaves.pop().unwrap()];
+ let included_script_leaves = [script_leaves.pop().unwrap()];
let excluded_script_leaves = script_leaves;
assert!(
}
/// Customize which taproot script-path leaves the signer should sign.
-#[derive(Debug, Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub enum TapLeavesOptions {
/// The signer will sign all the leaves it has a key for.
+ #[default]
All,
/// The signer won't sign leaves other than the ones specified. Note that it could still ignore
/// some of the specified leaves, if it doesn't have the right key to sign them.
None,
}
-impl Default for TapLeavesOptions {
- fn default() -> Self {
- TapLeavesOptions::All
- }
-}
-
#[allow(clippy::derivable_impls)]
impl Default for SignOptions {
fn default() -> Self {
///
/// This will be used to:
/// 1. Set the nLockTime for preventing fee sniping.
- /// **Note**: This will be ignored if you manually specify a nlocktime using [`TxBuilder::nlocktime`].
+ /// **Note**: This will be ignored if you manually specify a nlocktime using [`TxBuilder::nlocktime`].
/// 2. Decide whether coinbase outputs are mature or not. If the coinbase outputs are not
/// mature at `current_height`, we ignore them in the coin selection.
/// If you want to create a transaction that spends immature coinbase inputs, manually
}
/// Ordering of the transaction's inputs and outputs
-#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
+#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy, Default)]
pub enum TxOrdering {
/// Randomized (default)
+ #[default]
Shuffle,
/// Unchanged
Untouched,
Bip69Lexicographic,
}
-impl Default for TxOrdering {
- fn default() -> Self {
- TxOrdering::Shuffle
- }
-}
-
impl TxOrdering {
/// Sort transaction inputs and outputs by [`TxOrdering`] variant
pub fn sort_tx(&self, tx: &mut Transaction) {
}
/// Policy regarding the use of change outputs when creating a transaction
-#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
+#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy, Default)]
pub enum ChangeSpendPolicy {
/// Use both change and non-change outputs (default)
+ #[default]
ChangeAllowed,
/// Only use change outputs (see [`TxBuilder::only_spend_change`])
OnlyChange,
ChangeForbidden,
}
-impl Default for ChangeSpendPolicy {
- fn default() -> Self {
- ChangeSpendPolicy::ChangeAllowed
- }
-}
-
impl ChangeSpendPolicy {
pub(crate) fn is_satisfied_by(&self, utxo: &LocalUtxo) -> bool {
match self {