Skip to content

Commit 713e05e

Browse files
committed
add ExplorerApi
1 parent bba4ead commit 713e05e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.samourai.wallet.api.explorer;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
public class ExplorerApi {
7+
private Logger log = LoggerFactory.getLogger(ExplorerApi.class);
8+
9+
private static final String EXPLORER_MAINNET = "https://blockstream.info/";
10+
private static final String EXPLORER_TESTNET = "https://blockstream.info/testnet/";
11+
12+
private static final String URL_TX = "tx/";
13+
private static final String URL_ADDRESS = "address/";
14+
15+
private boolean testnet;
16+
17+
public ExplorerApi(boolean testnet) {
18+
this.testnet = testnet;
19+
}
20+
21+
public String getUrl() {
22+
return testnet ? EXPLORER_TESTNET : EXPLORER_MAINNET;
23+
}
24+
25+
public String getUrlTx() {
26+
return getUrl()+URL_TX;
27+
}
28+
29+
public String getUrlTx(String txid) {
30+
return getUrl()+URL_TX+txid;
31+
}
32+
33+
public String getUrlAddress() {
34+
return getUrl()+URL_ADDRESS;
35+
}
36+
37+
public String getUrlAddress(String address) {
38+
return getUrl()+URL_ADDRESS+address;
39+
}
40+
}

0 commit comments

Comments
 (0)