@@ -19,6 +19,7 @@ use lexe_ln::bitcoind::LexeBitcoind;
19
19
use lexe_ln:: invoice:: { HTLCStatus , MillisatAmount , PaymentInfo } ;
20
20
use lexe_ln:: keys_manager:: LexeKeysManager ;
21
21
use lexe_ln:: test_event:: { TestEvent , TestEventSender } ;
22
+ use lexe_ln:: wallet:: LexeWallet ;
22
23
use lightning:: chain:: chaininterface:: {
23
24
BroadcasterInterface , ConfirmationTarget , FeeEstimator ,
24
25
} ;
@@ -28,49 +29,22 @@ use tracing::{debug, error, info};
28
29
29
30
use crate :: channel_manager:: NodeChannelManager ;
30
31
32
+ // We pub(crate) all the fields to prevent having to specify each field two more
33
+ // times in Self::new paramaters and in struct init syntax.
31
34
pub struct NodeEventHandler {
32
- network : Network ,
33
- lsp : ChannelPeer ,
34
- channel_manager : NodeChannelManager ,
35
- keys_manager : LexeKeysManager ,
36
- bitcoind : Arc < LexeBitcoind > ,
37
- network_graph : Arc < NetworkGraphType > ,
38
- inbound_payments : PaymentInfoStorageType ,
39
- outbound_payments : PaymentInfoStorageType ,
40
- test_event_tx : TestEventSender ,
35
+ pub ( crate ) network : Network ,
36
+ pub ( crate ) lsp : ChannelPeer ,
37
+ pub ( crate ) wallet : LexeWallet ,
38
+ pub ( crate ) channel_manager : NodeChannelManager ,
39
+ pub ( crate ) keys_manager : LexeKeysManager ,
40
+ pub ( crate ) bitcoind : Arc < LexeBitcoind > ,
41
+ pub ( crate ) network_graph : Arc < NetworkGraphType > ,
42
+ pub ( crate ) inbound_payments : PaymentInfoStorageType ,
43
+ pub ( crate ) outbound_payments : PaymentInfoStorageType ,
44
+ pub ( crate ) test_event_tx : TestEventSender ,
41
45
// XXX: remove when `EventHandler` is async
42
- blocking_task_rt : BlockingTaskRt ,
43
- shutdown : ShutdownChannel ,
44
- }
45
-
46
- impl NodeEventHandler {
47
- #[ allow( clippy:: too_many_arguments) ]
48
- pub ( crate ) fn new (
49
- network : Network ,
50
- lsp : ChannelPeer ,
51
- channel_manager : NodeChannelManager ,
52
- keys_manager : LexeKeysManager ,
53
- bitcoind : Arc < LexeBitcoind > ,
54
- network_graph : Arc < NetworkGraphType > ,
55
- inbound_payments : PaymentInfoStorageType ,
56
- outbound_payments : PaymentInfoStorageType ,
57
- test_event_tx : TestEventSender ,
58
- shutdown : ShutdownChannel ,
59
- ) -> Self {
60
- Self {
61
- network,
62
- lsp,
63
- channel_manager,
64
- keys_manager,
65
- bitcoind,
66
- network_graph,
67
- inbound_payments,
68
- outbound_payments,
69
- test_event_tx,
70
- blocking_task_rt : BlockingTaskRt :: new ( ) ,
71
- shutdown,
72
- }
73
- }
46
+ pub ( crate ) blocking_task_rt : BlockingTaskRt ,
47
+ pub ( crate ) shutdown : ShutdownChannel ,
74
48
}
75
49
76
50
impl EventHandler for NodeEventHandler {
@@ -110,6 +84,7 @@ impl EventHandler for NodeEventHandler {
110
84
// handlilng is supported
111
85
let network = self . network ;
112
86
let lsp = self . lsp . clone ( ) ;
87
+ let wallet = self . wallet . clone ( ) ;
113
88
let channel_manager = self . channel_manager . clone ( ) ;
114
89
let bitcoind = self . bitcoind . clone ( ) ;
115
90
let network_graph = self . network_graph . clone ( ) ;
@@ -126,6 +101,7 @@ impl EventHandler for NodeEventHandler {
126
101
handle_event (
127
102
network,
128
103
& lsp,
104
+ & wallet,
129
105
& channel_manager,
130
106
& bitcoind,
131
107
& network_graph,
@@ -146,6 +122,7 @@ impl EventHandler for NodeEventHandler {
146
122
pub ( crate ) async fn handle_event (
147
123
network : Network ,
148
124
lsp : & ChannelPeer ,
125
+ wallet : & LexeWallet ,
149
126
channel_manager : & NodeChannelManager ,
150
127
bitcoind : & LexeBitcoind ,
151
128
network_graph : & NetworkGraphType ,
@@ -159,6 +136,7 @@ pub(crate) async fn handle_event(
159
136
let handle_event_res = handle_event_fallible (
160
137
network,
161
138
lsp,
139
+ wallet,
162
140
channel_manager,
163
141
bitcoind,
164
142
network_graph,
@@ -180,6 +158,7 @@ pub(crate) async fn handle_event(
180
158
async fn handle_event_fallible (
181
159
network : Network ,
182
160
lsp : & ChannelPeer ,
161
+ wallet : & LexeWallet ,
183
162
channel_manager : & NodeChannelManager ,
184
163
bitcoind : & LexeBitcoind ,
185
164
network_graph : & NetworkGraphType ,
@@ -490,10 +469,7 @@ async fn handle_event_fallible(
490
469
} ) ;
491
470
}
492
471
Event :: SpendableOutputs { outputs } => {
493
- let destination_address = bitcoind
494
- . get_new_address ( )
495
- . await
496
- . context ( "Could not get new address" ) ?;
472
+ let destination_address = wallet. get_new_address ( ) ?;
497
473
let output_descriptors = & outputs. iter ( ) . collect :: < Vec < _ > > ( ) ;
498
474
let tx_feerate = bitcoind
499
475
. get_est_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
0 commit comments