@@ -18,13 +18,14 @@ use tracing::{debug, info, trace};
18
18
19
19
use crate :: {
20
20
client:: Client ,
21
- config:: { DaLayer , DockerConfig , RollupConfig } ,
21
+ config:: { BitcoinConfig , DaLayer , DockerConfig , RollupConfig } ,
22
22
docker:: DockerEnv ,
23
23
log_provider:: LogPathProvider ,
24
24
traits:: { NodeT , Restart , SpawnOutput } ,
25
25
utils:: { get_citrea_path, get_genesis_path} ,
26
26
Result ,
27
27
} ;
28
+ use bitcoincore_rpc:: { Auth , Client as BitcoinClient } ;
28
29
29
30
#[ derive( Debug , Clone , Eq , Hash , PartialEq ) ]
30
31
pub enum NodeKind {
@@ -81,21 +82,41 @@ pub struct Node<C: Config + LogPathProvider + Send + Sync> {
81
82
spawn_output : SpawnOutput ,
82
83
config : C ,
83
84
pub client : Client ,
85
+ // Bitcoin client targetting node's wallet endpoint
86
+ pub da : BitcoinClient ,
84
87
}
85
88
86
89
impl < C > Node < C >
87
90
where
88
91
C : Config + LogPathProvider + Send + Sync + Debug ,
89
92
DockerConfig : From < C > ,
90
93
{
91
- pub async fn new ( config : & C , docker : Arc < Option < DockerEnv > > ) -> Result < Self > {
94
+ pub async fn new (
95
+ config : & C ,
96
+ da_config : & BitcoinConfig ,
97
+ docker : Arc < Option < DockerEnv > > ,
98
+ ) -> Result < Self > {
92
99
let spawn_output = <Self as NodeT >:: spawn ( config, & docker) . await ?;
93
100
94
101
let client = Client :: new ( config. rpc_bind_host ( ) , config. rpc_bind_port ( ) ) ?;
102
+
103
+ let da_rpc_url = format ! (
104
+ "http://127.0.0.1:{}/wallet/{}" ,
105
+ da_config. rpc_port,
106
+ C :: kind( )
107
+ ) ;
108
+ let da_client = BitcoinClient :: new (
109
+ & da_rpc_url,
110
+ Auth :: UserPass ( da_config. rpc_user . clone ( ) , da_config. rpc_password . clone ( ) ) ,
111
+ )
112
+ . await
113
+ . context ( "Failed to create RPC client" ) ?;
114
+
95
115
Ok ( Self {
96
116
spawn_output,
97
117
config : config. clone ( ) ,
98
118
client,
119
+ da : da_client,
99
120
} )
100
121
}
101
122
0 commit comments