Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ members = [
]

[workspace.dependencies]
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "337f6ccc7f45a5f7a50abf0d6fecb1ef0b786e7b" }
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
dash-network-seeds = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
key-wallet-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
dash-network = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "2045cd29efbb323df9ec6c23f542ae5b12389b0e" }

tokio-metrics = "0.5"

Expand Down
16 changes: 10 additions & 6 deletions packages/rs-platform-wallet-ffi/src/core_wallet_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ pub(crate) struct MasternodeAggregate {
/// ProUpReg.
pub operator_public_key: Option<[u8; 48]>,
operator_height: u32,
/// Platform node id (hash160, 20 bytes) for evonodes — follows the
/// Platform node id (SHA256[..20] Tenderdash, #884, 20 bytes) for evonodes — follows the
/// latest ProRegTx / ProUpServ.
pub platform_node_id: Option<[u8; 20]>,
platform_node_height: u32,
Expand Down Expand Up @@ -1172,8 +1172,11 @@ where
}
if agg.platform_node_id.is_none() || height >= agg.platform_node_height {
// Evonode-only; `None` on a regular masternode.
if let Some(node_id) = p.platform_node_id.as_ref() {
agg.platform_node_id = Some(provider_hash_to_20(node_id.as_ref()));
// `platform_node_id` is a `PlatformNodeId` newtype
// (rust-dashcore #885); the 20 raw bytes (SHA256[..20]
// Tenderdash convention) come off `to_byte_array()`.
if let Some(node_id) = p.platform_node_id {
agg.platform_node_id = Some(node_id.to_byte_array());
agg.platform_node_height = height;
}
}
Expand All @@ -1187,10 +1190,11 @@ where
agg.service_address = Some(provider_ip_port(p.ip_address, p.port));
agg.service_height = height;
}
// ProUpServ's `platform_node_id` is a raw `Option<[u8; 20]>`.
// ProUpServ's `platform_node_id` is now `Option<PlatformNodeId>`
// (rust-dashcore #885, was `Option<[u8; 20]>`).
if let Some(node_id) = p.platform_node_id {
if agg.platform_node_id.is_none() || height >= agg.platform_node_height {
agg.platform_node_id = Some(node_id);
agg.platform_node_id = Some(node_id.to_byte_array());
agg.platform_node_height = height;
}
}
Expand Down Expand Up @@ -1306,7 +1310,7 @@ pub struct MasternodeEntryFFI {
/// Operator BLS public key (48 bytes), gated by `has_operator_key`.
pub operator_public_key: [u8; 48],
pub has_operator_key: bool,
/// Platform node id (hash160, 20 bytes) — evonodes only — gated by
/// Platform node id (SHA256[..20] Tenderdash, #884, 20 bytes) — evonodes only — gated by
/// `has_platform_node_id`.
pub platform_node_id: [u8; 20],
pub has_platform_node_id: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,35 @@ pub(crate) unsafe fn resolve_master_from_resolver(
wallet_id: &[u8; 32],
network: Network,
) -> Result<ExtendedPrivKey, PlatformWalletFFIResult> {
let seed = resolve_seed_from_resolver(mnemonic_resolver_handle, wallet_id)?;
ExtendedPrivKey::new_master(network, seed.as_ref()).map_err(|e| {
PlatformWalletFFIResult::err(
PlatformWalletFFIResultCode::ErrorWalletOperation,
format!("failed to build master xpriv from resolved mnemonic: {e}"),
)
})
}

/// Resolve a wallet's BIP-39 mnemonic via a Swift-owned
/// [`MnemonicResolverHandle`] and return the **raw 64-byte BIP39 seed**
/// (empty passphrase).
///
/// This is the seed the BLS operator / Ed25519 platform-node HD masters
/// consume directly (rust-dashcore #879); unlike
/// [`resolve_master_from_resolver`] it does **not** reduce the seed to a
/// secp256k1 `ExtendedPrivKey` — doing so would discard the raw seed the
/// provider-key derivation needs. The mnemonic and the returned seed are
/// held in [`Zeroizing`] buffers; the seed is scrubbed when the returned
/// value drops.
///
/// # Safety
/// `mnemonic_resolver_handle` must be non-null, come from
/// [`rs_sdk_ffi::dash_sdk_mnemonic_resolver_create`], and remain valid
/// for the duration of the call.
pub(crate) unsafe fn resolve_seed_from_resolver(
mnemonic_resolver_handle: *mut rs_sdk_ffi::MnemonicResolverHandle,
wallet_id: &[u8; 32],
) -> Result<Zeroizing<[u8; 64]>, PlatformWalletFFIResult> {
use rs_sdk_ffi::{mnemonic_resolver_result, MNEMONIC_RESOLVER_BUFFER_CAPACITY};
use std::ffi::c_void;

Expand Down Expand Up @@ -165,13 +194,7 @@ pub(crate) unsafe fn resolve_master_from_resolver(

let seed: Zeroizing<[u8; 64]> = Zeroizing::new(mnemonic.to_seed(""));
drop(mnemonic);

ExtendedPrivKey::new_master(network, seed.as_ref()).map_err(|e| {
PlatformWalletFFIResult::err(
PlatformWalletFFIResultCode::ErrorWalletOperation,
format!("failed to build master xpriv from resolved mnemonic: {e}"),
)
})
Ok(seed)
}

/// Build the DIP-9 identity-authentication derivation path
Expand Down
Loading
Loading