Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Whirlpool
whirlpool-client-cli
Commits
f91e6950
Commit
f91e6950
authored
Dec 04, 2020
by
zeroleak
Browse files
ApiTx0PreviewRequest: add .mixFeeTarget + rename .feeTarget -> tx0FeeTarget
parent
94695c98
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
17 deletions
+47
-17
doc/API.md
doc/API.md
+10
-5
src/main/java/com/samourai/whirlpool/cli/api/controllers/pools/PoolsController.java
.../whirlpool/cli/api/controllers/pools/PoolsController.java
+3
-1
src/main/java/com/samourai/whirlpool/cli/api/controllers/utxo/UtxoController.java
...ai/whirlpool/cli/api/controllers/utxo/UtxoController.java
+5
-2
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiPoolsResponse.java
...rai/whirlpool/cli/api/protocol/rest/ApiPoolsResponse.java
+11
-4
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiTx0PreviewRequest.java
...whirlpool/cli/api/protocol/rest/ApiTx0PreviewRequest.java
+2
-1
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiTx0PreviewResponse.java
...hirlpool/cli/api/protocol/rest/ApiTx0PreviewResponse.java
+16
-4
No files found.
doc/API.md
View file @
f91e6950
...
...
@@ -13,9 +13,10 @@ It can be used by whirlpool-gui or any REST client.
## Pools
### List pools: ```GET /rest/pools[?tx0FeeTarget=BLOCKS_24]```
### List pools: ```GET /rest/pools[?tx0FeeTarget=BLOCKS_24
&?mixFeeTarget=BLOCKS_24
]```
Parameters:
*
(optional) tx0FeeTarget: tx0 fee target for tx0BalanceMin computation
*
(optional) mixFeeTarget: mix fee target for tx0BalanceMin computation
Response:
```
...
...
@@ -138,14 +139,16 @@ Response:
### Tx0 preview ```POST /rest/tx0/preview```
Payload:
*
inputs {hash, index} (mandatory): utxos to spend for tx0
*
feeTarget (mandatory): fee target for tx0
*
tx0FeeTarget (mandatory): fee target for tx0
*
mixFeeTarget (mandatory): fee target for mix
*
poolId (optional): override utxo's poolId
```
{
inputs: [
{hash:"c7f456d5ff002faa89dadec01cc5eb98bb00fdefb92031890324ec127f9d1541", index:5}
],
feeTarget: "BLOCKS_4",
tx0FeeTarget: "BLOCKS_4",
mixFeeTarget: "BLOCKS_6",
poolId: "0.01btc"
}
```
...
...
@@ -161,14 +164,16 @@ Response:
### Tx0 ```POST /rest/tx0```
Payload:
*
inputs {hash, index} (mandatory): utxos to spend for tx0
*
feeTarget (mandatory): fee target for tx0
*
tx0FeeTarget (mandatory): fee target for tx0
*
mixFeeTarget (mandatory): fee target for mix
*
poolId (optional): override utxo's poolId
```
{
inputs: [
{hash:"c7f456d5ff002faa89dadec01cc5eb98bb00fdefb92031890324ec127f9d1541", index:5}
],
feeTarget: "BLOCKS_4",
tx0FeeTarget: "BLOCKS_4",
mixFeeTarget: "BLOCKS_6",
poolId: "0.01btc"
}
```
...
...
src/main/java/com/samourai/whirlpool/cli/api/controllers/pools/PoolsController.java
View file @
f91e6950
...
...
@@ -22,11 +22,13 @@ public class PoolsController extends AbstractRestController {
public
ApiPoolsResponse
pools
(
@RequestParam
(
value
=
"tx0FeeTarget"
,
defaultValue
=
"BLOCKS_24"
)
Tx0FeeTarget
tx0FeeTarget
,
// Tx0FeeTarget.MIN
@RequestParam
(
value
=
"mixFeeTarget"
,
defaultValue
=
"BLOCKS_24"
)
Tx0FeeTarget
mixFeeTarget
,
// Tx0FeeTarget.MIN
@RequestHeader
HttpHeaders
headers
)
throws
Exception
{
checkHeaders
(
headers
);
WhirlpoolWallet
whirlpoolWallet
=
cliWalletService
.
getSessionWallet
();
Collection
<
Pool
>
pools
=
whirlpoolWallet
.
getPoolSupplier
().
getPools
();
return
new
ApiPoolsResponse
(
pools
,
tx0FeeTarget
,
whirlpoolWallet
);
return
new
ApiPoolsResponse
(
pools
,
tx0FeeTarget
,
mixFeeTarget
,
whirlpoolWallet
);
}
}
src/main/java/com/samourai/whirlpool/cli/api/controllers/utxo/UtxoController.java
View file @
f91e6950
...
...
@@ -85,7 +85,8 @@ public class UtxoController extends AbstractRestController {
// tx0 preview
Tx0Config
tx0Config
=
whirlpoolWallet
.
getTx0Config
();
Tx0Preview
tx0Preview
=
whirlpoolWallet
.
tx0Preview
(
whirlpoolUtxos
,
pool
,
tx0Config
,
payload
.
feeTarget
);
whirlpoolWallet
.
tx0Preview
(
whirlpoolUtxos
,
pool
,
tx0Config
,
payload
.
tx0FeeTarget
,
payload
.
mixFeeTarget
);
return
new
ApiTx0PreviewResponse
(
tx0Preview
);
}
...
...
@@ -106,7 +107,9 @@ public class UtxoController extends AbstractRestController {
// tx0
Tx0Config
tx0Config
=
whirlpoolWallet
.
getTx0Config
();
Tx0
tx0
=
whirlpoolWallet
.
tx0
(
whirlpoolUtxos
,
pool
,
payload
.
feeTarget
,
tx0Config
);
Tx0
tx0
=
whirlpoolWallet
.
tx0
(
whirlpoolUtxos
,
pool
,
payload
.
tx0FeeTarget
,
payload
.
mixFeeTarget
,
tx0Config
);
return
new
ApiTx0Response
(
tx0
);
}
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiPoolsResponse.java
View file @
f91e6950
...
...
@@ -11,17 +11,24 @@ public class ApiPoolsResponse {
private
Collection
<
ApiPool
>
pools
;
public
ApiPoolsResponse
(
Collection
<
Pool
>
pools
,
Tx0FeeTarget
feeTarget
,
WhirlpoolWallet
whirlpoolWallet
)
{
Collection
<
Pool
>
pools
,
Tx0FeeTarget
tx0FeeTarget
,
Tx0FeeTarget
mixFeeTarget
,
WhirlpoolWallet
whirlpoolWallet
)
{
this
.
pools
=
pools
.
stream
()
.
map
(
pool
->
computeApiPool
(
pool
,
f
eeTarget
,
whirlpoolWallet
))
.
map
(
pool
->
computeApiPool
(
pool
,
tx0FeeTarget
,
mixF
eeTarget
,
whirlpoolWallet
))
.
collect
(
Collectors
.
toList
());
}
private
ApiPool
computeApiPool
(
Pool
pool
,
Tx0FeeTarget
feeTarget
,
WhirlpoolWallet
whirlpoolWallet
)
{
long
tx0BalanceMin
=
whirlpoolWallet
.
computeTx0SpendFromBalanceMin
(
pool
,
feeTarget
);
Pool
pool
,
Tx0FeeTarget
tx0FeeTarget
,
Tx0FeeTarget
mixFeeTarget
,
WhirlpoolWallet
whirlpoolWallet
)
{
long
tx0BalanceMin
=
whirlpoolWallet
.
computeTx0SpendFromBalanceMin
(
pool
,
tx0FeeTarget
,
mixFeeTarget
);
return
new
ApiPool
(
pool
,
tx0BalanceMin
);
}
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiTx0PreviewRequest.java
View file @
f91e6950
...
...
@@ -7,7 +7,8 @@ import javax.validation.constraints.NotNull;
public
class
ApiTx0PreviewRequest
{
@NotEmpty
public
ApiUtxoRef
[]
inputs
;
@NotNull
public
Tx0FeeTarget
feeTarget
;
@NotNull
public
Tx0FeeTarget
tx0FeeTarget
;
@NotNull
public
Tx0FeeTarget
mixFeeTarget
;
@NotEmpty
public
String
poolId
;
public
ApiTx0PreviewRequest
()
{}
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiTx0PreviewResponse.java
View file @
f91e6950
...
...
@@ -3,7 +3,9 @@ package com.samourai.whirlpool.cli.api.protocol.rest;
import
com.samourai.whirlpool.client.tx0.Tx0Preview
;
public
class
ApiTx0PreviewResponse
{
private
long
minerFee
;
private
long
tx0MinerFee
;
private
long
mixMinerFee
;
private
long
premixMinerFee
;
private
long
feeValue
;
private
long
feeChange
;
private
long
premixValue
;
...
...
@@ -12,7 +14,9 @@ public class ApiTx0PreviewResponse {
private
int
feeDiscountPercent
;
public
ApiTx0PreviewResponse
(
Tx0Preview
tx0Preview
)
{
this
.
minerFee
=
tx0Preview
.
getMinerFee
();
this
.
tx0MinerFee
=
tx0Preview
.
getTx0MinerFee
();
this
.
mixMinerFee
=
tx0Preview
.
getMixMinerFee
();
this
.
premixMinerFee
=
tx0Preview
.
getPremixMinerFee
();
this
.
feeValue
=
tx0Preview
.
getFeeValue
();
this
.
feeChange
=
tx0Preview
.
getFeeChange
();
this
.
premixValue
=
tx0Preview
.
getPremixValue
();
...
...
@@ -21,8 +25,16 @@ public class ApiTx0PreviewResponse {
this
.
feeDiscountPercent
=
tx0Preview
.
getFeeDiscountPercent
();
}
public
long
getMinerFee
()
{
return
minerFee
;
public
long
getTx0MinerFee
()
{
return
tx0MinerFee
;
}
public
long
getMixMinerFee
()
{
return
mixMinerFee
;
}
public
long
getPremixMinerFee
()
{
return
premixMinerFee
;
}
public
long
getFeeValue
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment