Skip to content

Commit 4a8b2a3

Browse files
shumkovclaude
andcommitted
refactor: replace WalletSeedHash with WalletId across entire codebase
Commit 3 of the seed_hash → wallet_id refactor. Bulk-renames the type alias WalletSeedHash to WalletId across 38 files. Since both resolve to [u8; 32], this is a pure naming change with no semantic impact. Every import, type annotation, function parameter, and struct field that previously used WalletSeedHash now uses WalletId directly (re-exported from platform_wallet_bridge). The legacy WalletSeedHash alias is kept in model/wallet/mod.rs for ClosedKeyItem.seed_hash (which genuinely is the SHA256 of the seed, used for encryption) and WalletIdMapping (the bridge between old and new key schemes). WalletIdMapping itself now has both sides typed as WalletId — they are the same underlying [u8; 32] type but carry different semantic values (seed_hash bytes vs wallet_id bytes). The struct stays until commit 5+ when AppContext.wallets is re-keyed and the mapping is deleted. 38 files changed, all tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9772cb8 commit 4a8b2a3

38 files changed

+209
-220
lines changed

Cargo.lock

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/backend_task/identity/load_identity.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::model::qualified_identity::qualified_identity_public_key::QualifiedId
1212
use crate::model::qualified_identity::{
1313
DPNSNameInfo, IdentityStatus, IdentityType, QualifiedIdentity,
1414
};
15-
use crate::model::wallet::{Wallet, WalletSeedHash};
15+
use crate::model::wallet::{Wallet, WalletId};
1616
use crate::ui::identities::add_new_identity_screen::MAX_IDENTITY_INDEX;
1717
use dash_sdk::Sdk;
1818
use dash_sdk::dashcore_rpc::dashcore::PrivateKey;
@@ -32,7 +32,7 @@ use std::convert::TryInto;
3232
use std::sync::{Arc, RwLock};
3333

3434
type WalletKeyMap = BTreeMap<(PrivateKeyTarget, u32), (QualifiedIdentityPublicKey, PrivateKeyData)>;
35-
type WalletMatchResult = Option<(WalletSeedHash, u32, WalletKeyMap)>;
35+
type WalletMatchResult = Option<(WalletId, u32, WalletKeyMap)>;
3636

