Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Convex-Dev/convex.git in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
mikera committed Jun 18, 2024
2 parents 16c79d3 + ba9f5e1 commit 8231f99
Show file tree
Hide file tree
Showing 24 changed files with 55 additions and 63 deletions.
2 changes: 1 addition & 1 deletion convex-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion convex-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
23 changes: 6 additions & 17 deletions convex-cli/src/main/java/convex/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ public class Main extends ACommand {
description = "Specify verbosity level. Use -v0 to suppress user output. Default: ${DEFAULT-VALUE}")
private Integer verbose;

@Option(names = { "-V", "--version" },
versionHelp = true,
description = "Display version info")
boolean versionInfoRequested;

@Option(names = { "-h", "--help" },
usageHelp = true,
description = "Display help for this command")
boolean usageHelpRequested;

public Main() {
commandLine = commandLine.setExecutionExceptionHandler(new Main.ExceptionHandler());
}
Expand Down Expand Up @@ -257,13 +247,13 @@ public char[] getStorePassword() {
/**
* Keys the password for the current key
*
* @return
* @return password
*/
public char[] getKeyPassword() {
char[] keypass = null;

if (this.keystorePassword != null) {
keypass = this.keystorePassword.toCharArray();
if (this.keyPassword != null) {
keypass = this.keyPassword.toCharArray();
} else {
if (!nonInteractive) {
keypass = readPassword("Private Key Encryption Password: ");
Expand All @@ -274,7 +264,7 @@ public char[] getKeyPassword() {
keypass = new char[0];
}

this.keystorePassword=new String(keypass);
this.keyPassword=new String(keypass);
}
if (keypass.length == 0) {
paranoia("Cannot use an empty private key password");
Expand Down Expand Up @@ -312,7 +302,6 @@ public KeyStore getKeystore() {
/**
* Loads the currently configured key Store
*
* @param isCreate Flag to indicate if keystore should be created if absent
* @return KeyStore instance, or null if does not exist
*/
public KeyStore loadKeyStore() {
Expand Down Expand Up @@ -381,11 +370,11 @@ public AKeyPair loadKeyFromStore(String publicKey) {
String alias = aliases.nextElement();
if (alias.indexOf(publicKey) == 0) {
log.trace("found keypair " + alias);
keyPair = PFXTools.getKeyPair(keyStore, alias, storePassword);
keyPair = PFXTools.getKeyPair(keyStore, alias, getKeyPassword());
break;
}
}
} catch (Throwable t) {
} catch (Exception t) {
throw new CLIError("Cannot load key store", t);
}

Expand Down
1 change: 1 addition & 0 deletions convex-cli/src/test/java/convex/cli/key/KeyExportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void testKeyGenerateAndExport() {
"--export-password", new String(EXPORT_PASSWORD)
);
String s=tester.getOutput();
assertEquals("",tester.getError());
assertEquals(ExitCodes.SUCCESS,tester.getResult());
AKeyPair kp=AKeyPair.create(PEMTools.decryptPrivateKeyFromPEM(s, EXPORT_PASSWORD));
assertEquals(ak,kp.getAccountKey());
Expand Down
8 changes: 7 additions & 1 deletion convex-cli/src/test/java/convex/cli/key/KeyImportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class KeyImportTest {
private static final char[] KEYSTORE_PASSWORD = "testPassword".toCharArray();
private static final char[] IMPORT_PASSWORD = "testImportPassword".toCharArray();

private static final String KEY_PASSWORD="testPass";

private static final File KEYSTORE_FILE;
private static final String KEYSTORE_FILENAME;
static {
Expand Down Expand Up @@ -68,7 +70,8 @@ public void testKeyImportSeed() {
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--keystore", KEYSTORE_FILENAME,
"--text", keyPair.getSeed().toString(),
"--import-password", new String("")
"--password", KEY_PASSWORD,
"--import-password", new String("") // BIP39 password
);
assertEquals(ExitCodes.SUCCESS,tester.getResult());

Expand All @@ -77,6 +80,7 @@ public void testKeyImportSeed() {
CLTester t2=CLTester.run(
"key" ,
"list",
"--password",KEY_PASSWORD,
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--keystore", KEYSTORE_FILENAME);

Expand All @@ -97,6 +101,7 @@ public void testKeyImportBIP39() {
"bip39",
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--keystore", KEYSTORE_FILENAME,
"--password",KEY_PASSWORD,
"--text", "elder mail trick garage hour enjoy attack fringe problem motion poem security caught false penalty",
"--import-password", new String("")
);
Expand All @@ -107,6 +112,7 @@ public void testKeyImportBIP39() {
CLTester t2=CLTester.run(
"key" ,
"list",
"--password",KEY_PASSWORD,
"--keystore-password", new String(KEYSTORE_PASSWORD),
"--keystore", KEYSTORE_FILENAME);

Expand Down
2 changes: 1 addition & 1 deletion convex-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>

<properties>
Expand Down
3 changes: 1 addition & 2 deletions convex-core/src/main/java/convex/core/crypto/PEMTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ public static String encryptPrivateKeyToPEM(PrivateKey privateKey, char[] passwo
public static PrivateKey decryptPrivateKeyFromPEM(String pemText, char[] password) throws Error {
PrivateKey privateKey = null;
StringReader stringReader = new StringReader(pemText);
PEMParser pemParser = new PEMParser(stringReader);
PemObject pemObject = null;
JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
try {
try (PEMParser pemParser = new PEMParser(stringReader)) {
pemObject = pemParser.readPemObject();
while (pemObject != null) {
if (pemObject.getType().equals("ENCRYPTED PRIVATE KEY")) {
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions convex-gui/src/main/java/convex/gui/client/ConvexClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class ConvexClient extends AbstractGUI {
/**
* Launch the application.
* @param args Command line argument
* @throws TimeoutException
* @throws IOException
* @throws TimeoutException In case of timeout
* @throws IOException In case of connection error
*/
public static void main(String[] args) throws IOException, TimeoutException {
log.info("Starting Convex Client");
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/peer/PeerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void windowClosing(WindowEvent winEvt) {
/**
* Create the application.
* @param genesis Genesis key pair
* @param peerNum Number of peers to initialise in genesis
* @param peerCount number of peers to initialise in genesis
*/
public PeerGUI(int peerCount, AKeyPair genesis) {
super ("Peer Manager");
Expand Down
7 changes: 2 additions & 5 deletions convex-gui/src/main/java/convex/gui/tools/HackerTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

import javax.swing.JFrame;
Expand Down Expand Up @@ -37,10 +36,9 @@ public class HackerTools extends AbstractGUI {
/**
* Launch the application.
* @param args Command line argument
* @throws TimeoutException
* @throws IOException
* @throws TimeoutException In case of timeout
*/
public static void main(String[] args) throws IOException, TimeoutException {
public static void main(String[] args) throws TimeoutException {
log.info("Running Convex HackerTools");
clientMode=true;

Expand All @@ -61,7 +59,6 @@ public static void main(String[] args) throws IOException, TimeoutException {

/**
* Create the application.
* @param convex Convex client instance
*/
public HackerTools() {
super ("Hacker Tools");
Expand Down
4 changes: 2 additions & 2 deletions convex-gui/src/main/java/convex/gui/utils/Toolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static void showMainFrame(JComponent comp) {

/**
* Relinquish focus from a component
* @param c
* @param c Component to remove focus from
*/
public static void relinquishFocus(Component c) {
if (c.isFocusable()) {
Expand Down Expand Up @@ -290,7 +290,7 @@ public void actionPerformed(ActionEvent e) {

/**
* Adds a popup menu to a component, including necessary mouse listeners
* @param jPopupMenu
* @param popupMenu Op up menu component
*/
public static void addPopupMenu(JComponent comp,javax.swing.JPopupMenu popupMenu) {
comp.addMouseListener(new MouseAdapter () {
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/wallet/WalletApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String getTitle() {
/**
* Launch the application.
* @param args Command line args
* @throws InterruptedException
* @throws InterruptedException In case of interrupt
*/
public static void main(String[] args) throws InterruptedException {
// call to set up Look and Feel
Expand Down
2 changes: 1 addition & 1 deletion convex-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>

<name>Convex Java Client Library</name>
Expand Down
1 change: 1 addition & 0 deletions convex-observer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/pom.xml.versionsBackup
4 changes: 2 additions & 2 deletions convex-observer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>

<name>Convex Observer</name>
Expand Down Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>world.convex</groupId>
<artifactId>convex-java</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion convex-peer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>world.convex</groupId>
<artifactId>convex</artifactId>
<version>0.7.13</version>
<version>0.7.14-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
25 changes: 12 additions & 13 deletions convex-peer/src/main/java/convex/api/Convex.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void setNextSequence(long nextSequence) {
/**
* Sets a handler for messages that are received but not otherwise processed (transaction/query results will
* be relayed instead to the appropriate handler )
* @param handler
* @param handler Handler for received messaged
*/
public void setHandler(Consumer<Message> handler) {
this.delegatedHandler = handler;
Expand All @@ -237,8 +237,8 @@ public void setHandler(Consumer<Message> handler) {
* The next valid sequence number will be one higher than the result.
*
* @return Sequence number as a Long value (zero or positive)
* @throws TimeoutException
* @throws IOException
* @throws IOException If an IO error occurs
* @throws TimeoutException If the request times out
*/
public long getSequence() throws IOException, TimeoutException {
if (sequence == null) {
Expand All @@ -265,10 +265,10 @@ public long getSequence(Address addr) throws TimeoutException, IOException {

/**
* Look up the sequence number for an account
* @param origin
* @return
* @throws TimeoutException
* @throws IOException
* @param origin Account for which to check sequence
* @return Sequence number of account
* @throws TimeoutException if query times out
* @throws IOException in case of IO error
*/
public long lookupSequence(Address origin) throws IOException, TimeoutException {
AOp<ACell> code= Special.forSymbol(Symbols.STAR_SEQUENCE);
Expand Down Expand Up @@ -377,7 +377,7 @@ private synchronized long getNextSequence(ATransaction t) throws IOException, Ti
* @param transaction Transaction to execute
* @return A Future for the result of the transaction
* @throws IOException If an IO Exception occurs (most likely the connection is broken)
* @throws TimeoutException
* @throws TimeoutException In case of timeout
*/
public final synchronized CompletableFuture<Result> transact(ATransaction transaction) throws IOException, TimeoutException {
SignedData<ATransaction> signed = prepareTransaction(transaction);
Expand All @@ -394,14 +394,13 @@ public final synchronized CompletableFuture<Result> transact(ATransaction transa
* @param transaction Transaction to prepare
* @return Signed transaction ready to submit
* @throws IOException If an IO Exception occurs (most likely the connection is broken)
* @throws TimeoutException
* @throws TimeoutException In case of timeout
*/
public SignedData<ATransaction> prepareTransaction(ATransaction transaction) throws TimeoutException, IOException {
Address origin=transaction.getOrigin();
if (origin == null) {
origin=address;
transaction = transaction.withOrigin(origin);

}

final long originalSeq=transaction.getSequence(); // zero or negative means autosequence
Expand Down Expand Up @@ -451,7 +450,7 @@ public SignedData<ATransaction> prepareTransaction(ATransaction transaction) thr
* @param code Code to execute
* @return A Future for the result of the transaction
* @throws IOException If the connection is broken, or the send buffer is full
* @throws TimeoutException
* @throws TimeoutException In case of timeout
*/
public synchronized CompletableFuture<Result> transact(String code) throws IOException, TimeoutException {
return transact((ACell)Reader.read(code));
Expand All @@ -463,7 +462,7 @@ public synchronized CompletableFuture<Result> transact(String code) throws IOExc
* @param code Code to execute
* @return A Future for the result of the transaction
* @throws IOException If the connection is broken, or the send buffer is full
* @throws TimeoutException
* @throws TimeoutException In case of timeout
*/
public synchronized CompletableFuture<Result> transact(ACell code) throws IOException, TimeoutException {
ATransaction trans = Invoke.create(getAddress(), ATransaction.UNKNOWN_SEQUENCE, code);
Expand Down Expand Up @@ -515,7 +514,7 @@ public synchronized Result transactSync(String code) throws IOException, Timeout
* @param amount Amount of Convex Coins to transfer
* @return A Future for the result of the transaction
* @throws IOException If the connection is broken, or the send buffer is full
* @throws TimeoutException
* @throws TimeoutException In case of timeout
*/
public CompletableFuture<Result> transfer(Address target, long amount) throws IOException, TimeoutException {
ATransaction trans = Transfer.create(getAddress(), ATransaction.UNKNOWN_SEQUENCE, target, amount);
Expand Down
2 changes: 1 addition & 1 deletion convex-peer/src/main/java/convex/net/NIOServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static NIOServer create(Server server) {
*
* @param bindAddress Address to bind to, or null to bind to all addresses (unspecified)
* @param port Port to use. If 0 or null, a default port will be used, with fallback to a random port
* @throws IOException
* @throws IOException in case of IO problem
*/
public void launch(String bindAddress, Integer port) throws IOException {
if (port == null) {
Expand Down
8 changes: 4 additions & 4 deletions convex-peer/src/main/java/convex/peer/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,11 @@ public void alertBadMessage(Message m, String reason) {

/**
* Called to signal missing data in a Belief / Order
* @param m
* @param e
* @param key
* @param m Message which caused alert
* @param e Missing data exception encountered
* @param peerKey Peer key which triggered missing data
*/
public void alertMissing(Message m, MissingDataException e, AccountKey key) {
public void alertMissing(Message m, MissingDataException e, AccountKey peerKey) {
if (log.isDebugEnabled()) {
String message= "Missing data "+e.getMissingHash();
log.debug(message);
Expand Down
Loading

0 comments on commit 8231f99

Please sign in to comment.