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" }
2727
2828log = " 0.4.5"
2929jsonrpc = { version = " 0.18.0" , features = [" minreq_http" ] }
30+ minreq = { version = " 2.7.0" , features = [" json-using-serde" , " https" ] }
3031
3132# Used for deserialization of JSON.
3233serde = " 1"
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use crate::bitcoin;
1919use crate :: bitcoin:: consensus:: encode;
2020use bitcoin:: hex:: DisplayHex ;
2121use jsonrpc;
22+ use jsonrpc:: minreq_http:: MinreqHttpTransport ;
2223use serde;
2324use serde_json;
2425
@@ -1293,6 +1294,21 @@ impl Client {
12931294 . map_err ( |e| super :: error:: Error :: JsonRpc ( e. into ( ) ) )
12941295 }
12951296
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+
12961312 /// Create a new Client using the given [jsonrpc::Client].
12971313 pub fn from_jsonrpc ( client : jsonrpc:: client:: Client ) -> Client {
12981314 Client {
You can’t perform that action at this time.
0 commit comments