3737
impl AppContext {
3838
pub(super) async fn load_identity(
@@ -219,7 +219,7 @@ impl AppContext {
219219
None
220220
};
221221

222-
// let mut wallet_seed_hash: Option<(WalletSeedHash, u32)> = None;
222+
// let mut wallet_seed_hash: Option<(WalletId, u32)> = None;
223223

224224
if identity_type == IdentityType::User {
225225
let input_private_keys = keys_input
@@ -371,8 +371,8 @@ impl AppContext {
371371
pub(super) fn match_user_identity_keys_with_wallet(
372372
&self,
373373
identity: &Identity,
374-
wallets: &BTreeMap<WalletSeedHash, Arc<RwLock<Wallet>>>,
375-
wallet_filter: Option<WalletSeedHash>,
374+
wallets: &BTreeMap<WalletId, Arc<RwLock<Wallet>>>,
375+
wallet_filter: Option<WalletId>,
376376
) -> Result<WalletMatchResult, TaskError> {
377377
let highest_identity_key_id = identity.public_keys().keys().copied().max().unwrap_or(0);
378378
let top_bound = highest_identity_key_id.saturating_add(6).max(1);
@@ -413,7 +413,7 @@ impl AppContext {
413413
&self,
414414
identity: &Identity,
415415
wallet: &mut Wallet,
416-
wallet_seed_hash: WalletSeedHash,
416+
wallet_seed_hash: WalletId,
417417
top_bound: u32,
418418
) -> Result<Option<(u32, WalletKeyMap)>, TaskError> {
419419
for candidate_index in 0..MAX_IDENTITY_INDEX {
@@ -495,7 +495,7 @@ impl AppContext {
495495
fn build_wallet_private_key_map(
496496
&self,
497497
identity: &Identity,
498-
wallet_seed_hash: WalletSeedHash,
498+
wallet_seed_hash: WalletId,
499499
identity_index: u32,
500500
public_key_map: &BTreeMap<Vec<u8>, u32>,
501501
public_key_hash_map: &BTreeMap<[u8; 20], u32>,

src/backend_task/identity/load_identity_by_dpns_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::context::AppContext;
44
use crate::model::qualified_identity::{
55
DPNSNameInfo, IdentityStatus, IdentityType, QualifiedIdentity,
66
};
7-
use crate::model::wallet::WalletSeedHash;
7+
use crate::model::wallet::WalletId;
88
use dash_sdk::Sdk;
99
use dash_sdk::platform::{Fetch, Identity};
1010

@@ -19,7 +19,7 @@ impl AppContext {
1919
&self,
2020
sdk: &Sdk,
2121
dpns_name: String,
22-
selected_wallet_seed_hash: Option<WalletSeedHash>,
22+
selected_wallet_seed_hash: Option<WalletId>,
2323
) -> Result<BackendTaskSuccessResult, TaskError> {
2424
// Step 1: Resolve the DPNS name to an identity ID using the SDK.
2525
//

src/backend_task/identity/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::model::qualified_identity::encrypted_key_storage::{KeyStorage, Wallet
1818
use crate::model::qualified_identity::qualified_identity_public_key::QualifiedIdentityPublicKey;
1919
use crate::model::qualified_identity::{IdentityType, PrivateKeyTarget, QualifiedIdentity};
2020
use crate::model::secret::Secret;
21-
use crate::model::wallet::{Wallet, WalletArcRef, WalletSeedHash};
21+
use crate::model::wallet::{Wallet, WalletArcRef, WalletId};
2222
use dash_sdk::Sdk;
2323
use dash_sdk::dashcore_rpc::dashcore::key::Secp256k1;
2424
use dash_sdk::dashcore_rpc::dashcore::{Address, PrivateKey};
@@ -48,7 +48,7 @@ pub struct IdentityInputToLoad {
4848
pub payout_address_private_key_input: Secret,
4949
pub keys_input: Vec<Secret>,
5050
pub derive_keys_from_wallets: bool,
51-
pub selected_wallet_seed_hash: Option<WalletSeedHash>,
51+
pub selected_wallet_seed_hash: Option<WalletId>,
5252
}
5353

5454
/// A key input tuple containing the private key with derivation path, key type, purpose,
@@ -81,7 +81,7 @@ impl IdentityKeys {
8181
}
8282
}
8383

84-
pub fn to_key_storage(&self, wallet_seed_hash: WalletSeedHash) -> KeyStorage {
84+
pub fn to_key_storage(&self, wallet_seed_hash: WalletId) -> KeyStorage {
8585
let Self {
8686
master_private_key,
8787
master_private_key_type,
@@ -295,7 +295,7 @@ pub enum RegisterIdentityFundingMethod {
295295
/// Platform addresses and credits to use
296296
inputs: BTreeMap<dash_sdk::dpp::address_funds::PlatformAddress, Credits>,
297297
/// Wallet seed hash for signing
298-
wallet_seed_hash: WalletSeedHash,
298+
wallet_seed_hash: WalletId,
299299
},
300300
}
301301

@@ -350,7 +350,7 @@ pub enum IdentityTask {
350350
SearchIdentitiesUpToIndex(WalletArcRef, IdentityIndex),
351351
/// Search for an identity by its DPNS name (without .dash suffix)
352352
/// Second parameter is optional wallet seed hash for key derivation
353-
SearchIdentityByDpnsName(String, Option<WalletSeedHash>),
353+
SearchIdentityByDpnsName(String, Option<WalletId>),
354354
RegisterIdentity(IdentityRegistrationInfo),
355355
TopUpIdentity(IdentityTopUpInfo),
356356
/// Top up an identity from Platform addresses
@@ -359,7 +359,7 @@ pub enum IdentityTask {
359359
/// Platform addresses and amounts to use for top-up
360360
inputs: BTreeMap<dash_sdk::dpp::address_funds::PlatformAddress, Credits>,
361361
/// Wallet seed hash for signing
362-
wallet_seed_hash: WalletSeedHash,
362+
wallet_seed_hash: WalletId,
363363
},
364364
AddKeyToIdentity(QualifiedIdentity, QualifiedIdentityPublicKey, [u8; 32]),
365365
WithdrawFromIdentity(QualifiedIdentity, Option<Address>, Credits, Option<KeyID>),
@@ -760,7 +760,7 @@ impl AppContext {
760760
sdk: &Sdk,
761761
qualified_identity: QualifiedIdentity,
762762
inputs: BTreeMap<dash_sdk::dpp::address_funds::PlatformAddress, Credits>,
763-
wallet_seed_hash: WalletSeedHash,
763+
wallet_seed_hash: WalletId,
764764
) -> Result<BackendTaskSuccessResult, TaskError> {
765765
use crate::model::fee_estimation::PlatformFeeEstimator;
766766
use dash_sdk::platform::transition::top_up_identity_from_addresses::TopUpIdentityFromAddresses;
@@ -850,7 +850,7 @@ impl AppContext {
850850
// Update destination address balances in any wallets that contain them
851851
// (using proof-verified data from the SDK response).
852852
{
853-
let seed_hashes: Vec<WalletSeedHash> = self
853+
let seed_hashes: Vec<WalletId> = self
854854
.wallets
855855
.read()
856856
.map(|w| w.keys().copied().collect())

src/backend_task/identity/register_identity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl AppContext {
351351
dash_sdk::dpp::address_funds::PlatformAddress,
352352
(AddressNonce, dash_sdk::dpp::fee::Credits),
353353
>,
354-
wallet_seed_hash: super::WalletSeedHash,
354+
wallet_seed_hash: super::WalletId,
355355
) -> Result<BackendTaskSuccessResult, TaskError> {
356356
use dash_sdk::platform::transition::put_identity::PutIdentity;
357357

src/backend_task/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use dash_sdk::dpp::dashcore::bls_sig_utils::BLSSignature;
1818
use dash_sdk::dpp::dashcore::network::message_qrinfo::QRInfo;
1919
use dash_sdk::dpp::dashcore::BlockHash;
2020
use crate::model::qualified_identity::QualifiedIdentity;
21-
use crate::model::wallet::WalletSeedHash;
21+
use crate::model::wallet::WalletId;
2222
use crate::model::grovestark_prover::ProofDataOutput;
2323
use crate::ui::tokens::tokens_screen::{
2424
ContractDescriptionInfo, IdentityTokenIdentifier, TokenInfo,
@@ -214,28 +214,28 @@ pub enum BackendTaskSuccessResult {
214214
GeneratedZKProof(ProofDataOutput),
215215
VerifiedZKProof(bool, ProofDataOutput),
216216
GeneratedReceiveAddress {
217-
seed_hash: WalletSeedHash,
217+
seed_hash: WalletId,
218218
address: String,
219219
},
220220
/// Per-address info loaded from the CoreWallet bridge
221221
AddressInfo(Vec<crate::platform_wallet_bridge::CoreAddressInfo>),
222222
/// Platform address balances fetched from Platform
223223
PlatformAddressBalances {
224-
seed_hash: WalletSeedHash,
224+
seed_hash: WalletId,
225225
/// Map of address to (balance, nonce)
226226
balances: BTreeMap<Address<NetworkChecked>, (u64, u32)>,
227227
},
228228
/// Platform credits transferred between addresses
229229
PlatformCreditsTransferred {
230-
seed_hash: WalletSeedHash,
230+
seed_hash: WalletId,
231231
},
232232
/// Platform address funded from asset lock
233233
PlatformAddressFunded {
234-
seed_hash: WalletSeedHash,
234+
seed_hash: WalletId,
235235
},
236236
/// Withdrawal from Platform address to Core initiated
237237
PlatformAddressWithdrawal {
238-
seed_hash: WalletSeedHash,
238+
seed_hash: WalletId,
239239
},
240240

241241
// MNList-specific results
@@ -326,36 +326,36 @@ pub enum BackendTaskSuccessResult {
326326

327327
// Shielded pool results
328328
ShieldedInitialized {
329-
seed_hash: WalletSeedHash,
329+
seed_hash: WalletId,
330330
balance: u64,
331331
},
332332
ShieldedNotesSynced {
333-
seed_hash: WalletSeedHash,
333+
seed_hash: WalletId,
334334
new_notes: u32,
335335
balance: u64,
336336
},
337337
ShieldedCreditsShielded {
338-
seed_hash: WalletSeedHash,
338+
seed_hash: WalletId,
339339
amount: u64,
340340
},
341341
ShieldedTransferComplete {
342-
seed_hash: WalletSeedHash,
342+
seed_hash: WalletId,
343343
amount: u64,
344344
},
345345
ShieldedCreditsUnshielded {
346-
seed_hash: WalletSeedHash,
346+
seed_hash: WalletId,
347347
amount: u64,
348348
},
349349
ShieldedNullifiersChecked {
350-
seed_hash: WalletSeedHash,
350+
seed_hash: WalletId,
351351
spent_count: u32,
352352
},
353353
ShieldedFromAssetLock {
354-
seed_hash: WalletSeedHash,
354+
seed_hash: WalletId,
355355
amount: u64,
356356
},
357357
ShieldedWithdrawalComplete {
358-
seed_hash: WalletSeedHash,
358+
seed_hash: WalletId,
359359
amount: u64,
360360
},
361361
ProvingKeyReady,

src/backend_task/shielded/bundle.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::backend_task::error::{TaskError, shielded_broadcast_error, shielded_b
22
use crate::context::AppContext;
33
use crate::context::shielded::get_proving_key;
44
use crate::model::fee_estimation::{format_credits_as_dash, shielded_fee_for_actions};
5-
use crate::model::wallet::WalletSeedHash;
5+
use crate::model::wallet::WalletId;
66
use crate::model::wallet::shielded::{ShieldedNote, ShieldedWalletState};
77
use dash_sdk::dpp::address_funds::{
88
AddressFundsFeeStrategy, AddressFundsFeeStrategyStep, OrchardAddress, PlatformAddress,
@@ -87,7 +87,7 @@ impl ShieldStage {
8787
/// Returns the built `StateTransition` so the caller can broadcast in nonce order.
8888
pub fn build_shield_credit(
8989
app_context: &Arc<AppContext>,
90-
seed_hash: &WalletSeedHash,
90+
seed_hash: &WalletId,
9191
recipient_payment_address: &PaymentAddress,
9292
amount: u64,
9393
from_address: PlatformAddress,
@@ -140,7 +140,7 @@ pub fn build_shield_credit(
140140
/// (including Halo 2 proof generation and RedPallas signature application).
141141
pub async fn shield_credits(
142142
app_context: &Arc<AppContext>,
143-
seed_hash: &WalletSeedHash,
143+
seed_hash: &WalletId,
144144
recipient_payment_address: &PaymentAddress,
145145
amount: u64,
146146
from_address: PlatformAddress,
@@ -246,7 +246,7 @@ pub async fn shield_credits(
246246
/// Returns the nullifiers of the notes that were spent.
247247
pub async fn shielded_transfer(
248248
app_context: &Arc<AppContext>,
249-
_seed_hash: &WalletSeedHash,
249+
_seed_hash: &WalletId,
250250
shielded_state: &ShieldedWalletState,
251251
amount: u64,
252252
recipient_address_bytes: &[u8],
@@ -338,7 +338,7 @@ pub async fn shielded_transfer(
338338
/// Returns the nullifiers of the notes that were spent.
339339
pub async fn unshield_credits(
340340
app_context: &Arc<AppContext>,
341-
_seed_hash: &WalletSeedHash,
341+
_seed_hash: &WalletId,
342342
shielded_state: &ShieldedWalletState,
343343
amount: u64,
344344
to_platform_address: PlatformAddress,
@@ -427,7 +427,7 @@ pub async fn unshield_credits(
427427
/// shielded pool.
428428
pub async fn shield_from_asset_lock(
429429
app_context: &Arc<AppContext>,
430-
seed_hash: &WalletSeedHash,
430+
seed_hash: &WalletId,
431431
shielded_state: &ShieldedWalletState,
432432
amount_duffs: u64,
433433
source_address: Option<&Address>,
@@ -558,7 +558,7 @@ pub async fn shield_from_asset_lock(
558558
/// Returns the nullifiers of the notes that were spent.
559559
pub async fn shielded_withdrawal(
560560
app_context: &Arc<AppContext>,
561-
_seed_hash: &WalletSeedHash,
561+
_seed_hash: &WalletId,
562562
shielded_state: &ShieldedWalletState,
563563
amount: u64,
564564
to_core_address: Address,

0 commit comments

Comments
 (0)