File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ bitcoincore-rpc-json = { version = "0.19.0", path = "../json" }
27
27
28
28
log = " 0.4.5"
29
29
jsonrpc = { version = " 0.18.0" , features = [" minreq_http" ] }
30
+ minreq = { version = " 2.7.0" , features = [" json-using-serde" , " https" ] }
30
31
31
32
# Used for deserialization of JSON.
32
33
serde = " 1"
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use crate::bitcoin;
19
19
use crate :: bitcoin:: consensus:: encode;
20
20
use bitcoin:: hex:: DisplayHex ;
21
21
use jsonrpc;
22
+ use jsonrpc:: minreq_http:: MinreqHttpTransport ;
22
23
use serde;
23
24
use serde_json;
24
25
@@ -1293,6 +1294,21 @@ impl Client {
1293
1294
. map_err ( |e| super :: error:: Error :: JsonRpc ( e. into ( ) ) )
1294
1295
}
1295
1296
1297
+ pub fn new_with_minreq ( url : & str , auth : Auth ) -> Result < Self > {
1298
+ let ( user, pass) = auth. get_user_pass ( ) ?;
1299
+ if user. is_none ( ) {
1300
+ return Err ( Error :: ReturnedError ( "User is None" . to_string ( ) ) ) ;
1301
+ }
1302
+ let transport = MinreqHttpTransport :: builder ( )
1303
+ . url ( url)
1304
+ . map_err ( |e| super :: error:: Error :: JsonRpc ( e. into ( ) ) ) ?
1305
+ . basic_auth ( user. unwrap ( ) , pass)
1306
+ . build ( ) ;
1307
+ Ok ( Client {
1308
+ client : jsonrpc:: client:: Client :: with_transport ( transport) ,
1309
+ } )
1310
+ }
1311
+
1296
1312
/// Create a new Client using the given [jsonrpc::Client].
1297
1313
pub fn from_jsonrpc ( client : jsonrpc:: client:: Client ) -> Client {
1298
1314
Client {
You can’t perform that action at this time.
0 commit comments