Skip to content
44 changes: 44 additions & 0 deletions key-wallet-ffi/src/address_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ fn get_managed_account_by_type<'a>(
AccountType::AssetLockShieldedAddressTopUp => {
collection.asset_lock_shielded_address_topup.as_ref()
}
AccountType::BlockchainIdentitiesECDSA => collection.blockchain_identities_ecdsa.as_ref(),
AccountType::BlockchainIdentitiesECDSAHash160 => {
collection.blockchain_identities_ecdsa_hash160.as_ref()
}
AccountType::BlockchainIdentitiesBLS => collection.blockchain_identities_bls.as_ref(),
AccountType::BlockchainIdentitiesBLSHash160 => {
collection.blockchain_identities_bls_hash160.as_ref()
}
AccountType::ProviderVotingKeys => collection.provider_voting_keys.as_ref(),
AccountType::ProviderOwnerKeys => collection.provider_owner_keys.as_ref(),
AccountType::ProviderOperatorKeys => collection.provider_operator_keys.as_ref(),
Expand Down Expand Up @@ -102,6 +110,14 @@ fn get_managed_account_by_type_mut<'a>(
AccountType::AssetLockShieldedAddressTopUp => {
collection.asset_lock_shielded_address_topup.as_mut()
}
AccountType::BlockchainIdentitiesECDSA => collection.blockchain_identities_ecdsa.as_mut(),
AccountType::BlockchainIdentitiesECDSAHash160 => {
collection.blockchain_identities_ecdsa_hash160.as_mut()
}
AccountType::BlockchainIdentitiesBLS => collection.blockchain_identities_bls.as_mut(),
AccountType::BlockchainIdentitiesBLSHash160 => {
collection.blockchain_identities_bls_hash160.as_mut()
}
AccountType::ProviderVotingKeys => collection.provider_voting_keys.as_mut(),
AccountType::ProviderOwnerKeys => collection.provider_owner_keys.as_mut(),
AccountType::ProviderOperatorKeys => collection.provider_operator_keys.as_mut(),
Expand Down Expand Up @@ -788,6 +804,34 @@ pub unsafe extern "C" fn managed_wallet_mark_address_used(
}
}
}
if !found {
if let Some(account) = &mut collection.blockchain_identities_ecdsa {
if account.mark_address_used(&address) {
found = true;
}
}
}
if !found {
if let Some(account) = &mut collection.blockchain_identities_ecdsa_hash160 {
if account.mark_address_used(&address) {
found = true;
}
}
}
if !found {
if let Some(account) = &mut collection.blockchain_identities_bls {
if account.mark_address_used(&address) {
found = true;
}
}
}
if !found {
if let Some(account) = &mut collection.blockchain_identities_bls_hash160 {
if account.mark_address_used(&address) {
found = true;
}
}
}
if !found {
for account in collection.dashpay_receival_accounts.values_mut() {
if account.mark_address_used(&address) {
Expand Down
32 changes: 32 additions & 0 deletions key-wallet-ffi/src/managed_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ pub unsafe extern "C" fn managed_wallet_get_account(
AccountType::AssetLockShieldedAddressTopUp => {
managed_collection.asset_lock_shielded_address_topup.as_ref()
}
AccountType::BlockchainIdentitiesECDSA => {
managed_collection.blockchain_identities_ecdsa.as_ref()
}
AccountType::BlockchainIdentitiesECDSAHash160 => {
managed_collection.blockchain_identities_ecdsa_hash160.as_ref()
}
AccountType::BlockchainIdentitiesBLS => {
managed_collection.blockchain_identities_bls.as_ref()
}
AccountType::BlockchainIdentitiesBLSHash160 => {
managed_collection.blockchain_identities_bls_hash160.as_ref()
}
AccountType::ProviderVotingKeys => managed_collection.provider_voting_keys.as_ref(),
AccountType::ProviderOwnerKeys => managed_collection.provider_owner_keys.as_ref(),
AccountType::ProviderOperatorKeys => managed_collection.provider_operator_keys.as_ref(),
Expand Down Expand Up @@ -563,6 +575,14 @@ pub unsafe extern "C" fn managed_core_account_get_account_type(
AccountType::IdentityInvitation => FFIAccountType::IdentityInvitation,
AccountType::AssetLockAddressTopUp => FFIAccountType::AssetLockAddressTopUp,
AccountType::AssetLockShieldedAddressTopUp => FFIAccountType::AssetLockShieldedAddressTopUp,
AccountType::BlockchainIdentitiesECDSA => FFIAccountType::BlockchainIdentitiesECDSA,
AccountType::BlockchainIdentitiesECDSAHash160 => {
FFIAccountType::BlockchainIdentitiesECDSAHash160
}
AccountType::BlockchainIdentitiesBLS => FFIAccountType::BlockchainIdentitiesBLS,
AccountType::BlockchainIdentitiesBLSHash160 => {
FFIAccountType::BlockchainIdentitiesBLSHash160
}
AccountType::ProviderVotingKeys => FFIAccountType::ProviderVotingKeys,
AccountType::ProviderOwnerKeys => FFIAccountType::ProviderOwnerKeys,
AccountType::ProviderOperatorKeys => FFIAccountType::ProviderOperatorKeys,
Expand Down Expand Up @@ -1020,6 +1040,18 @@ pub unsafe extern "C" fn managed_core_account_get_address_pool(
ManagedAccountType::AssetLockShieldedAddressTopUp {
addresses,
} => addresses,
ManagedAccountType::BlockchainIdentitiesECDSA {
addresses,
} => addresses,
ManagedAccountType::BlockchainIdentitiesECDSAHash160 {
addresses,
} => addresses,
ManagedAccountType::BlockchainIdentitiesBLS {
addresses,
} => addresses,
ManagedAccountType::BlockchainIdentitiesBLSHash160 {
addresses,
} => addresses,
ManagedAccountType::ProviderVotingKeys {
addresses,
} => addresses,
Expand Down
68 changes: 68 additions & 0 deletions key-wallet-ffi/src/transaction_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,74 @@ pub unsafe extern "C" fn managed_wallet_check_transaction(
ffi_accounts.push(ffi_match);
continue;
}
CoreAccountTypeMatch::BlockchainIdentitiesECDSA {
involved_addresses,
} => {
let ffi_match = FFIAccountMatch {
account_type: 16, // BlockchainIdentitiesECDSA
account_index: 0,
registration_index: 0,
received: account_match.received,
sent: account_match.sent,
external_addresses_count: involved_addresses.len() as c_uint,
internal_addresses_count: 0,
has_external_addresses: !involved_addresses.is_empty(),
has_internal_addresses: false,
};
ffi_accounts.push(ffi_match);
continue;
}
CoreAccountTypeMatch::BlockchainIdentitiesECDSAHash160 {
involved_addresses,
} => {
let ffi_match = FFIAccountMatch {
account_type: 17, // BlockchainIdentitiesECDSAHash160
account_index: 0,
registration_index: 0,
received: account_match.received,
sent: account_match.sent,
external_addresses_count: involved_addresses.len() as c_uint,
internal_addresses_count: 0,
has_external_addresses: !involved_addresses.is_empty(),
has_internal_addresses: false,
};
ffi_accounts.push(ffi_match);
continue;
}
CoreAccountTypeMatch::BlockchainIdentitiesBLS {
involved_addresses,
} => {
let ffi_match = FFIAccountMatch {
account_type: 18, // BlockchainIdentitiesBLS
account_index: 0,
registration_index: 0,
received: account_match.received,
sent: account_match.sent,
external_addresses_count: involved_addresses.len() as c_uint,
internal_addresses_count: 0,
has_external_addresses: !involved_addresses.is_empty(),
has_internal_addresses: false,
};
ffi_accounts.push(ffi_match);
continue;
}
CoreAccountTypeMatch::BlockchainIdentitiesBLSHash160 {
involved_addresses,
} => {
let ffi_match = FFIAccountMatch {
account_type: 19, // BlockchainIdentitiesBLSHash160
account_index: 0,
registration_index: 0,
received: account_match.received,
sent: account_match.sent,
external_addresses_count: involved_addresses.len() as c_uint,
internal_addresses_count: 0,
has_external_addresses: !involved_addresses.is_empty(),
has_internal_addresses: false,
};
ffi_accounts.push(ffi_match);
continue;
}
CoreAccountTypeMatch::ProviderVotingKeys {
involved_addresses,
} => {
Expand Down
32 changes: 32 additions & 0 deletions key-wallet-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ pub enum FFIAccountType {
AssetLockAddressTopUp = 14,
/// Asset lock shielded address top-up funding (subfeature 5)
AssetLockShieldedAddressTopUp = 15,
/// Blockchain identity ECDSA keys (DIP-9) - Path: m/9'/coinType'/5'/0'
BlockchainIdentitiesECDSA = 16,
/// Blockchain identity ECDSA Hash160 keys (DIP-9) - Path: m/9'/coinType'/5'/1'
BlockchainIdentitiesECDSAHash160 = 17,
/// Blockchain identity BLS keys (DIP-9) - Path: m/9'/coinType'/5'/2'
BlockchainIdentitiesBLS = 18,
/// Blockchain identity BLS Hash160 keys (DIP-9) - Path: m/9'/coinType'/5'/3'
BlockchainIdentitiesBLSHash160 = 19,
}

impl FFIAccountType {
Expand Down Expand Up @@ -295,6 +303,18 @@ impl FFIAccountType {
FFIAccountType::AssetLockShieldedAddressTopUp => {
key_wallet::AccountType::AssetLockShieldedAddressTopUp
}
FFIAccountType::BlockchainIdentitiesECDSA => {
key_wallet::AccountType::BlockchainIdentitiesECDSA
}
FFIAccountType::BlockchainIdentitiesECDSAHash160 => {
key_wallet::AccountType::BlockchainIdentitiesECDSAHash160
}
FFIAccountType::BlockchainIdentitiesBLS => {
key_wallet::AccountType::BlockchainIdentitiesBLS
}
FFIAccountType::BlockchainIdentitiesBLSHash160 => {
key_wallet::AccountType::BlockchainIdentitiesBLSHash160
}
FFIAccountType::ProviderVotingKeys => key_wallet::AccountType::ProviderVotingKeys,
FFIAccountType::ProviderOwnerKeys => key_wallet::AccountType::ProviderOwnerKeys,
FFIAccountType::ProviderOperatorKeys => key_wallet::AccountType::ProviderOperatorKeys,
Expand Down Expand Up @@ -380,6 +400,18 @@ impl FFIAccountType {
key_wallet::AccountType::AssetLockShieldedAddressTopUp => {
(FFIAccountType::AssetLockShieldedAddressTopUp, 0, None)
}
key_wallet::AccountType::BlockchainIdentitiesECDSA => {
(FFIAccountType::BlockchainIdentitiesECDSA, 0, None)
}
key_wallet::AccountType::BlockchainIdentitiesECDSAHash160 => {
(FFIAccountType::BlockchainIdentitiesECDSAHash160, 0, None)
}
key_wallet::AccountType::BlockchainIdentitiesBLS => {
(FFIAccountType::BlockchainIdentitiesBLS, 0, None)
}
key_wallet::AccountType::BlockchainIdentitiesBLSHash160 => {
(FFIAccountType::BlockchainIdentitiesBLSHash160, 0, None)
}
key_wallet::AccountType::ProviderVotingKeys => {
(FFIAccountType::ProviderVotingKeys, 0, None)
}
Expand Down
5 changes: 3 additions & 2 deletions key-wallet-manager/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ fn test_account_management() {
assert!(result.is_ok());
assert_eq!(manager.monitor_revision(), 2);

// Get accounts from wallet - Default creates 11 accounts (including PlatformPayment), plus the one we added
// Get accounts from wallet - Default creates 15 accounts (including PlatformPayment
// and 4 BlockchainIdentities variants), plus the one we added
let accounts = manager.get_accounts(&wallet_id);
assert!(accounts.is_ok());
assert_eq!(accounts.unwrap().len(), 12); // 11 from Default + 1 we added
assert_eq!(accounts.unwrap().len(), 16); // 15 from Default + 1 we added
}

#[test]
Expand Down
Loading
Loading