-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start Release 0.1
- Loading branch information
Showing
179 changed files
with
7,006 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
/build | ||
/pack | ||
/mod/updated | ||
/out | ||
|
||
#IDE | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_PATH=$(dirname $(realpath $0)) | ||
|
||
pushd ${SCRIPT_PATH} | ||
|
||
java -cp "${SCRIPT_PATH}/mod/*:${SCRIPT_PATH}/lib/*" org.aion.wallet.WalletApplication | ||
|
||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.aion.wallet; | ||
|
||
import org.aion.wallet.connector.BlockchainConnector; | ||
import org.aion.wallet.ui.MainWindow; | ||
import org.aion.wallet.util.ConfigUtils; | ||
|
||
public class WalletApplication { | ||
public static void main(String args[]) { | ||
System.setProperty(ConfigUtils.WALLET_API_ENABLED_FLAG, "true"); | ||
javafx.application.Application.launch(MainWindow.class, args); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/org/aion/wallet/connector/BlockchainConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.aion.wallet.connector; | ||
|
||
import org.aion.wallet.connector.api.ApiBlockchainConnector; | ||
import org.aion.wallet.connector.core.CoreBlockchainConnector; | ||
import org.aion.wallet.connector.dto.SendRequestDTO; | ||
import org.aion.wallet.connector.dto.SyncInfoDTO; | ||
import org.aion.wallet.connector.dto.TransactionDTO; | ||
import org.aion.wallet.dto.AccountDTO; | ||
import org.aion.wallet.exception.NotFoundException; | ||
import org.aion.wallet.exception.ValidationException; | ||
import org.aion.wallet.storage.WalletStorage; | ||
import org.aion.wallet.util.ConfigUtils; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
|
||
public abstract class BlockchainConnector { | ||
|
||
private static BlockchainConnector INST; | ||
|
||
private final WalletStorage walletStorage = WalletStorage.getInstance(); | ||
|
||
public static BlockchainConnector getInstance() { | ||
if (INST != null) { | ||
return INST; | ||
} | ||
if (ConfigUtils.isEmbedded()) { | ||
INST = new CoreBlockchainConnector(); | ||
} else { | ||
INST = new ApiBlockchainConnector(); | ||
} | ||
return INST; | ||
} | ||
|
||
public abstract void createAccount(final String password, final String name); | ||
|
||
public abstract AccountDTO getAccount(final String address); | ||
|
||
public String sendTransaction(final SendRequestDTO dto) throws ValidationException { | ||
if (dto == null || !dto.validate()) { | ||
throw new ValidationException("Invalid transaction request data"); | ||
} | ||
if (dto.estimateValue().compareTo(getBalance(dto.getFrom())) >= 0) { | ||
throw new ValidationException("Insufficient funds"); | ||
} | ||
return sendTransactionInternal(dto); | ||
} | ||
|
||
protected abstract String sendTransactionInternal(final SendRequestDTO dto) throws ValidationException; | ||
|
||
public abstract List<AccountDTO> getAccounts(); | ||
|
||
public abstract TransactionDTO getTransaction(final String txHash) throws NotFoundException; | ||
|
||
public abstract List<TransactionDTO> getLatestTransactions(final String address); | ||
|
||
public abstract boolean getConnectionStatusByConnectedPeers(); | ||
|
||
public abstract SyncInfoDTO getSyncInfo(); | ||
|
||
public abstract BigInteger getBalance(final String address); | ||
|
||
public abstract AccountDTO addKeystoreUTCFile(final byte[] file, final String password) throws ValidationException; | ||
|
||
public abstract int getPeerCount(); | ||
|
||
// todo: Add balances with different currencies in AccountDTO | ||
public abstract String getCurrency(); | ||
|
||
public void close() { | ||
walletStorage.save(); | ||
} | ||
|
||
protected String getStoredAccountName(final String publicAddress) { | ||
return walletStorage.getAccountName(publicAddress); | ||
} | ||
|
||
protected void storeAccountName(final String address, final String name) { | ||
walletStorage.setAccountName(address, name); | ||
} | ||
} |
Oops, something went wrong.