1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
crate::ix!();

/**
  | Wallet chain client that in addition to having
  | chain client methods for starting up, shutting
  | down, and registering RPCs, also has
  | additional methods (called by the GUI) to load
  | and create wallets.
  */
pub trait WalletClient: 
ChainClient 
+ CreateWallet
+ WalletClientLoadWallet
+ GetWalletDir
+ ListWalletDir
+ GetWallets
+ HandleLoadWallet
+ GetWalletContext { }

pub trait GetWalletClient {

    fn get_wallet_client(&mut self) -> Rc<RefCell<dyn WalletClient>>;
}

pub trait CreateWallet {

    /**
      | Create new wallet.
      |
      */
    fn create_wallet(&mut self, 
        name:                  &String,
        passphrase:            &SecureString,
        wallet_creation_flags: u64,
        error:                 &mut BilingualStr,
        warnings:              &mut Vec<BilingualStr>) -> Box<dyn WalletInterface>;
}

pub trait WalletClientLoadWallet {

    /**
      | Load existing wallet.
      |
      */
    fn load_wallet(&mut self, 
        name:     &String,
        error:    &mut BilingualStr,
        warnings: &mut Vec<BilingualStr>) -> Box<dyn WalletInterface>;
}

pub trait GetWalletDir {

    /**
      | Return default wallet directory.
      |
      */
    fn get_wallet_dir(&mut self) -> String;
}

pub trait ListWalletDir {

    /**
      | Return available wallets in wallet
      | directory.
      |
      */
    fn list_wallet_dir(&mut self) -> Vec<String>;
}

pub trait GetWallets {

    /**
      | Return interfaces for accessing wallets
      | (if any).
      |
      */
    fn get_wallets(&mut self) -> Vec<Box<dyn WalletInterface>>;
}

pub trait HandleLoadWallet {

    /**
      | Register handler for load wallet
      | messages. This callback is triggered by
      | createWallet and loadWallet above, and also
      | triggered when wallets are loaded at
      | startup or by RPC.
      */
    fn handle_load_wallet(&mut self, fn_: LoadWalletFn) -> Box<dyn Handler>;
}