@@ -28,6 +28,17 @@ pub struct DashpayAccountKey {
2828 pub friend_identity_id : DashpayContactIdentityId ,
2929}
3030
31+ /// Key for Platform Payment accounts (DIP-17)
32+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
33+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
34+ #[ cfg_attr( feature = "bincode" , derive( Encode , Decode ) ) ]
35+ pub struct PlatformPaymentAccountKey {
36+ /// Account index (hardened)
37+ pub account : u32 ,
38+ /// Key class (hardened)
39+ pub key_class : u32 ,
40+ }
41+
3142/// Collection of accounts organized by type
3243#[ derive( Debug , Clone , Default ) ]
3344#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
@@ -61,6 +72,8 @@ pub struct AccountCollection {
6172 pub dashpay_receival_accounts : BTreeMap < DashpayAccountKey , Account > ,
6273 /// DashPay external (watch-only) accounts
6374 pub dashpay_external_accounts : BTreeMap < DashpayAccountKey , Account > ,
75+ /// Platform Payment accounts (DIP-17)
76+ pub platform_payment_accounts : BTreeMap < PlatformPaymentAccountKey , Account > ,
6477}
6578
6679impl AccountCollection {
@@ -82,6 +95,7 @@ impl AccountCollection {
8295 provider_platform_keys : None ,
8396 dashpay_receival_accounts : BTreeMap :: new ( ) ,
8497 dashpay_external_accounts : BTreeMap :: new ( ) ,
98+ platform_payment_accounts : BTreeMap :: new ( ) ,
8599 }
86100 }
87101
@@ -157,6 +171,16 @@ impl AccountCollection {
157171 } ;
158172 self . dashpay_external_accounts . insert ( key, account) ;
159173 }
174+ AccountType :: PlatformPayment {
175+ account : acc_index,
176+ key_class,
177+ } => {
178+ let key = PlatformPaymentAccountKey {
179+ account : * acc_index,
180+ key_class : * key_class,
181+ } ;
182+ self . platform_payment_accounts . insert ( key, account) ;
183+ }
160184 }
161185 Ok ( ( ) )
162186 }
@@ -240,6 +264,16 @@ impl AccountCollection {
240264 } ;
241265 self . dashpay_external_accounts . contains_key ( & key)
242266 }
267+ AccountType :: PlatformPayment {
268+ account,
269+ key_class,
270+ } => {
271+ let key = PlatformPaymentAccountKey {
272+ account : * account,
273+ key_class : * key_class,
274+ } ;
275+ self . platform_payment_accounts . contains_key ( & key)
276+ }
243277 }
244278 }
245279
@@ -293,6 +327,16 @@ impl AccountCollection {
293327 } ;
294328 self . dashpay_external_accounts . get ( & key)
295329 }
330+ AccountType :: PlatformPayment {
331+ account,
332+ key_class,
333+ } => {
334+ let key = PlatformPaymentAccountKey {
335+ account,
336+ key_class,
337+ } ;
338+ self . platform_payment_accounts . get ( & key)
339+ }
296340 }
297341 }
298342
@@ -346,6 +390,16 @@ impl AccountCollection {
346390 } ;
347391 self . dashpay_external_accounts . get_mut ( & key)
348392 }
393+ AccountType :: PlatformPayment {
394+ account,
395+ key_class,
396+ } => {
397+ let key = PlatformPaymentAccountKey {
398+ account,
399+ key_class,
400+ } ;
401+ self . platform_payment_accounts . get_mut ( & key)
402+ }
349403 }
350404 }
351405
@@ -382,6 +436,10 @@ impl AccountCollection {
382436 // Note: provider_operator_keys (BLS) and provider_platform_keys (EdDSA) are excluded
383437 // Use specific methods to access them
384438
439+ accounts. extend ( self . dashpay_receival_accounts . values ( ) ) ;
440+ accounts. extend ( self . dashpay_external_accounts . values ( ) ) ;
441+ accounts. extend ( self . platform_payment_accounts . values ( ) ) ;
442+
385443 accounts
386444 }
387445
@@ -418,6 +476,10 @@ impl AccountCollection {
418476 // Note: provider_operator_keys (BLS) and provider_platform_keys (EdDSA) are excluded
419477 // Use specific methods to access them
420478
479+ accounts. extend ( self . dashpay_receival_accounts . values_mut ( ) ) ;
480+ accounts. extend ( self . dashpay_external_accounts . values_mut ( ) ) ;
481+ accounts. extend ( self . platform_payment_accounts . values_mut ( ) ) ;
482+
421483 accounts
422484 }
423485
0 commit comments