Commit b186c3c8 authored by zeroleak's avatar zeroleak
Browse files

API: add "refresh" parameter to GET /rest/utxos

parent 55f08b70
......@@ -92,6 +92,9 @@ Response:
## UTXO controls
### List utxos: ```GET /rest/utxos```
Parameters:
* refresh (optional): "true" to refresh utxos
Response:
```
{
......
package com.samourai.whirlpool.cli.api.controllers.wallet;
package com.samourai.whirlpool.cli.api.controllers.utxo;
import com.samourai.whirlpool.cli.api.controllers.AbstractRestController;
import com.samourai.whirlpool.cli.api.protocol.CliApiEndpoint;
......@@ -7,19 +7,23 @@ import com.samourai.whirlpool.cli.services.CliWalletService;
import com.samourai.whirlpool.client.wallet.WhirlpoolWallet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
public class UtxosListController extends AbstractRestController {
@Autowired private CliWalletService cliWalletService;
@RequestMapping(value = CliApiEndpoint.REST_UTXOS, method = RequestMethod.GET)
public ApiWalletUtxosResponse wallet(@RequestHeader HttpHeaders headers) throws Exception {
public ApiWalletUtxosResponse wallet(
@RequestHeader HttpHeaders headers,
@RequestParam(value = "refresh", defaultValue = "false") boolean refresh)
throws Exception {
checkHeaders(headers);
WhirlpoolWallet whirlpoolWallet = cliWalletService.getSessionWallet();
if (refresh) {
// wait for utxo refresh
whirlpoolWallet.refreshUtxos(true);
}
return new ApiWalletUtxosResponse(whirlpoolWallet);
}
}
......@@ -160,7 +160,7 @@ public class WalletAggregateService {
return false;
}
ClientUtils.sleepRefreshUtxos(params);
ClientUtils.sleepUtxosDelay(params);
log.info(" • Consolidating deposit...");
boolean success = toWallet(depositWallet, depositWallet, feeSatPerByte, backendApi);
return success;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment