1515
1616use std:: { collections:: BTreeMap , fmt:: Debug , path:: PathBuf , str:: FromStr , sync:: Arc } ;
1717
18+ use futures:: { stream:: FuturesOrdered , TryStreamExt } ;
19+ use tokio:: {
20+ sync:: mpsc:: { UnboundedReceiver , UnboundedSender } ,
21+ task:: JoinHandle ,
22+ } ;
23+
1824use common:: {
1925 address:: { Address , RpcAddress } ,
2026 chain:: { ChainConfig , GenBlock , SignedTransaction } ,
2127 primitives:: { per_thousand:: PerThousand , BlockHeight , Id } ,
2228} ;
2329use crypto:: key:: hdkd:: { child_number:: ChildNumber , u31:: U31 } ;
24- use futures:: { stream:: FuturesOrdered , TryStreamExt } ;
2530use logging:: log;
2631use node_comm:: rpc_client:: ColdWalletClient ;
2732use node_lib:: node_controller:: NodeController ;
2833use serialization:: hex_encoded:: HexEncoded ;
29- use tokio:: {
30- sync:: mpsc:: { UnboundedReceiver , UnboundedSender } ,
31- task:: JoinHandle ,
32- } ;
3334use wallet:: { account:: transaction_list:: TransactionList , wallet:: Error , WalletError } ;
3435use wallet_cli_commands:: {
3536 get_repl_command, parse_input, CommandHandler , ConsoleCommand , ManageableWalletCommand ,
3637 WalletCommand ,
3738} ;
3839use wallet_controller:: {
3940 make_cold_wallet_rpc_client,
40- types:: { Balances , WalletCreationOptions , WalletTypeArgs } ,
41+ types:: { Balances , WalletCreationOptions , WalletExtraInfo , WalletTypeArgs } ,
4142 ControllerConfig , NodeInterface , UtxoState , WalletHandlesClient ,
4243} ;
4344use wallet_rpc_client:: handles_client:: WalletRpcHandlesClient ;
@@ -361,6 +362,7 @@ impl Backend {
361362 } ;
362363
363364 let encryption = EncryptionState :: Disabled ;
365+ let wallet_extra_info = Self :: get_wallet_extra_info ( & wallet_data. controller ) . await ?;
364366
365367 let wallet_info = WalletInfo {
366368 wallet_id,
@@ -369,13 +371,31 @@ impl Backend {
369371 accounts : accounts_info,
370372 best_block,
371373 wallet_type,
374+ extra_info : wallet_extra_info,
372375 } ;
373376
374377 self . wallets . insert ( wallet_id, wallet_data) ;
375378
376379 Ok ( wallet_info)
377380 }
378381
382+ async fn get_wallet_extra_info (
383+ controller : & GuiHotColdController ,
384+ ) -> Result < WalletExtraInfo , BackendError > {
385+ let wallet_info_from_rpc = match controller {
386+ GuiHotColdController :: Hot ( wallet_rpc, _) => wallet_rpc
387+ . wallet_info ( )
388+ . await
389+ . map_err ( |err| BackendError :: WalletError ( err. to_string ( ) ) ) ?,
390+ GuiHotColdController :: Cold ( wallet_rpc, _) => wallet_rpc
391+ . wallet_info ( )
392+ . await
393+ . map_err ( |err| BackendError :: WalletError ( err. to_string ( ) ) ) ?,
394+ } ;
395+
396+ Ok ( wallet_info_from_rpc. extra_info )
397+ }
398+
379399 async fn create_wallet < N > (
380400 & mut self ,
381401 handles_client : N ,
@@ -414,10 +434,18 @@ impl Backend {
414434 overwrite_wallet_file : true ,
415435 scan_blockchain : import. should_scan_blockchain ( ) ,
416436 } ;
417- wallet_rpc
437+ let created_wallet = wallet_rpc
418438 . create_wallet ( file_path, wallet_args, options)
419439 . await
420440 . map_err ( |err| BackendError :: WalletError ( err. to_string ( ) ) ) ?;
441+ match created_wallet {
442+ wallet_controller:: types:: CreatedWallet :: UserProvidedMnemonic
443+ | wallet_controller:: types:: CreatedWallet :: NewlyGeneratedMnemonic ( _) => { }
444+ #[ cfg( feature = "trezor" ) ]
445+ wallet_controller:: types:: CreatedWallet :: TrezorDeviceSelection ( found_devices) => {
446+ return Err ( BackendError :: MultipleTrezorDevicesFound ( found_devices) )
447+ }
448+ }
421449 tokio:: spawn ( forward_events (
422450 wallet_events,
423451 wallet_service
@@ -572,13 +600,16 @@ impl Backend {
572600 }
573601 } ;
574602
603+ let wallet_extra_info = Self :: get_wallet_extra_info ( & wallet_data. controller ) . await ?;
604+
575605 let wallet_info = WalletInfo {
576606 wallet_id,
577607 path : file_path,
578608 encryption,
579609 accounts : accounts_info,
580610 best_block,
581611 wallet_type,
612+ extra_info : wallet_extra_info,
582613 } ;
583614
584615 self . wallets . insert ( wallet_id, wallet_data) ;
@@ -619,7 +650,7 @@ impl Backend {
619650 let node_rpc = wallet_service. node_rpc ( ) . clone ( ) ;
620651 let chain_config = wallet_service. chain_config ( ) . clone ( ) ;
621652 let wallet_rpc = WalletRpc :: new ( wallet_handle, node_rpc. clone ( ) , chain_config. clone ( ) ) ;
622- wallet_rpc
653+ let opened_wallet = wallet_rpc
623654 . open_wallet (
624655 file_path,
625656 None ,
@@ -629,6 +660,13 @@ impl Backend {
629660 )
630661 . await
631662 . map_err ( |err| BackendError :: WalletError ( err. to_string ( ) ) ) ?;
663+ match opened_wallet {
664+ | wallet_controller:: types:: OpenedWallet :: Opened => { }
665+ #[ cfg( feature = "trezor" ) ]
666+ wallet_controller:: types:: OpenedWallet :: TrezorDeviceSelection ( found_devices) => {
667+ return Err ( BackendError :: MultipleTrezorDevicesFound ( found_devices) )
668+ }
669+ }
632670 tokio:: spawn ( forward_events (
633671 wallet_events,
634672 wallet_service
0 commit comments