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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
crate::ix!();

//-------------------------------------------[.cpp/bitcoin/src/node/interfaces.cpp]

//-------------------------------------------[.cpp/bitcoin/src/util/ui_change_type.h]

//-------------------------------------------[.cpp/bitcoin/src/wallet/interfaces.cpp]

/**
  | Return implementation of Init interface
  | for the wallet process.
  |
  */
pub fn make_wallet_init(
        argc:        i32,
        argv:        &[*mut u8],
        exit_status: &mut i32) -> Box<dyn Init> {
    
    todo!();
        /*
        
        */
}

/**
  | Return implementation of Init interface
  | for the gui process.
  |
  */
pub fn make_gui_init(
        argc: i32,
        argv: &[*mut u8]) -> Box<dyn Init> {
    
    todo!();
        /*
        
        */
}

pub struct NotificationsHandlerImpl {
    proxy: Arc<NotificationsProxy>,
}

impl Handler for NotificationsHandlerImpl {

}

impl Drop for NotificationsHandlerImpl {
    fn drop(&mut self) {
        todo!();
        /*
            disconnect();
        */
    }
}

impl From<Arc<dyn ChainNotifications>> for NotificationsHandlerImpl {

    fn from(notifications: Arc<dyn ChainNotifications>) -> Self {
    
        todo!();
        /*


            : m_proxy(std::make_shared<NotificationsProxy>(std::move(notifications)))

            RegisterSharedValidationInterface(m_proxy);
        */
    }
}
    
impl Disconnect for NotificationsHandlerImpl {
    fn disconnect(&mut self)  {
        
        todo!();
        /*
            if (m_proxy) {
                UnregisterSharedValidationInterface(m_proxy);
                m_proxy.reset();
            }
        */
    }
}

pub struct NotificationsProxy {
    notifications: Arc<dyn ChainNotifications>,
}

impl From<Arc<dyn ChainNotifications>> for NotificationsProxy {
    
    fn from(notifications: Arc<dyn ChainNotifications>) -> Self {
    
        todo!();
        /*
        : notifications(std::move(notifications)),

        
        */
    }
}

impl ValidationInterface for NotificationsProxy { }

impl NewPoWValidBlock for NotificationsProxy { }
impl BlockChecked     for NotificationsProxy { }

impl TransactionAddedToMempool for NotificationsProxy {
    fn transaction_added_to_mempool(&mut self, 
        tx:               &TransactionRef,
        mempool_sequence: u64)  {
        
        todo!();
        /*
            m_notifications->transactionAddedToMempool(tx, mempool_sequence);
        */
    }
}
    
impl TransactionRemovedFromMempool for NotificationsProxy {

    fn transaction_removed_from_mempool(&mut self, 
        tx:               &TransactionRef,
        reason:           MemPoolRemovalReason,
        mempool_sequence: u64)  {
        
        todo!();
        /*
            m_notifications->transactionRemovedFromMempool(tx, reason, mempool_sequence);
        */
    }
}

impl BlockConnected for NotificationsProxy {

    fn block_connected(&mut self, 
        block: Arc<Block>,
        index: Arc<BlockIndex>)  {
        
        todo!();
        /*
            m_notifications->blockConnected(*block, index->nHeight);
        */
    }
}
    
impl BlockDisconnected for NotificationsProxy {
    fn block_disconnected(&mut self, 
        block: Arc<Block>,
        index: Arc<BlockIndex>)  {
        
        todo!();
        /*
            m_notifications->blockDisconnected(*block, index->nHeight);
        */
    }
}
    
impl UpdatedBlockTip for NotificationsProxy {

    fn updated_block_tip(&mut self, 
        index:      Option<Arc<BlockIndex>>,
        fork_index: Option<Arc<BlockIndex>>,
        is_ibd:     bool)  {
        
        todo!();
        /*
            m_notifications->updatedBlockTip();
        */
    }
}
    
impl ChainStateFlushed for NotificationsProxy {
    fn chain_state_flushed(&mut self, locator: &BlockLocator)  {
        
        todo!();
        /*
            m_notifications->chainStateFlushed(locator);
        */
    }
}

///-----------------------
pub struct RpcHandlerImpl {
    command:         RPCCommand,
    wrapped_command: *const RPCCommand,
}

impl Handler for RpcHandlerImpl {

}

impl Drop for RpcHandlerImpl {
    fn drop(&mut self) {
        todo!();
        /*
            disconnect();
        */
    }
}

impl From<&RPCCommand> for RpcHandlerImpl {
    
    fn from(command: &RPCCommand) -> Self {
    
        todo!();
        /*
        : command(command),
        : wrapped_command(&command),

            m_command.actor = [this](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
                if (!m_wrapped_command) return false;
                try {
                    return m_wrapped_command->actor(request, result, last_handler);
                } catch (const UniValue& e) {
                    // If this is not the last handler and a wallet not found
                    // exception was thrown, return false so the next handler can
                    // try to handle the request. Otherwise, reraise the exception.
                    if (!last_handler) {
                        const UniValue& code = e["code"];
                        if (code.isNum() && code.get_int() == RPC_WALLET_NOT_FOUND) {
                            return false;
                        }
                    }
                    throw;
                }
            };
            ::tableRPC.appendCommand(m_command.name, &m_command);
        */
    }
}

impl Disconnect for RpcHandlerImpl {

    fn disconnect(&mut self)  {
        
        todo!();
        /*
            if (m_wrapped_command) {
                m_wrapped_command = nullptr;
                ::tableRPC.removeCommand(m_command.name, &m_command);
            }
        */
    }
}