Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["dash", "hashes", "internals", "fuzz", "rpc-client", "rpc-json", "rpc
resolver = "2"

[workspace.package]
version = "0.39.0"
version = "0.39.1"

[patch.crates-io.dashcore_hashes]
path = "hashes"
Expand Down
28 changes: 22 additions & 6 deletions dash/src/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ use serde;

use crate::base58;
use crate::crypto::key::{self, Keypair, PrivateKey, PublicKey};
use crate::dip9::{
DASH_BIP44_PATH_MAINNET, DASH_BIP44_PATH_TESTNET, IDENTITY_AUTHENTICATION_PATH_MAINNET,
IDENTITY_AUTHENTICATION_PATH_TESTNET, IDENTITY_INVITATION_PATH_MAINNET,
IDENTITY_INVITATION_PATH_TESTNET, IDENTITY_REGISTRATION_PATH_MAINNET,
IDENTITY_REGISTRATION_PATH_TESTNET, IDENTITY_TOPUP_PATH_MAINNET, IDENTITY_TOPUP_PATH_TESTNET,
};
use crate::dip9::{COINJOIN_PATH_MAINNET, COINJOIN_PATH_TESTNET, DASH_BIP44_PATH_MAINNET, DASH_BIP44_PATH_TESTNET, IDENTITY_AUTHENTICATION_PATH_MAINNET, IDENTITY_AUTHENTICATION_PATH_TESTNET, IDENTITY_INVITATION_PATH_MAINNET, IDENTITY_INVITATION_PATH_TESTNET, IDENTITY_REGISTRATION_PATH_MAINNET, IDENTITY_REGISTRATION_PATH_TESTNET, IDENTITY_TOPUP_PATH_MAINNET, IDENTITY_TOPUP_PATH_TESTNET};
use crate::hash_types::XpubIdentifier;
use crate::internal_macros::impl_bytes_newtype;
use crate::io::Write;
Expand Down Expand Up @@ -494,6 +489,18 @@ impl DerivationPath {
]);
root_derivation_path
}
pub fn coinjoin_path(
network: Network,
account: u32,
) -> Self {
let mut root_derivation_path: DerivationPath = match network {
Network::Dash => COINJOIN_PATH_MAINNET,
_ => COINJOIN_PATH_TESTNET,
}
.into();
root_derivation_path.0.extend(&[ChildNumber::Hardened { index: account }]);
root_derivation_path
}

/// This might have been used in the past
pub fn identity_registration_path_child_non_hardened(network: Network, index: u32) -> Self {
Expand Down Expand Up @@ -2059,6 +2066,15 @@ mod tests {
assert_eq!(path.to_string(), "m/44'/1'/1'/0/42");
}

#[test]
fn test_coinjoin_path() {
let path = DerivationPath::coinjoin_path(Network::Dash, 0);
assert_eq!(path.to_string(), "m/9'/5'/4'/0'");

let path = DerivationPath::coinjoin_path(Network::Testnet, 1);
assert_eq!(path.to_string(), "m/9'/1'/4'/1'");
}

#[test]
fn test_identity_registration_path() {
let path = DerivationPath::identity_registration_path(Network::Dash, 10);
Expand Down
22 changes: 22 additions & 0 deletions dash/src/dip9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub enum DerivationPathReference {
BlockchainIdentityCreditTopupFunding = 12,
BlockchainIdentityCreditInvitationFunding = 13,
ProviderPlatformNodeKeys = 14,
CoinJoin = 15,
Root = 255,
}

Expand Down Expand Up @@ -118,6 +119,7 @@ pub const BIP44_PURPOSE: u32 = 44;
pub const FEATURE_PURPOSE: u32 = 9;
pub const DASH_COIN_TYPE: u32 = 5;
pub const DASH_TESTNET_COIN_TYPE: u32 = 1;
pub const FEATURE_PURPOSE_COINJOIN: u32 = 4;
pub const FEATURE_PURPOSE_IDENTITIES: u32 = 5;
pub const FEATURE_PURPOSE_IDENTITIES_SUBFEATURE_AUTHENTICATION: u32 = 0;
pub const FEATURE_PURPOSE_IDENTITIES_SUBFEATURE_REGISTRATION: u32 = 1;
Expand Down Expand Up @@ -149,6 +151,26 @@ pub const DASH_BIP44_PATH_TESTNET: IndexConstPath<2> = IndexConstPath {
reference: DerivationPathReference::BIP44,
path_type: DerivationPathType::CLEAR_FUNDS,
};
// CoinJoin Paths

pub const COINJOIN_PATH_MAINNET: IndexConstPath<3> = IndexConstPath {
indexes: [
ChildNumber::Hardened { index: FEATURE_PURPOSE },
ChildNumber::Hardened { index: DASH_COIN_TYPE },
ChildNumber::Hardened { index: FEATURE_PURPOSE_COINJOIN },
],
reference: DerivationPathReference::CoinJoin,
path_type: DerivationPathType::ANONYMOUS_FUNDS,
};
pub const COINJOIN_PATH_TESTNET: IndexConstPath<3> = IndexConstPath {
indexes: [
ChildNumber::Hardened { index: FEATURE_PURPOSE },
ChildNumber::Hardened { index: DASH_TESTNET_COIN_TYPE },
ChildNumber::Hardened { index: FEATURE_PURPOSE_COINJOIN },
],
reference: DerivationPathReference::CoinJoin,
path_type: DerivationPathType::ANONYMOUS_FUNDS,
};

pub const IDENTITY_REGISTRATION_PATH_MAINNET: IndexConstPath<4> = IndexConstPath {
indexes: [
Expand Down
Loading