Commit 05463493 authored by zeroleak's avatar zeroleak
Browse files

API: add tx0 for multiple utxos

parent 19ec025f
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.samourai.code.whirlpool</groupId>
<artifactId>whirlpool-client-cli</artifactId>
<version>0.10.10</version>
<version>develop-SNAPSHOT</version>
<name>whirlpool-client-cli</name>
<properties>
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
......@@ -17,7 +17,7 @@
<dependency>
<groupId>io.samourai.code.whirlpool</groupId>
<artifactId>whirlpool-client</artifactId>
<version>0.23.24</version>
<version>develop-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
......
......@@ -38,7 +38,7 @@ public class UtxoController extends AbstractRestController {
List<WhirlpoolUtxo> whirlpoolUtos = new LinkedList<>();
for (ApiUtxoRef utxoRef : utxoRefs) {
// find utxo
WhirlpoolUtxo whirlpoolUtxo = findUtxo(utxoRef.getHash(), utxoRef.getIndex());
WhirlpoolUtxo whirlpoolUtxo = findUtxo(utxoRef.hash, utxoRef.index);
if (whirlpoolUtxo == null) {
throw new NotifiableException("Utxo not found: " + utxoRef.toString());
}
......@@ -67,7 +67,7 @@ public class UtxoController extends AbstractRestController {
return apiUtxo;
}
@RequestMapping(value = CliApiEndpoint.REST_UTXO_TX0_PREVIEW, method = RequestMethod.POST)
@RequestMapping(value = CliApiEndpoint.REST_TX0_PREVIEW, method = RequestMethod.POST)
public ApiTx0PreviewResponse tx0Preview(
@RequestHeader HttpHeaders headers, @Valid @RequestBody ApiTx0PreviewRequest payload)
throws Exception {
......@@ -89,22 +89,7 @@ public class UtxoController extends AbstractRestController {
return new ApiTx0PreviewResponse(tx0Preview);
}
@Deprecated // TODO remove on next release
@RequestMapping(value = CliApiEndpoint.REST_UTXO_TX0_SINGLE_PREVIEW, method = RequestMethod.POST)
public ApiTx0PreviewResponse tx0PreviewSingle(
@RequestHeader HttpHeaders headers,
@PathVariable("hash") String utxoHash,
@PathVariable("index") int utxoIndex,
@Valid @RequestBody ApiTx0PreviewRequest payload)
throws Exception {
checkHeaders(headers);
// forward to new API
payload.inputs = new ApiUtxoRef[] {new ApiUtxoRef(utxoHash, utxoIndex)};
return tx0Preview(headers, payload);
}
@RequestMapping(value = CliApiEndpoint.REST_UTXO_TX0, method = RequestMethod.POST)
@RequestMapping(value = CliApiEndpoint.REST_TX0, method = RequestMethod.POST)
public ApiTx0Response tx0(
@RequestHeader HttpHeaders headers, @Valid @RequestBody ApiTx0Request payload)
throws Exception {
......@@ -125,21 +110,6 @@ public class UtxoController extends AbstractRestController {
return new ApiTx0Response(tx0);
}
@Deprecated // TODO remove on next release
@RequestMapping(value = CliApiEndpoint.REST_UTXO_TX0_SINGLE, method = RequestMethod.POST)
public ApiTx0Response tx0Single(
@RequestHeader HttpHeaders headers,
@PathVariable("hash") String utxoHash,
@PathVariable("index") int utxoIndex,
@Valid @RequestBody ApiTx0Request payload)
throws Exception {
checkHeaders(headers);
// forward to new API
payload.inputs = new ApiUtxoRef[] {new ApiUtxoRef(utxoHash, utxoIndex)};
return tx0(headers, payload);
}
@RequestMapping(value = CliApiEndpoint.REST_UTXO_STARTMIX, method = RequestMethod.POST)
public void startMix(
@RequestHeader HttpHeaders headers,
......
......@@ -21,13 +21,10 @@ public class CliApiEndpoint {
public static final String REST_UTXOS = REST_PREFIX + "utxos";
public static final String REST_UTXO_CONFIGURE = REST_PREFIX + "utxos/{hash}:{index}";
public static final String REST_UTXO_TX0 = REST_PREFIX + "tx0";
public static final String REST_UTXO_TX0_PREVIEW = REST_PREFIX + "tx0/preview";
public static final String REST_UTXO_TX0_SINGLE = REST_PREFIX + "utxos/{hash}:{index}/tx0";
public static final String REST_UTXO_TX0_SINGLE_PREVIEW =
REST_PREFIX + "utxos/{hash}:{index}/tx0Preview";
public static final String REST_UTXO_STARTMIX = REST_PREFIX + "utxos/{hash}:{index}/startMix";
public static final String REST_UTXO_STOPMIX = REST_PREFIX + "utxos/{hash}:{index}/stopMix";
public static final String REST_TX0 = REST_PREFIX + "tx0";
public static final String REST_TX0_PREVIEW = REST_PREFIX + "tx0/preview";
public static final String[] REST_ENDPOINTS =
new String[] {
......@@ -45,11 +42,9 @@ public class CliApiEndpoint {
REST_MIX_STOP,
REST_UTXOS,
REST_UTXO_CONFIGURE,
REST_UTXO_TX0_PREVIEW,
REST_UTXO_TX0,
REST_UTXO_TX0_SINGLE_PREVIEW,
REST_UTXO_TX0_SINGLE,
REST_UTXO_STARTMIX,
REST_UTXO_STOPMIX
REST_UTXO_STOPMIX,
REST_TX0_PREVIEW,
REST_TX0
};
}
package com.samourai.whirlpool.cli.api.protocol.beans;
public class ApiUtxoRef {
private String hash;
private int index;
public ApiUtxoRef(String hash, int index) {
this.hash = hash;
this.index = index;
}
import javax.validation.constraints.NotEmpty;
public String getHash() {
return hash;
}
public class ApiUtxoRef {
@NotEmpty public String hash;
@NotEmpty public int index;
public int getIndex() {
return index;
}
public ApiUtxoRef() {}
}
......@@ -2,12 +2,13 @@ package com.samourai.whirlpool.cli.api.protocol.rest;
import com.samourai.whirlpool.cli.api.protocol.beans.ApiUtxoRef;
import com.samourai.whirlpool.client.wallet.beans.Tx0FeeTarget;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
public class ApiTx0PreviewRequest {
/*@NotNull TODO next release*/ public ApiUtxoRef[] inputs;
@NotEmpty public ApiUtxoRef[] inputs;
@NotNull public Tx0FeeTarget feeTarget;
@NotNull public String poolId;
@NotEmpty public String poolId;
public ApiTx0PreviewRequest() {}
}
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