Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions key-wallet-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"
4 changes: 2 additions & 2 deletions key-wallet-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
3 changes: 1 addition & 2 deletions key-wallet-manager/src/wallet_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion key-wallet-manager/src/wallet_manager/process_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -92,7 +93,7 @@ impl<T: WalletInfoInterface + Send + Sync + 'static> 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))
Expand Down
3 changes: 1 addition & 2 deletions key-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions key-wallet/src/account/account_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
1 change: 0 additions & 1 deletion key-wallet/src/account/account_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion key-wallet/src/account/bls_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion key-wallet/src/account/eddsa_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions key-wallet/src/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions key-wallet/src/bip38.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion key-wallet/src/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 1 addition & 5 deletions key-wallet/src/derivation_bls_bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -64,7 +61,6 @@ impl fmt::Display for Error {
}
}

#[cfg(feature = "std")]
impl error::Error for Error {}

/// Extended BLS private key for HD derivation
Expand Down
6 changes: 1 addition & 5 deletions key-wallet/src/derivation_slip10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -444,7 +441,6 @@ impl fmt::Display for Error {
}
}

#[cfg(feature = "std")]
impl error::Error for Error {}

impl From<crate::bip32::Error> for Error {
Expand Down
3 changes: 0 additions & 3 deletions key-wallet/src/error.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions key-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions key-wallet/src/managed_account/address_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions key-wallet/src/managed_account/managed_account_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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};

Expand Down
3 changes: 2 additions & 1 deletion key-wallet/src/managed_account/managed_account_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 6 additions & 13 deletions key-wallet/src/managed_account/managed_platform_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions key-wallet/src/managed_account/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
17 changes: 5 additions & 12 deletions key-wallet/src/managed_account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion key-wallet/src/managed_account/transaction_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Loading
Loading