1515
1616public class WalletService extends AbstractServicesConfig {
1717
18- private static final String PATH = "/{0}/bc/{1}/{2}/wallets/ {3}" ;
18+ private static final String PATH = "/{0}/bc/{1}/{2}/wallets{3}" ;
1919
2020 public WalletService (EndpointConfig endpointConfig ) {
2121 super (endpointConfig );
@@ -30,7 +30,7 @@ protected String getPath() {
3030
3131
3232 public ApiResponse importAddressAsWallet (String walletName , String privateKey , String password , String address ) {
33- String endpoint = String .format ("%s/import" , HD );
33+ String endpoint = String .format ("/ %s/import" , HD );
3434 ImportAddress importAddress = ImportAddress .importAddressAsWallet (walletName , privateKey , password , address );
3535
3636 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
@@ -46,8 +46,9 @@ public ApiResponse createWallet(List<String> addresses, String walletName) {
4646
4747 public ApiResponse createHDWallet (String walletName , int addressCount , String password ) {
4848 HDWallet hdWallet = HDWallet .createHDWallet (walletName , addressCount , password );
49+ String endpoint = String .format ("/%s" , HD );
4950
50- return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , HD ), HttpsRequestsEnum .POST .name (), endpointConfig ,
51+ return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
5152 hdWallet .toString ());
5253 }
5354
@@ -57,7 +58,9 @@ public ApiResponse listWallets() {
5758 }
5859
5960 public ApiResponse listHDWallets () {
60- return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , HD ), HttpsRequestsEnum .GET .name (), endpointConfig ,
61+ String endpoint = String .format ("/%s" , HD );
62+
63+ return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .GET .name (), endpointConfig ,
6164 null );
6265 }
6366
@@ -72,7 +75,7 @@ public ApiResponse getHDWallet(String hdWalletName) {
7275 public ApiResponse addAddressToWallet (List <String > addresses , String walletName ) {
7376 Wallet wallet = Wallet .createWallet (addresses , walletName );
7477
75- String endpoint = String .format ("%s/addresses" , walletName );
78+ String endpoint = String .format ("/ %s/addresses" , walletName );
7679 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
7780 wallet .toString ());
7881 }
@@ -88,7 +91,7 @@ public ApiResponse generateAddressHDWallet(String hdWalletName, int addressCount
8891 }
8992
9093 public ApiResponse removeAddress (String walletName , String address ) {
91- String endpoint = String .format ("%s/address/%s" , walletName , address );
94+ String endpoint = String .format ("/ %s/address/%s" , walletName , address );
9295 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .DELETE .name (), endpointConfig ,
9396 null );
9497 }
@@ -98,44 +101,46 @@ public ApiResponse deleteWallet(String wallletName) {
98101 }
99102
100103 public ApiResponse deleteHDWallet (String hdWallletName ) {
101- String endpoint = String .format ("%s/%s" , HD , hdWallletName );
104+ String endpoint = String .format ("/ %s/%s" , HD , hdWallletName );
102105 return deleteWallets (endpoint );
103106 }
104107
105108 public ApiResponse createExtendedKey (String password ) {
106- String endpoint = String .format ("%s/xpub" , HD );
109+ String endpoint = String .format ("/ %s/xpub" , HD );
107110 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
108111 XpubAddresses .createExtendedKey (password ).toString ());
109112 }
110113
111114 public ApiResponse getXpubReceiveAddresses (String xpub , int from , int to ) {
112- String endpoint = String .format ("%s/xpub/addresses/receive" , HD );
115+ String endpoint = String .format ("/ %s/xpub/addresses/receive" , HD );
113116 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
114117 XpubAddresses .getXpubAddresses (xpub , from , to ).toString ());
115118 }
116119
117120 public ApiResponse getXpubChangeAddresses (String xpub , int from , int to ) {
118- String endpoint = String .format ("%s/xpub/addresses/change" , HD );
121+ String endpoint = String .format ("/ %s/xpub/addresses/change" , HD );
119122 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
120123 XpubAddresses .getXpubAddresses (xpub , from , to ).toString ());
121124 }
122125
123126 private ApiResponse getWallet (String walletName , boolean isHD ) {
124- String endpoint = isHD ? String .format ("%s/%s" , HD , walletName ) : String .format ("%s" , walletName );
127+ String endpoint = isHD ? String .format ("/ %s/%s" , HD , walletName ) : String .format ("/ %s" , walletName );
125128 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .GET .name (), endpointConfig ,
126129 null );
127130 }
128131
129132 private ApiResponse generateAddress (String walletName , boolean isHD , String body ) {
130133 final String generateEndpoint = "addresses/generate" ;
131134
132- String endpoint = isHD ? String .format ("%s/%s/%s" , HD , walletName , generateEndpoint ) : String .format ("%s/%s" , walletName , generateEndpoint );
135+ String endpoint = isHD ? String .format ("/ %s/%s/%s" , HD , walletName , generateEndpoint ) : String .format ("/ %s/%s" , walletName , generateEndpoint );
133136 return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .POST .name (), endpointConfig ,
134137 body );
135138 }
136139
137140 private ApiResponse deleteWallets (String path ) {
138- return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , path ), HttpsRequestsEnum .DELETE .name (), endpointConfig ,
141+ String endpoint = String .format ("/%s" , path );
142+
143+ return WebServices .httpsRequest (WebServices .formatUrl (url , endpointConfig , endpoint ), HttpsRequestsEnum .DELETE .name (), endpointConfig ,
139144 null );
140145 }
141146}
0 commit comments