@@ -321,26 +321,41 @@ def test_key_iteration(self):
321321 wif = 'L1AAHuEC7XuDM7pJ7yHLEqYK1QspMo8n1kgxyZVdgvEpVC1rkUrM'
322322 pk = '03b428da420cd337c7208ed42c5331ebb407bb59ffbe3dc27936a227c619804284'
323323 pk_u = '0414fc03b8df87cd7b872996810db8458d61da8448e531569c8517b469a119d267be5645686309c6e6736dbd93940707cc9143d3cf29f1b877ff340e2cb2d259cf'
324+ policy_keys = wally_map_from_dict ({f'@{ i } ' : xpub for i ,xpub in enumerate ([k1 ])})
325+ P = POLICY
326+
324327 # Valid args
325- for descriptor , expected in [
328+ for flags , descriptor , expected , child_path in [
326329 # Bip32 xpub
327- (f'pkh({ k1 } )' , k1 ),
330+ (0 , f'pkh({ k1 } )' , k1 , '' ),
331+ (0 , f'pkh({ k1 } /*)' , k1 , '*' ),
332+ (0 , f'pkh({ k1 } /0/1/2/*)' , k1 , '0/1/2/*' ),
333+ (0 , f'pkh({ k1 } /<0;1>/*)' , k1 , '<0;1>/*' ),
334+ # Bip32 xpub (as policy)
335+ (P , 'pkh(@0/*)' , k1 , '*' ),
336+ (P , 'pkh(@0/**)' , k1 , '<0;1>/*' ),
337+ (P , 'pkh(@0/<0;1>/*)' , k1 , '<0;1>/*' ),
328338 # BIP32 xprv
329- (f'pkh({ k2 } )' , k2 ),
339+ (0 , f'pkh({ k2 } )' , k2 , '' ),
330340 # WIF
331- (f'pkh({ wif } )' , wif ),
341+ (0 , f'pkh({ wif } )' , wif , '' ),
332342 # Hex pubkey, compressed
333- (f'pk({ pk } )' , pk ),
343+ (0 , f'pk({ pk } )' , pk , '' ),
334344 # Hex pubkey, uncompressed
335- (f'pk({ pk_u } )' , pk_u ),
345+ (0 , f'pk({ pk_u } )' , pk_u , '' ),
336346 ]:
337347 d = c_void_p ()
338- ret = wally_descriptor_parse (descriptor , None , NETWORK_BTC_MAIN , 0 , d )
348+ keys = policy_keys if flags & P else None
349+ ret = wally_descriptor_parse (descriptor , keys , NETWORK_BTC_MAIN , flags , d )
339350 self .assertEqual (ret , WALLY_OK )
340351 ret , num_keys = wally_descriptor_get_num_keys (d )
341352 self .assertEqual ((ret , num_keys ), (WALLY_OK , 1 ))
342353 ret , key_str = wally_descriptor_get_key (d , 0 )
343354 self .assertEqual ((ret , key_str ), (WALLY_OK , expected ))
355+ ret , path_len = wally_descriptor_get_key_child_path_str_len (d , 0 )
356+ self .assertEqual ((ret , path_len ), (WALLY_OK , len (child_path )))
357+ ret , path_str = wally_descriptor_get_key_child_path_str (d , 0 )
358+ self .assertEqual ((ret , path_str ), (WALLY_OK , child_path ))
344359 wally_descriptor_free (d )
345360
346361
0 commit comments