Skip to content
Open
16 changes: 16 additions & 0 deletions key-wallet-ffi/include/key_wallet_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ typedef enum {
Asset lock shielded address top-up funding (subfeature 5)
*/
ASSET_LOCK_SHIELDED_ADDRESS_TOP_UP = 15,
/*
Blockchain identity ECDSA keys (DIP-9) - Path: m/9'/coinType'/5'/0'
*/
BLOCKCHAIN_IDENTITIES_ECDSA = 16,
/*
Blockchain identity ECDSA Hash160 keys (DIP-9) - Path: m/9'/coinType'/5'/1'
*/
BLOCKCHAIN_IDENTITIES_ECDSA_HASH160 = 17,
/*
Blockchain identity BLS keys (DIP-9) - Path: m/9'/coinType'/5'/2'
*/
BLOCKCHAIN_IDENTITIES_BLS = 18,
/*
Blockchain identity BLS Hash160 keys (DIP-9) - Path: m/9'/coinType'/5'/3'
*/
BLOCKCHAIN_IDENTITIES_BLS_HASH160 = 19,
} FFIAccountType;

/*
Expand Down
16 changes: 16 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()
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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
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 @@ -1039,6 +1059,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 @@ -382,6 +382,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
Comment thread
lklimek marked this conversation as resolved.
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 @@ -194,6 +194,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,
Comment thread
lklimek marked this conversation as resolved.
}

impl FFIAccountType {
Expand Down Expand Up @@ -228,6 +236,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 @@ -313,6 +333,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
82 changes: 82 additions & 0 deletions key-wallet/src/account/account_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ pub struct AccountCollection {
pub asset_lock_address_topup: Option<Account>,
/// Asset lock shielded address top-up account (optional)
pub asset_lock_shielded_address_topup: Option<Account>,
/// Blockchain identities ECDSA account
pub blockchain_identities_ecdsa: Option<Account>,
/// Blockchain identities ECDSA_HASH160 account
pub blockchain_identities_ecdsa_hash160: Option<Account>,
/// Blockchain identities BLS account
pub blockchain_identities_bls: Option<Account>,
/// Blockchain identities BLS_HASH160 account
pub blockchain_identities_bls_hash160: Option<Account>,
/// Provider voting keys (optional)
pub provider_voting_keys: Option<Account>,
/// Provider owner keys (optional)
Expand Down Expand Up @@ -93,6 +101,10 @@ impl AccountCollection {
identity_invitation: None,
asset_lock_address_topup: None,
asset_lock_shielded_address_topup: None,
blockchain_identities_ecdsa: None,
blockchain_identities_ecdsa_hash160: None,
blockchain_identities_bls: None,
blockchain_identities_bls_hash160: None,
provider_voting_keys: None,
provider_owner_keys: None,
#[cfg(feature = "bls")]
Expand Down Expand Up @@ -147,6 +159,18 @@ impl AccountCollection {
AccountType::AssetLockShieldedAddressTopUp => {
self.asset_lock_shielded_address_topup = Some(account);
}
AccountType::BlockchainIdentitiesECDSA => {
self.blockchain_identities_ecdsa = Some(account);
}
AccountType::BlockchainIdentitiesECDSAHash160 => {
self.blockchain_identities_ecdsa_hash160 = Some(account);
}
AccountType::BlockchainIdentitiesBLS => {
self.blockchain_identities_bls = Some(account);
}
AccountType::BlockchainIdentitiesBLSHash160 => {
self.blockchain_identities_bls_hash160 = Some(account);
}
AccountType::ProviderVotingKeys => {
self.provider_voting_keys = Some(account);
}
Expand Down Expand Up @@ -246,6 +270,14 @@ impl AccountCollection {
AccountType::AssetLockShieldedAddressTopUp => {
self.asset_lock_shielded_address_topup.is_some()
}
AccountType::BlockchainIdentitiesECDSA => self.blockchain_identities_ecdsa.is_some(),
AccountType::BlockchainIdentitiesECDSAHash160 => {
self.blockchain_identities_ecdsa_hash160.is_some()
}
AccountType::BlockchainIdentitiesBLS => self.blockchain_identities_bls.is_some(),
AccountType::BlockchainIdentitiesBLSHash160 => {
self.blockchain_identities_bls_hash160.is_some()
}
AccountType::ProviderVotingKeys => self.provider_voting_keys.is_some(),
AccountType::ProviderOwnerKeys => self.provider_owner_keys.is_some(),
#[cfg(feature = "bls")]
Expand Down Expand Up @@ -319,6 +351,14 @@ impl AccountCollection {
AccountType::AssetLockShieldedAddressTopUp => {
self.asset_lock_shielded_address_topup.as_ref()
}
AccountType::BlockchainIdentitiesECDSA => self.blockchain_identities_ecdsa.as_ref(),
AccountType::BlockchainIdentitiesECDSAHash160 => {
self.blockchain_identities_ecdsa_hash160.as_ref()
}
AccountType::BlockchainIdentitiesBLS => self.blockchain_identities_bls.as_ref(),
AccountType::BlockchainIdentitiesBLSHash160 => {
self.blockchain_identities_bls_hash160.as_ref()
}
AccountType::ProviderVotingKeys => self.provider_voting_keys.as_ref(),
AccountType::ProviderOwnerKeys => self.provider_owner_keys.as_ref(),
AccountType::ProviderOperatorKeys => None, // BLSAccount, use bls_account_of_type
Expand Down Expand Up @@ -386,6 +426,14 @@ impl AccountCollection {
AccountType::AssetLockShieldedAddressTopUp => {
self.asset_lock_shielded_address_topup.as_mut()
}
AccountType::BlockchainIdentitiesECDSA => self.blockchain_identities_ecdsa.as_mut(),
AccountType::BlockchainIdentitiesECDSAHash160 => {
self.blockchain_identities_ecdsa_hash160.as_mut()
}
AccountType::BlockchainIdentitiesBLS => self.blockchain_identities_bls.as_mut(),
AccountType::BlockchainIdentitiesBLSHash160 => {
self.blockchain_identities_bls_hash160.as_mut()
}
AccountType::ProviderVotingKeys => self.provider_voting_keys.as_mut(),
AccountType::ProviderOwnerKeys => self.provider_owner_keys.as_mut(),
AccountType::ProviderOperatorKeys => None, // BLSAccount, use bls_account_of_type_mut
Expand Down Expand Up @@ -457,6 +505,19 @@ impl AccountCollection {
accounts.push(account);
}

if let Some(account) = &self.blockchain_identities_ecdsa {
accounts.push(account);
}
if let Some(account) = &self.blockchain_identities_ecdsa_hash160 {
accounts.push(account);
}
if let Some(account) = &self.blockchain_identities_bls {
accounts.push(account);
}
if let Some(account) = &self.blockchain_identities_bls_hash160 {
accounts.push(account);
}

if let Some(account) = &self.provider_voting_keys {
accounts.push(account);
}
Expand Down Expand Up @@ -505,6 +566,19 @@ impl AccountCollection {
accounts.push(account);
}

if let Some(account) = &mut self.blockchain_identities_ecdsa {
accounts.push(account);
}
if let Some(account) = &mut self.blockchain_identities_ecdsa_hash160 {
accounts.push(account);
}
if let Some(account) = &mut self.blockchain_identities_bls {
accounts.push(account);
}
if let Some(account) = &mut self.blockchain_identities_bls_hash160 {
accounts.push(account);
}

if let Some(account) = &mut self.provider_voting_keys {
accounts.push(account);
}
Expand Down Expand Up @@ -607,6 +681,10 @@ impl AccountCollection {
&& self.identity_invitation.is_none()
&& self.asset_lock_address_topup.is_none()
&& self.asset_lock_shielded_address_topup.is_none()
&& self.blockchain_identities_ecdsa.is_none()
&& self.blockchain_identities_ecdsa_hash160.is_none()
&& self.blockchain_identities_bls.is_none()
&& self.blockchain_identities_bls_hash160.is_none()
&& self.provider_voting_keys.is_none()
&& self.provider_owner_keys.is_none();

Expand Down Expand Up @@ -634,6 +712,10 @@ impl AccountCollection {
self.identity_invitation = None;
self.asset_lock_address_topup = None;
self.asset_lock_shielded_address_topup = None;
self.blockchain_identities_ecdsa = None;
self.blockchain_identities_ecdsa_hash160 = None;
self.blockchain_identities_bls = None;
self.blockchain_identities_bls_hash160 = None;
self.provider_voting_keys = None;
self.provider_owner_keys = None;
#[cfg(feature = "bls")]
Expand Down
Loading
Loading