From eb5b21bd9324e6d2c725b1ae9360cfbe3c17816e Mon Sep 17 00:00:00 2001 From: Borja Castellano Date: Wed, 11 Mar 2026 20:39:08 +0000 Subject: [PATCH] drop no-std supp for key-wallet --- key-wallet-ffi/Cargo.toml | 4 ++-- key-wallet-manager/Cargo.toml | 4 ++-- key-wallet-manager/src/wallet_manager/mod.rs | 3 +-- .../src/wallet_manager/process_block.rs | 3 ++- key-wallet/Cargo.toml | 3 +-- key-wallet/src/account/account_collection.rs | 4 ++-- key-wallet/src/account/account_trait.rs | 1 - key-wallet/src/account/bls_account.rs | 1 - key-wallet/src/account/eddsa_account.rs | 1 - key-wallet/src/bip32.rs | 6 ------ key-wallet/src/bip38.rs | 2 -- key-wallet/src/derivation.rs | 1 - key-wallet/src/derivation_bls_bip32.rs | 6 +----- key-wallet/src/derivation_slip10.rs | 6 +----- key-wallet/src/error.rs | 3 --- key-wallet/src/lib.rs | 8 ------- .../src/managed_account/address_pool.rs | 2 -- .../managed_account_collection.rs | 4 ++-- .../managed_account/managed_account_trait.rs | 3 ++- .../managed_platform_account.rs | 19 ++++++----------- key-wallet/src/managed_account/metadata.rs | 2 -- key-wallet/src/managed_account/mod.rs | 17 +++++---------- .../src/managed_account/transaction_record.rs | 1 - key-wallet/src/mnemonic.rs | 8 ------- key-wallet/src/psbt/error.rs | 1 - key-wallet/src/psbt/map/global.rs | 4 +--- key-wallet/src/psbt/map/input.rs | 4 +--- key-wallet/src/psbt/map/mod.rs | 1 - key-wallet/src/psbt/map/output.rs | 4 +--- key-wallet/src/psbt/mod.rs | 21 +++---------------- key-wallet/src/psbt/raw.rs | 1 - key-wallet/src/psbt/serialize.rs | 2 -- key-wallet/src/seed.rs | 2 -- key-wallet/src/tests/wallet_tests.rs | 1 - .../transaction_checking/account_checker.rs | 5 +++-- key-wallet/src/wallet/bip38.rs | 3 --- key-wallet/src/wallet/helper.rs | 1 - key-wallet/src/wallet/initialization.rs | 1 - .../managed_wallet_info/coin_selection.rs | 2 -- .../src/wallet/managed_wallet_info/helpers.rs | 1 - .../src/wallet/managed_wallet_info/mod.rs | 1 - .../transaction_builder.rs | 2 -- .../wallet_info_interface.rs | 5 +++-- key-wallet/src/wallet/metadata.rs | 4 ++-- key-wallet/src/wallet/mod.rs | 1 - key-wallet/src/wallet/root_extended_keys.rs | 3 ++- 46 files changed, 43 insertions(+), 139 deletions(-) diff --git a/key-wallet-ffi/Cargo.toml b/key-wallet-ffi/Cargo.toml index e44a9a787..f60238279 100644 --- a/key-wallet-ffi/Cargo.toml +++ b/key-wallet-ffi/Cargo.toml @@ -20,7 +20,7 @@ eddsa = ["dashcore/eddsa", "key-wallet/eddsa"] bls = ["dashcore/bls", "key-wallet/bls"] [dependencies] -key-wallet = { path = "../key-wallet", default-features = false, features = ["std"] } +key-wallet = { path = "../key-wallet" } key-wallet-manager = { path = "../key-wallet-manager", features = ["std"] } dashcore = { path = "../dash" } secp256k1 = { version = "0.30.0", features = ["global-context"] } @@ -32,6 +32,6 @@ hex = "0.4" cbindgen = "0.29" [dev-dependencies] -key-wallet = { path = "../key-wallet", default-features = false, features = ["std", "test-utils"] } +key-wallet = { path = "../key-wallet", features = ["test-utils"] } tempfile = "3.0" hex = "0.4" diff --git a/key-wallet-manager/Cargo.toml b/key-wallet-manager/Cargo.toml index d588e21a0..02016a8fc 100644 --- a/key-wallet-manager/Cargo.toml +++ b/key-wallet-manager/Cargo.toml @@ -10,14 +10,14 @@ license = "CC0-1.0" [features] default = ["std", "bincode"] -std = ["key-wallet/std", "secp256k1/std"] +std = ["secp256k1/std"] serde = ["dep:serde", "key-wallet/serde", "dashcore/serde"] getrandom = ["key-wallet/getrandom"] bincode = ["dep:bincode", "key-wallet/bincode"] test-utils = [] [dependencies] -key-wallet = { path = "../key-wallet", default-features = false } +key-wallet = { path = "../key-wallet" } dashcore = { path = "../dash" } dashcore_hashes = { path = "../hashes" } secp256k1 = { version = "0.30.0", default-features = false, features = ["recovery"] } diff --git a/key-wallet-manager/src/wallet_manager/mod.rs b/key-wallet-manager/src/wallet_manager/mod.rs index f2521da5c..64d413153 100644 --- a/key-wallet-manager/src/wallet_manager/mod.rs +++ b/key-wallet-manager/src/wallet_manager/mod.rs @@ -8,7 +8,6 @@ mod matching; mod process_block; pub use crate::wallet_manager::matching::{check_compact_filters_for_addresses, FilterMatchKey}; -use alloc::collections::BTreeMap; use alloc::string::String; use alloc::vec::Vec; use dashcore::blockdata::transaction::Transaction; @@ -22,7 +21,7 @@ use key_wallet::wallet::WalletType; use key_wallet::Utxo; use key_wallet::{Account, AccountType, Address, ExtendedPrivKey, Mnemonic, Network, Wallet}; use key_wallet::{ExtendedPubKey, WalletCoreBalance}; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; use std::str::FromStr; use zeroize::Zeroize; diff --git a/key-wallet-manager/src/wallet_manager/process_block.rs b/key-wallet-manager/src/wallet_manager/process_block.rs index c1c3faed0..57bf68d2d 100644 --- a/key-wallet-manager/src/wallet_manager/process_block.rs +++ b/key-wallet-manager/src/wallet_manager/process_block.rs @@ -10,6 +10,7 @@ use dashcore::{Address, Block, Transaction}; use key_wallet::transaction_checking::transaction_router::TransactionRouter; use key_wallet::transaction_checking::TransactionContext; use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; +use std::collections::BTreeSet; use tokio::sync::broadcast; #[async_trait] @@ -92,7 +93,7 @@ impl WalletInterface for WalletM if is_relevant_any { // Deduplicate addresses while preserving order - let mut seen = alloc::collections::BTreeSet::new(); + let mut seen = BTreeSet::new(); addresses.retain(|a| seen.insert(a.clone())); let net = (total_received as i64) - (total_sent as i64); Some((net, addresses)) diff --git a/key-wallet/Cargo.toml b/key-wallet/Cargo.toml index 80c633a91..28d63e392 100644 --- a/key-wallet/Cargo.toml +++ b/key-wallet/Cargo.toml @@ -9,8 +9,7 @@ readme = "README.md" license = "CC0-1.0" [features] -default = ["std"] -std = ["secp256k1/std", "bip39/std", "getrandom", "rand"] +default = ["secp256k1/std", "bip39/std", "getrandom", "rand"] serde = ["dep:serde", "dep:serde_json", "dashcore_hashes/serde", "secp256k1/serde", "dashcore/serde"] bincode = ["serde", "dep:bincode", "dep:bincode_derive", "dashcore_hashes/bincode", "dashcore/bincode"] bip38 = ["scrypt", "aes", "bs58", "rand"] diff --git a/key-wallet/src/account/account_collection.rs b/key-wallet/src/account/account_collection.rs index 5a2a2c566..f430a13e8 100644 --- a/key-wallet/src/account/account_collection.rs +++ b/key-wallet/src/account/account_collection.rs @@ -2,8 +2,8 @@ //! //! This module provides a structured way to manage accounts by type. -use alloc::collections::BTreeMap; -use alloc::vec::Vec; +use std::collections::BTreeMap; + #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; #[cfg(feature = "serde")] diff --git a/key-wallet/src/account/account_trait.rs b/key-wallet/src/account/account_trait.rs index d02ad3c5c..c35df26c2 100644 --- a/key-wallet/src/account/account_trait.rs +++ b/key-wallet/src/account/account_trait.rs @@ -7,7 +7,6 @@ use crate::bip32::DerivationPath; use crate::dip9::DerivationPathReference; use crate::error::Result; use crate::Network; -use alloc::vec::Vec; /// Common trait for all account types pub trait AccountTrait { diff --git a/key-wallet/src/account/bls_account.rs b/key-wallet/src/account/bls_account.rs index 94c4d188b..12a1c031d 100644 --- a/key-wallet/src/account/bls_account.rs +++ b/key-wallet/src/account/bls_account.rs @@ -9,7 +9,6 @@ use crate::derivation_bls_bip32::{ExtendedBLSPrivKey, ExtendedBLSPubKey}; use crate::error::{Error, Result}; use crate::managed_account::address_pool::AddressPoolType; use crate::{ChildNumber, DerivationPath, Network}; -use alloc::vec::Vec; use core::fmt; use dashcore::Address; diff --git a/key-wallet/src/account/eddsa_account.rs b/key-wallet/src/account/eddsa_account.rs index efbf40ff4..497fd4c37 100644 --- a/key-wallet/src/account/eddsa_account.rs +++ b/key-wallet/src/account/eddsa_account.rs @@ -8,7 +8,6 @@ use crate::account::AccountType; use crate::derivation_slip10::{ExtendedEd25519PrivKey, ExtendedEd25519PubKey, VerifyingKey}; use crate::error::{Error, Result}; use crate::{ChildNumber, DerivationPath, Network}; -use alloc::vec::Vec; use core::fmt; use dashcore::Address; diff --git a/key-wallet/src/bip32.rs b/key-wallet/src/bip32.rs index f1663e11e..8933b19e4 100644 --- a/key-wallet/src/bip32.rs +++ b/key-wallet/src/bip32.rs @@ -25,7 +25,6 @@ use core::default::Default; use core::fmt; use core::ops::Index; use core::str::FromStr; -#[cfg(feature = "std")] use std::error; use dashcore_hashes::{hash160, sha512, Hash, HashEngine, Hmac, HmacEngine}; @@ -42,7 +41,6 @@ use crate::dip9::{ IDENTITY_REGISTRATION_PATH_MAINNET, IDENTITY_REGISTRATION_PATH_TESTNET, IDENTITY_TOPUP_PATH_MAINNET, IDENTITY_TOPUP_PATH_TESTNET, }; -use alloc::{string::String, vec::Vec}; use base58ck; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; @@ -343,7 +341,6 @@ impl<'de> serde::Deserialize<'de> for Fingerprint { /// Extended private key #[derive(Copy, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(Debug))] pub struct ExtendedPrivKey { /// The network this key is to be used on pub network: Network, @@ -451,8 +448,6 @@ impl<'de> serde::Deserialize<'de> for ExtendedPrivKey { } } -#[cfg(not(feature = "std"))] -#[cfg_attr(docsrs, doc(cfg(not(feature = "std"))))] impl fmt::Debug for ExtendedPrivKey { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("ExtendedPrivKey") @@ -1474,7 +1469,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl error::Error for Error { fn cause(&self) -> Option<&dyn error::Error> { if let Error::Secp256k1(ref e) = *self { diff --git a/key-wallet/src/bip38.rs b/key-wallet/src/bip38.rs index a57bba553..3a2ff59cb 100644 --- a/key-wallet/src/bip38.rs +++ b/key-wallet/src/bip38.rs @@ -11,8 +11,6 @@ //! - Prefix: 0x0142 for non-EC-multiply mode (base58 starts with "6P") //! - Prefix: 0x0143 for EC-multiply mode (base58 starts with "6P") -use alloc::string::String; -use alloc::vec::Vec; use core::fmt; use crate::error::{Error, Result}; diff --git a/key-wallet/src/derivation.rs b/key-wallet/src/derivation.rs index 4bf0ce6e7..8ba603027 100644 --- a/key-wallet/src/derivation.rs +++ b/key-wallet/src/derivation.rs @@ -3,7 +3,6 @@ //! This module provides key derivation functionality with a builder pattern //! for flexible path construction and derivation strategies. -use alloc::vec::Vec; use secp256k1::Secp256k1; use crate::bip32::{ChildNumber, DerivationPath, ExtendedPrivKey, ExtendedPubKey}; diff --git a/key-wallet/src/derivation_bls_bip32.rs b/key-wallet/src/derivation_bls_bip32.rs index d11d9a31a..18b704e04 100644 --- a/key-wallet/src/derivation_bls_bip32.rs +++ b/key-wallet/src/derivation_bls_bip32.rs @@ -10,11 +10,8 @@ //! - Supports both hardened and non-hardened derivation use core::fmt; -#[cfg(feature = "std")] -use std::error; - -use alloc::string::String; use dashcore_hashes::{sha256, Hash, HashEngine, Hmac, HmacEngine}; +use std::error; // NOTE: We use Bls12381G2Impl for BLS keys (48-byte public keys) use dashcore::blsful::{ @@ -64,7 +61,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl error::Error for Error {} /// Extended BLS private key for HD derivation diff --git a/key-wallet/src/derivation_slip10.rs b/key-wallet/src/derivation_slip10.rs index 7a4af881e..b24f1c91f 100644 --- a/key-wallet/src/derivation_slip10.rs +++ b/key-wallet/src/derivation_slip10.rs @@ -9,15 +9,12 @@ //! - Different serialization format (no xpub/xprv, custom encoding) use core::fmt; -#[cfg(feature = "std")] -use std::error; - -use alloc::{string::String, vec::Vec}; pub use dashcore::ed25519_dalek::{SigningKey, VerifyingKey}; use dashcore::Network; use dashcore_hashes::{sha512, Hash, HashEngine, Hmac, HmacEngine}; #[cfg(feature = "serde")] use serde; +use std::error; // Re-export ChainCode, Fingerprint and ChildNumber from bip32 use crate::bip32::{ChainCode, ChildNumber, Fingerprint}; @@ -444,7 +441,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl error::Error for Error {} impl From for Error { diff --git a/key-wallet/src/error.rs b/key-wallet/src/error.rs index 28cbdcbc2..5e3105e7d 100644 --- a/key-wallet/src/error.rs +++ b/key-wallet/src/error.rs @@ -1,8 +1,6 @@ //! Error types for the key-wallet library use core::fmt; - -#[cfg(feature = "std")] use std::error; /// Result type alias for key-wallet operations @@ -69,7 +67,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match self { diff --git a/key-wallet/src/lib.rs b/key-wallet/src/lib.rs index db1496b58..e12224ae4 100644 --- a/key-wallet/src/lib.rs +++ b/key-wallet/src/lib.rs @@ -4,14 +4,6 @@ //! including BIP32 hierarchical deterministic wallets, BIP39 mnemonic support, //! and Dash-specific derivation paths (DIP9). -#![cfg_attr(not(feature = "std"), no_std)] - -extern crate alloc; - -extern crate core; -#[cfg(feature = "std")] -extern crate std; - #[cfg(any(test, feature = "test-utils"))] pub mod test_utils; diff --git a/key-wallet/src/managed_account/address_pool.rs b/key-wallet/src/managed_account/address_pool.rs index c84571bee..36fd1edf6 100644 --- a/key-wallet/src/managed_account/address_pool.rs +++ b/key-wallet/src/managed_account/address_pool.rs @@ -3,8 +3,6 @@ //! This module provides comprehensive address pool management including //! generation, usage tracking, and discovery. -use alloc::string::String; -use alloc::vec::Vec; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; use core::fmt; diff --git a/key-wallet/src/managed_account/managed_account_collection.rs b/key-wallet/src/managed_account/managed_account_collection.rs index 5fc272a03..10f5adcb4 100644 --- a/key-wallet/src/managed_account/managed_account_collection.rs +++ b/key-wallet/src/managed_account/managed_account_collection.rs @@ -3,6 +3,8 @@ //! This module provides a structure for managing multiple accounts //! across different networks in a hierarchical manner. +use std::collections::BTreeMap; + use crate::account::account_collection::{DashpayAccountKey, PlatformPaymentAccountKey}; use crate::account::account_type::AccountType; use crate::gap_limit::{ @@ -16,8 +18,6 @@ use crate::managed_account::ManagedCoreAccount; use crate::transaction_checking::account_checker::CoreAccountTypeMatch; use crate::{Account, AccountCollection}; use crate::{KeySource, Network}; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/key-wallet/src/managed_account/managed_account_trait.rs b/key-wallet/src/managed_account/managed_account_trait.rs index 505f959be..0a09a14a5 100644 --- a/key-wallet/src/managed_account/managed_account_trait.rs +++ b/key-wallet/src/managed_account/managed_account_trait.rs @@ -2,13 +2,14 @@ //! //! This module defines the common interface for all managed account types. +use std::collections::BTreeMap; + use crate::account::AccountMetadata; use crate::account::TransactionRecord; use crate::managed_account::managed_account_type::ManagedAccountType; use crate::utxo::Utxo; use crate::wallet::balance::WalletCoreBalance; use crate::Network; -use alloc::collections::BTreeMap; use dashcore::blockdata::transaction::OutPoint; use dashcore::Txid; diff --git a/key-wallet/src/managed_account/managed_platform_account.rs b/key-wallet/src/managed_account/managed_platform_account.rs index a803feb0e..aa85ce5b1 100644 --- a/key-wallet/src/managed_account/managed_platform_account.rs +++ b/key-wallet/src/managed_account/managed_platform_account.rs @@ -9,13 +9,13 @@ //! //! The derivation path follows DIP-17: `m/9'/coin_type'/17'/account'/key_class'/index` +use std::collections::BTreeMap; + use super::address_pool::{AddressPool, KeySource}; use super::metadata::AccountMetadata; use super::platform_address::PlatformP2PKHAddress; use crate::error::{Error, Result}; use crate::Network; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; use dashcore::Address; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -302,17 +302,10 @@ impl ManagedPlatformAccount { /// Get the current timestamp fn current_timestamp() -> u64 { - #[cfg(feature = "std")] - { - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_secs() - } - #[cfg(not(feature = "std"))] - { - 0 // In no_std environments, timestamp must be provided externally - } + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs() } /// Get pool statistics diff --git a/key-wallet/src/managed_account/metadata.rs b/key-wallet/src/managed_account/metadata.rs index ccdd63ca6..b03c5ef14 100644 --- a/key-wallet/src/managed_account/metadata.rs +++ b/key-wallet/src/managed_account/metadata.rs @@ -2,8 +2,6 @@ //! //! This module contains metadata structures for accounts. -use alloc::string::String; -use alloc::vec::Vec; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; #[cfg(feature = "serde")] diff --git a/key-wallet/src/managed_account/mod.rs b/key-wallet/src/managed_account/mod.rs index 82ba2b803..08bec38e8 100644 --- a/key-wallet/src/managed_account/mod.rs +++ b/key-wallet/src/managed_account/mod.rs @@ -20,13 +20,13 @@ use crate::wallet::balance::WalletCoreBalance; #[cfg(feature = "eddsa")] use crate::AddressInfo; use crate::{ExtendedPubKey, Network}; -use alloc::collections::BTreeMap; use dashcore::blockdata::transaction::OutPoint; use dashcore::{Address, ScriptBuf}; use dashcore::{Transaction, Txid}; use managed_account_type::ManagedAccountType; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; use std::collections::{BTreeSet, HashSet}; pub mod address_pool; @@ -921,17 +921,10 @@ impl ManagedCoreAccount { /// Get the current timestamp (for metadata) fn current_timestamp() -> u64 { - #[cfg(feature = "std")] - { - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_secs() - } - #[cfg(not(feature = "std"))] - { - 0 // In no_std environments, timestamp must be provided externally - } + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_secs() } /// Get total address count across all pools diff --git a/key-wallet/src/managed_account/transaction_record.rs b/key-wallet/src/managed_account/transaction_record.rs index 3f51b6e01..89cabcde5 100644 --- a/key-wallet/src/managed_account/transaction_record.rs +++ b/key-wallet/src/managed_account/transaction_record.rs @@ -3,7 +3,6 @@ //! This module contains the transaction record structure used to track //! transactions associated with accounts. -use alloc::string::String; use dashcore::blockdata::transaction::Transaction; use dashcore::{BlockHash, Txid}; #[cfg(feature = "serde")] diff --git a/key-wallet/src/mnemonic.rs b/key-wallet/src/mnemonic.rs index 554779cce..d3cdc6963 100644 --- a/key-wallet/src/mnemonic.rs +++ b/key-wallet/src/mnemonic.rs @@ -1,7 +1,5 @@ //! BIP39 Mnemonic implementation -use alloc::string::String; -use alloc::vec::Vec; use core::fmt; use core::str::FromStr; @@ -10,7 +8,6 @@ use crate::error::{Error, Result}; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; use bip39 as bip39_crate; -#[cfg(feature = "std")] use rand::{RngCore, SeedableRng}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -156,7 +153,6 @@ impl Mnemonic { /// let mut rng = StdRng::from_entropy(); /// let mnemonic = Mnemonic::generate_using_rng(12, Language::English, &mut rng).unwrap(); /// ``` - #[cfg(feature = "std")] pub fn generate_using_rng( word_count: usize, language: Language, @@ -201,7 +197,6 @@ impl Mnemonic { /// let seed = 12345u64; /// let mnemonic = Mnemonic::generate_with_seed(12, Language::English, seed).unwrap(); /// ``` - #[cfg(feature = "std")] pub fn generate_with_seed(word_count: usize, language: Language, seed: u64) -> Result { use rand::rngs::StdRng; @@ -528,7 +523,6 @@ mod tests { // Test mnemonic generation with custom RNG #[test] - #[cfg(feature = "std")] fn test_generate_using_rng() { use rand::rngs::StdRng; use rand::SeedableRng; @@ -557,7 +551,6 @@ mod tests { // Test deterministic mnemonic generation from seed #[test] - #[cfg(feature = "std")] fn test_generate_with_seed() { // Generate mnemonic from seed let seed = 42u64; @@ -598,7 +591,6 @@ mod tests { // Test that generate_with_seed is truly deterministic #[test] - #[cfg(feature = "std")] fn test_generate_with_seed_deterministic() { let test_seeds = vec![0u64, 1, 100, 1000, u64::MAX]; diff --git a/key-wallet/src/psbt/error.rs b/key-wallet/src/psbt/error.rs index 553cb25fc..fafc5b4d9 100644 --- a/key-wallet/src/psbt/error.rs +++ b/key-wallet/src/psbt/error.rs @@ -174,7 +174,6 @@ impl fmt::Display for Error { } } -#[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::Error::*; diff --git a/key-wallet/src/psbt/map/global.rs b/key-wallet/src/psbt/map/global.rs index 7de54f334..97df0aa07 100644 --- a/key-wallet/src/psbt/map/global.rs +++ b/key-wallet/src/psbt/map/global.rs @@ -5,14 +5,12 @@ use core::convert::TryFrom; use crate::bip32::{ChildNumber, DerivationPath, ExtendedPubKey, Fingerprint}; use crate::psbt::map::Map; use crate::psbt::{raw, Error, PartiallySignedTransaction}; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; use dashcore::blockdata::transaction::Transaction; use dashcore::consensus::encode::MAX_VEC_SIZE; use dashcore::consensus::{encode, Decodable, Encodable}; use dashcore::io::{Cursor, Read}; use dashcore::transaction::special_transaction::TransactionType; -use std::collections::btree_map; +use std::collections::{btree_map, BTreeMap}; /// Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00 const PSBT_GLOBAL_UNSIGNED_TX: u8 = 0x00; diff --git a/key-wallet/src/psbt/map/input.rs b/key-wallet/src/psbt/map/input.rs index f8be874f9..01da313e7 100644 --- a/key-wallet/src/psbt/map/input.rs +++ b/key-wallet/src/psbt/map/input.rs @@ -10,8 +10,6 @@ use secp256k1::XOnlyPublicKey; use crate::psbt::map::Map; use crate::psbt::serialize::Deserialize; use crate::psbt::{error, raw, Error}; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; use dashcore::blockdata::script::ScriptBuf; use dashcore::blockdata::transaction::txout::TxOut; use dashcore::blockdata::transaction::Transaction; @@ -22,7 +20,7 @@ use dashcore::sighash::{ self, EcdsaSighashType, NonStandardSighashType, SighashTypeParseError, TapSighashType, }; use dashcore::taproot::{ControlBlock, LeafVersion, TapLeafHash, TapNodeHash}; -use std::collections::btree_map; +use std::collections::{btree_map, BTreeMap}; use crate::bip32::KeySource; #[cfg(feature = "serde")] diff --git a/key-wallet/src/psbt/map/mod.rs b/key-wallet/src/psbt/map/mod.rs index 252ceef2b..b301973fc 100644 --- a/key-wallet/src/psbt/map/mod.rs +++ b/key-wallet/src/psbt/map/mod.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: CC0-1.0 use crate::psbt::raw; -use alloc::vec::Vec; mod global; mod input; diff --git a/key-wallet/src/psbt/map/output.rs b/key-wallet/src/psbt/map/output.rs index 5f5809613..f9dd45d4a 100644 --- a/key-wallet/src/psbt/map/output.rs +++ b/key-wallet/src/psbt/map/output.rs @@ -10,11 +10,9 @@ use {core, secp256k1}; use crate::bip32::KeySource; use crate::psbt::map::Map; use crate::psbt::{raw, Error}; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; use dashcore::blockdata::script::ScriptBuf; use dashcore::taproot::{TapLeafHash, TapTree}; -use std::collections::btree_map; +use std::collections::{btree_map, BTreeMap}; /// Type: Redeem ScriptBuf PSBT_OUT_REDEEM_SCRIPT = 0x00 const PSBT_OUT_REDEEM_SCRIPT: u8 = 0x00; diff --git a/key-wallet/src/psbt/mod.rs b/key-wallet/src/psbt/mod.rs index c04dc3842..15837c410 100644 --- a/key-wallet/src/psbt/mod.rs +++ b/key-wallet/src/psbt/mod.rs @@ -10,13 +10,10 @@ use core::{cmp, fmt}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -#[cfg(feature = "std")] -use std::collections::{HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap, HashSet}; use crate::bip32::KeySource; use crate::bip32::{self, ExtendedPrivKey, ExtendedPubKey}; -use alloc::collections::BTreeMap; -use alloc::vec::Vec; use core::borrow::Borrow; use dashcore::blockdata::script::ScriptBuf; use dashcore::blockdata::transaction::txout::TxOut; @@ -576,7 +573,6 @@ impl GetKey for $set { } }}} impl_get_key_for_set!(BTreeSet); -#[cfg(feature = "std")] impl_get_key_for_set!(HashSet); #[rustfmt::skip] @@ -598,7 +594,6 @@ impl GetKey for $map { } }}} impl_get_key_for_map!(BTreeMap); -#[cfg(feature = "std")] impl_get_key_for_map!(HashMap); /// Errors when getting a key. @@ -624,7 +619,6 @@ impl fmt::Display for GetKeyError { } } -#[cfg(feature = "std")] impl std::error::Error for GetKeyError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use GetKeyError::*; @@ -747,7 +741,6 @@ impl fmt::Display for SignError { } } -#[cfg(feature = "std")] impl std::error::Error for SignError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::SignError::*; @@ -808,7 +801,6 @@ mod display_from_str { } } - #[cfg(feature = "std")] impl std::error::Error for PsbtParseError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::PsbtParseError::*; @@ -1130,16 +1122,9 @@ mod tests { #[cfg(feature = "base64")] use std::str::FromStr; + use crate::psbt::map::Map; + use super::*; - use crate::psbt::map::{Input, Map, Output}; - use crate::psbt::{raw, PartiallySignedTransaction}; - use dashcore::blockdata::script::ScriptBuf; - use dashcore::blockdata::transaction::outpoint::OutPoint; - use dashcore::blockdata::transaction::txin::TxIn; - use dashcore::blockdata::transaction::txout::TxOut; - use dashcore::blockdata::transaction::Transaction; - use dashcore::blockdata::witness::Witness; - use dashcore::sighash::EcdsaSighashType; #[test] #[should_panic(expected = "InvalidMagic")] diff --git a/key-wallet/src/psbt/raw.rs b/key-wallet/src/psbt/raw.rs index 3aeab5efb..b97c580df 100644 --- a/key-wallet/src/psbt/raw.rs +++ b/key-wallet/src/psbt/raw.rs @@ -13,7 +13,6 @@ use serde::{Deserialize as SerdeDeserialize, Serialize as SerdeSerialize}; use super::serialize::{self, Deserialize, Serialize}; use crate::psbt::Error; -use alloc::vec::Vec; use dashcore::consensus::encode::{ self, deserialize, serialize, Decodable, Encodable, ReadExt, VarInt, WriteExt, MAX_VEC_SIZE, }; diff --git a/key-wallet/src/psbt/serialize.rs b/key-wallet/src/psbt/serialize.rs index 2b40ae841..4bd7e1825 100644 --- a/key-wallet/src/psbt/serialize.rs +++ b/key-wallet/src/psbt/serialize.rs @@ -16,8 +16,6 @@ use super::Psbt; use crate::bip32::KeySource; use crate::bip32::{ChildNumber, Fingerprint}; use crate::psbt::{Error, PartiallySignedTransaction}; -use alloc::string::String; -use alloc::vec::Vec; use dashcore::blockdata::script::ScriptBuf; use dashcore::blockdata::transaction::txout::TxOut; use dashcore::blockdata::transaction::Transaction; diff --git a/key-wallet/src/seed.rs b/key-wallet/src/seed.rs index 9c4ccda52..51c9fa952 100644 --- a/key-wallet/src/seed.rs +++ b/key-wallet/src/seed.rs @@ -3,8 +3,6 @@ //! A seed is a 512-bit (64 bytes) value used to derive HD wallet keys. use crate::error::{Error, Result}; -use alloc::string::String; -use alloc::vec::Vec; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; use core::fmt; diff --git a/key-wallet/src/tests/wallet_tests.rs b/key-wallet/src/tests/wallet_tests.rs index 511d890b1..862154800 100644 --- a/key-wallet/src/tests/wallet_tests.rs +++ b/key-wallet/src/tests/wallet_tests.rs @@ -9,7 +9,6 @@ use crate::seed::Seed; use crate::wallet::root_extended_keys::RootExtendedPrivKey; use crate::wallet::{Wallet, WalletType}; use crate::Network; -use alloc::string::ToString; /// Known test mnemonic for deterministic testing const TEST_MNEMONIC: &str = diff --git a/key-wallet/src/transaction_checking/account_checker.rs b/key-wallet/src/transaction_checking/account_checker.rs index 15089cef9..4531a4dc7 100644 --- a/key-wallet/src/transaction_checking/account_checker.rs +++ b/key-wallet/src/transaction_checking/account_checker.rs @@ -3,12 +3,13 @@ //! This module provides methods for checking if transactions belong to //! specific accounts within a ManagedAccountCollection. +use std::collections::BTreeMap; + use super::transaction_router::AccountTypeToCheck; use crate::account::{ManagedAccountCollection, ManagedCoreAccount}; use crate::managed_account::address_pool::{AddressInfo, PublicKeyType}; use crate::managed_account::managed_account_type::ManagedAccountType; use crate::Address; -use alloc::vec::Vec; use dashcore::address::Payload; use dashcore::blockdata::transaction::Transaction; use dashcore::transaction::TransactionPayload; @@ -412,7 +413,7 @@ impl ManagedAccountCollection { /// Check indexed accounts (BTreeMap of accounts) fn check_indexed_accounts( - accounts: &alloc::collections::BTreeMap, + accounts: &BTreeMap, tx: &Transaction, ) -> Vec { let mut matches = Vec::new(); diff --git a/key-wallet/src/wallet/bip38.rs b/key-wallet/src/wallet/bip38.rs index fd74205e1..8c06c1d1e 100644 --- a/key-wallet/src/wallet/bip38.rs +++ b/key-wallet/src/wallet/bip38.rs @@ -10,9 +10,6 @@ use crate::bip38::{encrypt_private_key, Bip38EncryptedKey}; use crate::error::{Error, Result}; #[cfg(feature = "bip38")] use crate::Network; -#[cfg(feature = "bip38")] -use alloc::vec::Vec; - #[cfg(feature = "bip38")] impl Wallet { /// Export the master private key as BIP38 encrypted diff --git a/key-wallet/src/wallet/helper.rs b/key-wallet/src/wallet/helper.rs index 82e693d0e..a97b8dfb8 100644 --- a/key-wallet/src/wallet/helper.rs +++ b/key-wallet/src/wallet/helper.rs @@ -8,7 +8,6 @@ use super::{Wallet, WalletType}; use crate::account::{Account, AccountType, StandardAccountType}; use crate::error::Result; use crate::Error; -use alloc::vec::Vec; use hex; impl Wallet { diff --git a/key-wallet/src/wallet/initialization.rs b/key-wallet/src/wallet/initialization.rs index 3e76c0d07..efb94b1e9 100644 --- a/key-wallet/src/wallet/initialization.rs +++ b/key-wallet/src/wallet/initialization.rs @@ -11,7 +11,6 @@ use crate::error::Result; use crate::mnemonic::{Language, Mnemonic}; use crate::seed::Seed; use crate::Network; -use alloc::string::String; use std::collections::BTreeSet; /// Set of BIP44 account indices to create diff --git a/key-wallet/src/wallet/managed_wallet_info/coin_selection.rs b/key-wallet/src/wallet/managed_wallet_info/coin_selection.rs index 52fb37aee..42348122c 100644 --- a/key-wallet/src/wallet/managed_wallet_info/coin_selection.rs +++ b/key-wallet/src/wallet/managed_wallet_info/coin_selection.rs @@ -5,7 +5,6 @@ use crate::wallet::managed_wallet_info::fee::FeeRate; use crate::Utxo; -use alloc::vec::Vec; use core::cmp::Reverse; /// UTXO selection strategy @@ -684,7 +683,6 @@ impl core::fmt::Display for SelectionError { } } -#[cfg(feature = "std")] impl std::error::Error for SelectionError {} #[cfg(test)] diff --git a/key-wallet/src/wallet/managed_wallet_info/helpers.rs b/key-wallet/src/wallet/managed_wallet_info/helpers.rs index 31194e0d4..0271c372f 100644 --- a/key-wallet/src/wallet/managed_wallet_info/helpers.rs +++ b/key-wallet/src/wallet/managed_wallet_info/helpers.rs @@ -4,7 +4,6 @@ use super::ManagedWalletInfo; use crate::account::account_collection::PlatformPaymentAccountKey; use crate::account::ManagedCoreAccount; use crate::managed_account::managed_platform_account::ManagedPlatformAccount; -use alloc::vec::Vec; impl ManagedWalletInfo { // BIP44 Account Helpers diff --git a/key-wallet/src/wallet/managed_wallet_info/mod.rs b/key-wallet/src/wallet/managed_wallet_info/mod.rs index 26ad6db0d..26cfa8c3c 100644 --- a/key-wallet/src/wallet/managed_wallet_info/mod.rs +++ b/key-wallet/src/wallet/managed_wallet_info/mod.rs @@ -18,7 +18,6 @@ use super::balance::WalletCoreBalance; use super::metadata::WalletMetadata; use crate::account::ManagedAccountCollection; use crate::Network; -use alloc::string::String; use dashcore::prelude::CoreBlockHeight; use dashcore::Txid; #[cfg(feature = "serde")] diff --git a/key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs b/key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs index c8cca6b37..05bc461b8 100644 --- a/key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs +++ b/key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs @@ -3,7 +3,6 @@ //! This module provides high-level transaction building functionality //! using types from the dashcore crate. -use alloc::vec::Vec; use core::fmt; use dashcore::blockdata::script::{Builder, PushBytes, ScriptBuf}; @@ -825,7 +824,6 @@ impl fmt::Display for BuilderError { } } -#[cfg(feature = "std")] impl std::error::Error for BuilderError {} #[cfg(test)] diff --git a/key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs b/key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs index 760573cca..52ac3248a 100644 --- a/key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs +++ b/key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs @@ -2,6 +2,8 @@ //! //! This trait allows WalletManager to work with different wallet info implementations +use std::collections::BTreeSet; + use super::managed_account_operations::ManagedAccountOperations; use crate::account::ManagedAccountTrait; use crate::managed_account::managed_account_collection::ManagedAccountCollection; @@ -9,8 +11,7 @@ use crate::transaction_checking::WalletTransactionChecker; use crate::wallet::managed_wallet_info::TransactionRecord; use crate::wallet::ManagedWalletInfo; use crate::{Network, Utxo, Wallet, WalletCoreBalance}; -use alloc::collections::BTreeSet; -use alloc::vec::Vec; + use dashcore::prelude::CoreBlockHeight; use dashcore::{Address as DashAddress, Transaction, Txid}; diff --git a/key-wallet/src/wallet/metadata.rs b/key-wallet/src/wallet/metadata.rs index 5ecd34371..a2bd8025e 100644 --- a/key-wallet/src/wallet/metadata.rs +++ b/key-wallet/src/wallet/metadata.rs @@ -2,8 +2,8 @@ //! //! This module contains the metadata structures for wallets. -use alloc::collections::BTreeMap; -use alloc::string::String; +use std::collections::BTreeMap; + use dashcore::prelude::CoreBlockHeight; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/key-wallet/src/wallet/mod.rs b/key-wallet/src/wallet/mod.rs index 5e4d2320e..7feebd889 100644 --- a/key-wallet/src/wallet/mod.rs +++ b/key-wallet/src/wallet/mod.rs @@ -22,7 +22,6 @@ use crate::account::account_collection::AccountCollection; use crate::mnemonic::Mnemonic; use crate::seed::Seed; use crate::Network; -use alloc::vec::Vec; #[cfg(feature = "bincode")] use bincode_derive::{Decode, Encode}; use core::fmt; diff --git a/key-wallet/src/wallet/root_extended_keys.rs b/key-wallet/src/wallet/root_extended_keys.rs index 5e2122e52..7b6904147 100644 --- a/key-wallet/src/wallet/root_extended_keys.rs +++ b/key-wallet/src/wallet/root_extended_keys.rs @@ -1,9 +1,10 @@ +use std::borrow::Cow; + use crate::bip32::{ChainCode, ChildNumber, ExtendedPrivKey, ExtendedPubKey}; #[cfg(feature = "bls")] use crate::derivation_bls_bip32::ExtendedBLSPrivKey; use crate::wallet::WalletType; use crate::{Error, Network, Wallet}; -use alloc::borrow::Cow; #[cfg(feature = "bincode")] use bincode::{BorrowDecode, Decode, Encode}; #[cfg(feature = "bls")]