@@ -2,15 +2,16 @@ use bitcoin::{
2
2
block:: Header , consensus, hashes:: hex:: FromHex , BlockHash , CompactTarget , MerkleBlock , Network ,
3
3
Transaction , TxMerkleNode , Txid ,
4
4
} ;
5
- use eyre:: Result ;
5
+ use eyre:: { Error , Result } ;
6
6
use reqwest:: { Client , Url } ;
7
7
use serde:: Deserialize ;
8
8
use std:: str:: FromStr ;
9
9
use tracing:: * ;
10
10
11
- const ESPLORA_MAINNET_URL : & str = "https://blockstream.info/api/ " ;
12
- const ESPLORA_TESTNET_URL : & str = "https://blockstream.info/testnet/api/ " ;
11
+ const ESPLORA_TESTNET_URL : & str = "https://btc-testnet.interlay.io " ;
12
+ const ESPLORA_MAINNET_URL : & str = "https://btc-mainnet.interlay.io " ;
13
13
const ESPLORA_LOCALHOST_URL : & str = "http://localhost:3002" ;
14
+ const ESPLORA_SIGNET_URL : & str = "https://btc-signet.gobob.xyz" ;
14
15
15
16
// https://github.com/Blockstream/electrs/blob/adedee15f1fe460398a7045b292604df2161adc0/src/util/transaction.rs#L17-L26
16
17
#[ derive( Debug , Deserialize ) ]
@@ -76,6 +77,7 @@ impl EsploraClient {
76
77
match network {
77
78
Network :: Bitcoin => ESPLORA_MAINNET_URL ,
78
79
Network :: Testnet => ESPLORA_TESTNET_URL ,
80
+ Network :: Signet => ESPLORA_SIGNET_URL ,
79
81
_ => ESPLORA_LOCALHOST_URL ,
80
82
}
81
83
. to_owned ( )
@@ -180,6 +182,18 @@ impl EsploraClient {
180
182
}
181
183
}
182
184
}
185
+
186
+ pub async fn get_bitcoin_network ( & self ) -> Result < Network > {
187
+ let url_str = self . url . as_str ( ) ;
188
+
189
+ match url_str {
190
+ _ if url_str. contains ( ESPLORA_MAINNET_URL ) => Ok ( Network :: Bitcoin ) ,
191
+ _ if url_str. contains ( ESPLORA_TESTNET_URL ) => Ok ( Network :: Testnet ) ,
192
+ _ if url_str. contains ( ESPLORA_LOCALHOST_URL ) => Ok ( Network :: Regtest ) ,
193
+ _ if url_str. contains ( ESPLORA_SIGNET_URL ) => Ok ( Network :: Signet ) ,
194
+ _ => Err ( Error :: msg ( "Unknown network for URL: {url_str}" ) ) ,
195
+ }
196
+ }
183
197
}
184
198
185
199
#[ cfg( test) ]
0 commit comments