From 608195514068d8a1e55fd38cd91bd51e57e16af3 Mon Sep 17 00:00:00 2001 From: mikera Date: Tue, 30 Jan 2024 13:13:18 +0000 Subject: [PATCH] Code tidying, more CLI tightening --- convex-cli/src/main/java/convex/cli/Main.java | 4 +++- .../src/main/java/convex/cli/key/KeyGenerate.java | 12 ++---------- .../manager/mainpanels/actors/MarketComponent.java | 2 ++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/convex-cli/src/main/java/convex/cli/Main.java b/convex-cli/src/main/java/convex/cli/Main.java index 8b61ad41e..1ffacdbd0 100644 --- a/convex-cli/src/main/java/convex/cli/Main.java +++ b/convex-cli/src/main/java/convex/cli/Main.java @@ -270,10 +270,12 @@ public char[] getKeyPassword() { keypass=new char[0]; } } + if (keypass.length==0) { + paranoia("Cannot use an empty private key password"); + } return keypass; } - /** * Gets the keystore file name currently used for the CLI * @return File name, or null if not specified diff --git a/convex-cli/src/main/java/convex/cli/key/KeyGenerate.java b/convex-cli/src/main/java/convex/cli/key/KeyGenerate.java index 61fa4ccc7..1fe25c323 100644 --- a/convex-cli/src/main/java/convex/cli/key/KeyGenerate.java +++ b/convex-cli/src/main/java/convex/cli/key/KeyGenerate.java @@ -4,9 +4,6 @@ import java.security.KeyStore; import java.util.Arrays; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import convex.cli.Constants; import convex.core.crypto.AKeyPair; import convex.core.crypto.BIP39; @@ -31,8 +28,6 @@ description="Generate private key pair(s) in the currently configured keystore. Will create a keystore if it does not exist.") public class KeyGenerate extends AKeyCommand { - private static final Logger log = LoggerFactory.getLogger(KeyGenerate.class); - @Option(names="--count", defaultValue="" + Constants.KEY_GENERATE_COUNT, description="Number of keys to generate. Default: ${DEFAULT-VALUE}") @@ -60,7 +55,7 @@ private AKeyPair generateKeyPair() { } } if (passphrase.isBlank()) { - cli().paranoia("Cannot use an empty passphrase for secure key generation"); + cli().paranoia("Cannot use an empty BIP39 passphrase for secure key generation"); } Blob bipseed = BIP39.getSeed(mnemonic, passphrase); AKeyPair result= BIP39.seedToKeyPair(bipseed); @@ -77,10 +72,9 @@ private AKeyPair generateKeyPair() { public void run() { // check the number of keys to generate. if (count <= 0) { - log.warn("No keys to generate: count = "+count); + cli().printErr("No keys generated. Perhaps specify a positive --count ?"); return; } - log.debug("Generating {} keys",count); char[] storePass=cli().getStorePassword(); try { @@ -93,9 +87,7 @@ public void run() { PFXTools.setKeyPair(ks, kp, keyPassword); Arrays.fill(keyPassword, 'p'); } - log.debug(count+ " keys successfully generated"); cli().saveKeyStore(storePass); - log.trace("Keystore saved successfully"); } catch (Throwable e) { throw Utils.sneakyThrow(e); } finally { diff --git a/convex-gui/src/main/java/convex/gui/manager/mainpanels/actors/MarketComponent.java b/convex-gui/src/main/java/convex/gui/manager/mainpanels/actors/MarketComponent.java index b4f9c473e..a6b726364 100644 --- a/convex-gui/src/main/java/convex/gui/manager/mainpanels/actors/MarketComponent.java +++ b/convex-gui/src/main/java/convex/gui/manager/mainpanels/actors/MarketComponent.java @@ -158,7 +158,9 @@ private void buy(Object outcome) { changeStake(outcome, 1000000); } + @SuppressWarnings("unused") private void changeStake(Object outcome, long delta) { + // TODO: this is broken and needs fixing State state = marketsPanel.getLatestState(); Long stk = getStake(state, outcome); if (stk == null) stk = 0L;