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
abda80ee
Commit
abda80ee
authored
Dec 13, 2019
by
zeroleak
Browse files
make WhirlpoolUtxo.mixsTarget nullable + add WhirlpoolUtxo.mixsTargetOrDefault
parent
b45d6e07
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
53 additions
and
46 deletions
+53
-46
README-API.md
README-API.md
+2
-1
src/main/java/com/samourai/whirlpool/cli/Application.java
src/main/java/com/samourai/whirlpool/cli/Application.java
+2
-32
src/main/java/com/samourai/whirlpool/cli/api/controllers/mix/MixController.java
...urai/whirlpool/cli/api/controllers/mix/MixController.java
+4
-2
src/main/java/com/samourai/whirlpool/cli/api/protocol/beans/ApiUtxo.java
...om/samourai/whirlpool/cli/api/protocol/beans/ApiUtxo.java
+9
-3
src/main/java/com/samourai/whirlpool/cli/api/protocol/beans/ApiWallet.java
.../samourai/whirlpool/cli/api/protocol/beans/ApiWallet.java
+5
-2
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiWalletStateResponse.java
...irlpool/cli/api/protocol/rest/ApiWalletStateResponse.java
+2
-2
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiWalletUtxosResponse.java
...irlpool/cli/api/protocol/rest/ApiWalletUtxosResponse.java
+13
-3
src/main/java/com/samourai/whirlpool/cli/run/CliStatusOrchestrator.java
...com/samourai/whirlpool/cli/run/CliStatusOrchestrator.java
+1
-1
src/main/java/com/samourai/whirlpool/cli/utils/CliUtils.java
src/main/java/com/samourai/whirlpool/cli/utils/CliUtils.java
+15
-0
No files found.
README-API.md
View file @
abda80ee
...
...
@@ -91,7 +91,8 @@ Response:
"progressLabel":"CONNECTING",
"poolId":"0.01btc",
"priority":5,
"mixsTarget":1,
"mixsTarget":null,
"mixsTargetOrDefault":1,
"mixsDone":0,
"message":" - [MIX 1/1] ▮▮▮▮▮▯▯▯▯▯ (5/10) CONFIRMED_INPUT : joined a mix!",
"error":null,
...
...
src/main/java/com/samourai/whirlpool/cli/Application.java
View file @
abda80ee
...
...
@@ -4,14 +4,12 @@ import com.samourai.whirlpool.cli.services.CliConfigService;
import
com.samourai.whirlpool.cli.services.CliService
;
import
com.samourai.whirlpool.cli.utils.CliUtils
;
import
com.samourai.whirlpool.client.exception.NotifiableException
;
import
com.samourai.whirlpool.client.utils.LogbackUtils
;
import
com.samourai.whirlpool.protocol.WhirlpoolProtocol
;
import
java.lang.invoke.MethodHandles
;
import
java.util.Arrays
;
import
javax.annotation.PreDestroy
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.event.Level
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
...
...
@@ -55,7 +53,7 @@ public class Application implements ApplicationRunner {
// enable debug logs with --debug
debug
=
ApplicationArgs
.
isMainDebug
(
args
);
debugClient
=
ApplicationArgs
.
isMainDebugClient
(
args
);
setDebug
(
debug
,
debugClient
);
CliUtils
.
setLogLevel
(
debug
,
debugClient
);
// run
WebApplicationType
wat
=
...
...
@@ -97,7 +95,7 @@ public class Application implements ApplicationRunner {
restart
=
false
;
Application
.
applicationArguments
=
applicationArguments
;
setDebug
(
debug
,
debugClient
);
// run twice to fix incorrect log level
CliUtils
.
setLogLevel
(
debug
,
debugClient
);
// run twice to fix incorrect log level
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Run... "
+
Arrays
.
toString
(
applicationArguments
.
getSourceArgs
()));
...
...
@@ -133,34 +131,6 @@ public class Application implements ApplicationRunner {
}
}
private
static
void
setDebug
(
boolean
isDebug
,
boolean
isDebugClient
)
{
if
(
isDebug
)
{
LogbackUtils
.
setLogLevel
(
"com.samourai"
,
Level
.
DEBUG
.
toString
());
}
if
(
isDebugClient
)
{
LogbackUtils
.
setLogLevel
(
"com.samourai.whirlpool.client"
,
Level
.
DEBUG
.
toString
());
LogbackUtils
.
setLogLevel
(
"com.samourai.stomp.client"
,
Level
.
DEBUG
.
toString
());
}
else
{
LogbackUtils
.
setLogLevel
(
"com.samourai.whirlpool.client"
,
Level
.
INFO
.
toString
());
LogbackUtils
.
setLogLevel
(
"com.samourai.stomp.client"
,
Level
.
INFO
.
toString
());
}
if
(
isDebug
)
{
LogbackUtils
.
setLogLevel
(
"com.samourai.whirlpool.client.wallet"
,
Level
.
DEBUG
.
toString
());
LogbackUtils
.
setLogLevel
(
"com.samourai.whirlpool.client.wallet.orchestrator"
,
Level
.
DEBUG
.
toString
());
}
// skip noisy logs
LogbackUtils
.
setLogLevel
(
"org.bitcoinj"
,
Level
.
ERROR
.
toString
());
LogbackUtils
.
setLogLevel
(
"org.bitcoin"
,
Level
.
WARN
.
toString
());
// "no wallycore"
LogbackUtils
.
setLogLevel
(
"com.msopentech.thali.toronionproxy"
,
Level
.
WARN
.
toString
());
LogbackUtils
.
setLogLevel
(
"com.msopentech.thali.java.toronionproxy"
,
Level
.
WARN
.
toString
());
LogbackUtils
.
setLogLevel
(
"org.springframework.web"
,
Level
.
INFO
.
toString
());
LogbackUtils
.
setLogLevel
(
"org.apache.http.impl.conn"
,
Level
.
INFO
.
toString
());
}
public
static
void
restart
()
{
long
restartDelay
=
1000
;
if
(
log
.
isDebugEnabled
())
{
...
...
src/main/java/com/samourai/whirlpool/cli/api/controllers/mix/MixController.java
View file @
abda80ee
...
...
@@ -4,6 +4,7 @@ import com.samourai.whirlpool.cli.api.controllers.AbstractRestController;
import
com.samourai.whirlpool.cli.api.protocol.CliApiEndpoint
;
import
com.samourai.whirlpool.cli.api.protocol.rest.ApiWalletStateResponse
;
import
com.samourai.whirlpool.cli.services.CliWalletService
;
import
com.samourai.whirlpool.client.wallet.WhirlpoolWallet
;
import
com.samourai.whirlpool.client.wallet.beans.MixingState
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpHeaders
;
...
...
@@ -19,8 +20,9 @@ public class MixController extends AbstractRestController {
@RequestMapping
(
value
=
CliApiEndpoint
.
REST_MIX
,
method
=
RequestMethod
.
GET
)
public
ApiWalletStateResponse
wallet
(
@RequestHeader
HttpHeaders
headers
)
throws
Exception
{
checkHeaders
(
headers
);
MixingState
mixingState
=
cliWalletService
.
getSessionWallet
().
getMixingState
();
return
new
ApiWalletStateResponse
(
mixingState
);
WhirlpoolWallet
whirlpoolWallet
=
cliWalletService
.
getSessionWallet
();
MixingState
mixingState
=
whirlpoolWallet
.
getMixingState
();
return
new
ApiWalletStateResponse
(
mixingState
,
whirlpoolWallet
.
getConfig
().
getMixsTarget
());
}
@RequestMapping
(
value
=
CliApiEndpoint
.
REST_MIX_START
,
method
=
RequestMethod
.
POST
)
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/beans/ApiUtxo.java
View file @
abda80ee
...
...
@@ -17,13 +17,14 @@ public class ApiUtxo {
private
MixableStatus
mixableStatus
;
private
Integer
progressPercent
;
private
String
poolId
;
private
int
mixsTarget
;
private
Integer
mixsTarget
;
private
Integer
mixsTargetOrDefault
;
private
int
mixsDone
;
private
String
message
;
private
String
error
;
private
Long
lastActivityElapsed
;
public
ApiUtxo
(
WhirlpoolUtxo
whirlpoolUtxo
)
{
public
ApiUtxo
(
WhirlpoolUtxo
whirlpoolUtxo
,
int
mixsTargetMin
)
{
UnspentResponse
.
UnspentOutput
utxo
=
whirlpoolUtxo
.
getUtxo
();
this
.
hash
=
utxo
.
tx_hash
;
this
.
index
=
utxo
.
tx_output_n
;
...
...
@@ -42,6 +43,7 @@ public class ApiUtxo {
utxoState
.
getMixProgress
()
!=
null
?
utxoState
.
getMixProgress
().
getProgressPercent
()
:
null
;
this
.
poolId
=
utxoConfig
.
getPoolId
();
this
.
mixsTarget
=
utxoConfig
.
getMixsTarget
();
this
.
mixsTargetOrDefault
=
utxoConfig
.
getMixsTargetOrDefault
(
mixsTargetMin
);
this
.
mixsDone
=
utxoConfig
.
getMixsDone
();
this
.
message
=
utxoState
.
getMessage
();
this
.
error
=
utxoState
.
getError
();
...
...
@@ -95,10 +97,14 @@ public class ApiUtxo {
return
poolId
;
}
public
i
nt
getMixsTarget
()
{
public
I
nt
eger
getMixsTarget
()
{
return
mixsTarget
;
}
public
Integer
getMixsTargetOrDefault
()
{
return
mixsTargetOrDefault
;
}
public
int
getMixsDone
()
{
return
mixsDone
;
}
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/beans/ApiWallet.java
View file @
abda80ee
...
...
@@ -11,12 +11,15 @@ public class ApiWallet {
private
String
zpub
;
public
ApiWallet
(
Collection
<
WhirlpoolUtxo
>
whirlpoolUtxos
,
String
zpub
,
Comparator
<
WhirlpoolUtxo
>
comparator
)
{
Collection
<
WhirlpoolUtxo
>
whirlpoolUtxos
,
String
zpub
,
Comparator
<
WhirlpoolUtxo
>
comparator
,
int
mixsTargetMin
)
{
this
.
utxos
=
whirlpoolUtxos
.
stream
()
.
sorted
(
comparator
)
.
map
(
whirlpoolUtxo
->
new
ApiUtxo
(
whirlpoolUtxo
))
.
map
(
whirlpoolUtxo
->
new
ApiUtxo
(
whirlpoolUtxo
,
mixsTargetMin
))
.
collect
(
Collectors
.
toList
());
this
.
balance
=
whirlpoolUtxos
.
stream
().
mapToLong
(
whirlpoolUtxo
->
whirlpoolUtxo
.
getUtxo
().
value
).
sum
();
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiWalletStateResponse.java
View file @
abda80ee
...
...
@@ -12,7 +12,7 @@ public class ApiWalletStateResponse {
private
int
nbQueued
;
private
Collection
<
ApiUtxo
>
threads
;
public
ApiWalletStateResponse
(
MixingState
mixingState
)
{
public
ApiWalletStateResponse
(
MixingState
mixingState
,
int
mixsTargetMin
)
{
this
.
started
=
mixingState
.
isStarted
();
this
.
nbMixing
=
mixingState
.
getNbMixing
();
this
.
nbQueued
=
mixingState
.
getNbQueued
();
...
...
@@ -20,7 +20,7 @@ public class ApiWalletStateResponse {
mixingState
.
getUtxosMixing
()
.
stream
()
.
map
(
whirlpoolUtxo
->
new
ApiUtxo
(
whirlpoolUtxo
))
.
map
(
whirlpoolUtxo
->
new
ApiUtxo
(
whirlpoolUtxo
,
mixsTargetMin
))
.
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/samourai/whirlpool/cli/api/protocol/rest/ApiWalletUtxosResponse.java
View file @
abda80ee
...
...
@@ -35,15 +35,25 @@ public class ApiWalletUtxosResponse {
// last confirmed
return
Ints
.
compare
(
o1
.
getUtxo
().
confirmations
,
o2
.
getUtxo
().
confirmations
);
};
int
mixsTargetMin
=
whirlpoolWallet
.
getConfig
().
getMixsTarget
();
this
.
deposit
=
new
ApiWallet
(
whirlpoolWallet
.
getUtxosDeposit
(),
whirlpoolWallet
.
getZpubDeposit
(),
comparator
);
whirlpoolWallet
.
getUtxosDeposit
(),
whirlpoolWallet
.
getZpubDeposit
(),
comparator
,
mixsTargetMin
);
this
.
premix
=
new
ApiWallet
(
whirlpoolWallet
.
getUtxosPremix
(),
whirlpoolWallet
.
getZpubPremix
(),
comparator
);
whirlpoolWallet
.
getUtxosPremix
(),
whirlpoolWallet
.
getZpubPremix
(),
comparator
,
mixsTargetMin
);
this
.
postmix
=
new
ApiWallet
(
whirlpoolWallet
.
getUtxosPostmix
(),
whirlpoolWallet
.
getZpubPostmix
(),
comparator
);
whirlpoolWallet
.
getUtxosPostmix
(),
whirlpoolWallet
.
getZpubPostmix
(),
comparator
,
mixsTargetMin
);
}
public
ApiWallet
getDeposit
()
{
...
...
src/main/java/com/samourai/whirlpool/cli/run/CliStatusOrchestrator.java
View file @
abda80ee
...
...
@@ -122,7 +122,7 @@ public class CliStatusOrchestrator extends AbstractOrchestrator {
try
{
log
.
info
(
"⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿"
);
log
.
info
(
"⣿ "
+
account
+
" UTXOS:"
);
ClientUtils
.
logWhirlpoolUtxos
(
utxos
);
ClientUtils
.
logWhirlpoolUtxos
(
utxos
,
cliConfig
.
getMix
().
getMixsTarget
()
);
}
catch
(
Exception
e
)
{
log
.
error
(
""
,
e
);
...
...
src/main/java/com/samourai/whirlpool/cli/utils/CliUtils.java
View file @
abda80ee
package
com.samourai.whirlpool.cli.utils
;
import
ch.qos.logback.classic.Level
;
import
com.samourai.tor.client.JavaTorConnexion
;
import
com.samourai.whirlpool.cli.beans.CliProxy
;
import
com.samourai.whirlpool.cli.beans.CliProxyProtocol
;
import
com.samourai.whirlpool.cli.services.CliTorClientService
;
import
com.samourai.whirlpool.client.exception.NotifiableException
;
import
com.samourai.whirlpool.client.utils.ClientUtils
;
import
com.samourai.whirlpool.client.utils.LogbackUtils
;
import
java.io.Console
;
import
java.io.IOException
;
import
java.lang.invoke.MethodHandles
;
...
...
@@ -204,4 +206,17 @@ public class CliUtils {
}
return
lines
;
}
public
static
void
setLogLevel
(
boolean
isDebug
,
boolean
isDebugClient
)
{
Level
whirlpoolLevel
=
isDebug
?
Level
.
DEBUG
:
Level
.
INFO
;
Level
whirlpoolClientLevel
=
isDebugClient
?
Level
.
DEBUG
:
Level
.
INFO
;
ClientUtils
.
setLogLevel
(
whirlpoolLevel
,
whirlpoolClientLevel
);
LogbackUtils
.
setLogLevel
(
"com.msopentech.thali.toronionproxy"
,
org
.
slf4j
.
event
.
Level
.
WARN
.
toString
());
LogbackUtils
.
setLogLevel
(
"com.msopentech.thali.java.toronionproxy"
,
org
.
slf4j
.
event
.
Level
.
WARN
.
toString
());
LogbackUtils
.
setLogLevel
(
"org.springframework.web"
,
org
.
slf4j
.
event
.
Level
.
INFO
.
toString
());
LogbackUtils
.
setLogLevel
(
"org.apache.http.impl.conn"
,
org
.
slf4j
.
event
.
Level
.
INFO
.
toString
());
}
}
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