Ethereum Wallet Prototype
Added GUI for future wallet, to run it one can run ToolBar and click on the wallet icon.
This commit is contained in:
parent
1f00205a14
commit
e7b2fd7d19
|
@ -244,6 +244,7 @@ public class Block {
|
||||||
// [parent_hash, uncles_hash, coinbase, state_root, tx_trie_root,
|
// [parent_hash, uncles_hash, coinbase, state_root, tx_trie_root,
|
||||||
// difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp,
|
// difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp,
|
||||||
// extradata, nonce]
|
// extradata, nonce]
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (!parsed) parseRLP();
|
if (!parsed) parseRLP();
|
||||||
|
@ -271,10 +272,37 @@ public class Block {
|
||||||
toStringBuff.append( tx.toString() );
|
toStringBuff.append( tx.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
toStringBuff.append("\n]");
|
toStringBuff.append("\n]");
|
||||||
|
return toStringBuff.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toFlatString(){
|
||||||
|
if (!parsed) parseRLP();
|
||||||
|
|
||||||
|
toStringBuff.setLength(0);
|
||||||
|
toStringBuff.append("BlockData [");
|
||||||
|
toStringBuff.append(" hash=" + Utils.toHexString(hash)).append("");
|
||||||
|
toStringBuff.append(" parentHash=" + Utils.toHexString(parentHash)).append("");
|
||||||
|
toStringBuff.append(" unclesHash=" + Utils.toHexString(unclesHash)).append("");
|
||||||
|
toStringBuff.append(" coinbase=" + Utils.toHexString(coinbase)).append("");
|
||||||
|
toStringBuff.append(" stateHash=" + Utils.toHexString(stateRoot)).append("");
|
||||||
|
toStringBuff.append(" txTrieHash=" + Utils.toHexString(txTrieRoot)).append("");
|
||||||
|
toStringBuff.append(" difficulty=" + Utils.toHexString(difficulty)).append("");
|
||||||
|
toStringBuff.append(" number=" + number).append("");
|
||||||
|
toStringBuff.append(" minGasPrice=" + minGasPrice).append("");
|
||||||
|
toStringBuff.append(" gasLimit=" + gasLimit).append("");
|
||||||
|
toStringBuff.append(" gasUsed=" + gasUsed).append("");
|
||||||
|
toStringBuff.append(" timestamp=" + timestamp).append("");
|
||||||
|
toStringBuff.append(" extraData=" + Utils.toHexString(extraData)).append("");
|
||||||
|
toStringBuff.append(" nonce=" + Utils.toHexString(nonce)).append("");
|
||||||
|
|
||||||
|
for (Transaction tx : getTransactionsList()){
|
||||||
|
|
||||||
|
toStringBuff.append("\n");
|
||||||
|
toStringBuff.append( tx.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
toStringBuff.append("]");
|
||||||
return toStringBuff.toString();
|
return toStringBuff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
* Project Home: http://fifesoft.com/rsyntaxtextarea<br>
|
* Project Home: http://fifesoft.com/rsyntaxtextarea<br>
|
||||||
* Downloads: https://sourceforge.net/projects/rsyntaxtextarea
|
* Downloads: https://sourceforge.net/projects/rsyntaxtextarea
|
||||||
*/
|
*/
|
||||||
public class ConnectionConsole extends JFrame implements PeerListener{
|
public class ConnectionConsoleWindow extends JFrame implements PeerListener{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ public class ConnectionConsole extends JFrame implements PeerListener{
|
||||||
* TRACE (start/end method)
|
* TRACE (start/end method)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ConnectionConsole() {
|
public ConnectionConsoleWindow() {
|
||||||
final ConnectionConsole thisConsole = this;
|
final ConnectionConsoleWindow thisConsole = this;
|
||||||
|
|
||||||
java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
|
java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
|
||||||
Toolkit kit = Toolkit.getDefaultToolkit();
|
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||||
|
@ -95,7 +95,7 @@ public class ConnectionConsole extends JFrame implements PeerListener{
|
||||||
// Start all Swing applications on the EDT.
|
// Start all Swing applications on the EDT.
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
new ConnectionConsole().setVisible(true);
|
new ConnectionConsoleWindow().setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ import javax.swing.table.TableCellRenderer;
|
||||||
* User: Roman Mandeleil
|
* User: Roman Mandeleil
|
||||||
* Created on: 25/04/14 07:11
|
* Created on: 25/04/14 07:11
|
||||||
*/
|
*/
|
||||||
public class PeersTableMain extends JFrame{
|
public class PeersTableWindow extends JFrame{
|
||||||
|
|
||||||
// Instance attributes used in this example
|
// Instance attributes used in this example
|
||||||
private JPanel topPanel;
|
private JPanel topPanel;
|
||||||
|
@ -28,7 +28,7 @@ public class PeersTableMain extends JFrame{
|
||||||
private JScrollPane scrollPane;
|
private JScrollPane scrollPane;
|
||||||
|
|
||||||
// Constructor of main frame
|
// Constructor of main frame
|
||||||
public PeersTableMain() {
|
public PeersTableWindow() {
|
||||||
// Set the frame characteristics
|
// Set the frame characteristics
|
||||||
setTitle("Ethereum Peers");
|
setTitle("Ethereum Peers");
|
||||||
setSize(355, 300);
|
setSize(355, 300);
|
||||||
|
@ -75,7 +75,7 @@ public class PeersTableMain extends JFrame{
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
|
|
||||||
PeersTableMain mainFrame = new PeersTableMain();
|
PeersTableWindow mainFrame = new PeersTableWindow();
|
||||||
mainFrame.setVisible(true);
|
mainFrame.setVisible(true);
|
||||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
}
|
}
|
|
@ -80,7 +80,7 @@ public class ToolBar extends JFrame {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
new ConnectionConsole().setVisible(true);
|
new ConnectionConsoleWindow().setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class ToolBar extends JFrame {
|
||||||
peersToggle.addActionListener( new ActionListener() {
|
peersToggle.addActionListener( new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
PeersTableMain mainFrame = new PeersTableMain();
|
PeersTableWindow mainFrame = new PeersTableWindow();
|
||||||
mainFrame.setVisible( true );
|
mainFrame.setVisible( true );
|
||||||
// mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
// mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,13 @@ public class ToolBar extends JFrame {
|
||||||
walletToggle.setBorderPainted(false);
|
walletToggle.setBorderPainted(false);
|
||||||
walletToggle.setFocusPainted(false);
|
walletToggle.setFocusPainted(false);
|
||||||
walletToggle.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
walletToggle.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
|
walletToggle.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
WalletWindow walletWindow = new WalletWindow();
|
||||||
|
walletWindow.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cp.add(editorToggle);
|
cp.add(editorToggle);
|
||||||
cp.add(logToggle);
|
cp.add(logToggle);
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package org.ethereum.gui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* www.ethereumJ.com
|
||||||
|
* User: Roman Mandeleil
|
||||||
|
* Created on: 17/05/14 12:32
|
||||||
|
*/
|
||||||
|
public class WalletAddressPanel extends JPanel{
|
||||||
|
|
||||||
|
public WalletAddressPanel() {
|
||||||
|
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
double width = this.getSize().getWidth();
|
||||||
|
this.setPreferredSize(new Dimension(500, 50));
|
||||||
|
|
||||||
|
JTextField addressField = new JTextField();
|
||||||
|
Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
|
||||||
|
Border empty = new EmptyBorder(5, 8, 5, 8);
|
||||||
|
CompoundBorder border = new CompoundBorder(line, empty);
|
||||||
|
addressField.setBorder(border);
|
||||||
|
addressField.setEnabled(true);
|
||||||
|
addressField.setEditable(false);
|
||||||
|
addressField.setText("5a554ee950faddf206972771bebd3dc0f13f1f4d");
|
||||||
|
addressField.setForeground(new Color(143, 170, 220));
|
||||||
|
addressField.setBackground(Color.WHITE);
|
||||||
|
this.add(addressField);
|
||||||
|
|
||||||
|
JTextField amount = new JTextField();
|
||||||
|
amount.setBorder(border);
|
||||||
|
amount.setEnabled(true);
|
||||||
|
amount.setEditable(false);
|
||||||
|
amount.setText("234 * 10^9");
|
||||||
|
amount.setForeground(new Color(143, 170, 220));
|
||||||
|
amount.setBackground(Color.WHITE);
|
||||||
|
this.add(amount);
|
||||||
|
|
||||||
|
URL payoutIconURL = ClassLoader.getSystemResource("buttons/wallet-pay.png");
|
||||||
|
ImageIcon payOutIcon = new ImageIcon(payoutIconURL);
|
||||||
|
JLabel payOutLabel = new JLabel(payOutIcon);
|
||||||
|
payOutLabel.setToolTipText("Payout for address");
|
||||||
|
payOutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
|
payOutLabel.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
System.out.println("boom");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
this.add(payOutLabel);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package org.ethereum.gui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* www.ethereumJ.com
|
||||||
|
* User: Roman Mandeleil
|
||||||
|
* Created on: 17/05/14 12:32
|
||||||
|
*/
|
||||||
|
public class WalletSumPanel extends JPanel{
|
||||||
|
|
||||||
|
public WalletSumPanel() {
|
||||||
|
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
double width = this.getSize().getWidth();
|
||||||
|
this.setPreferredSize(new Dimension(500, 50));
|
||||||
|
Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
|
||||||
|
Border empty = new EmptyBorder(5, 8, 5, 8);
|
||||||
|
CompoundBorder border = new CompoundBorder(line, empty);
|
||||||
|
|
||||||
|
JLabel addressField = new JLabel();
|
||||||
|
addressField.setPreferredSize(new Dimension(276, 50));
|
||||||
|
this.add(addressField);
|
||||||
|
|
||||||
|
JTextField amount = new JTextField();
|
||||||
|
amount.setBorder(border);
|
||||||
|
amount.setEnabled(true);
|
||||||
|
amount.setEditable(false);
|
||||||
|
amount.setText("234 * 10^9");
|
||||||
|
amount.setForeground(new Color(143, 170, 220));
|
||||||
|
amount.setBackground(Color.WHITE);
|
||||||
|
this.add(amount);
|
||||||
|
|
||||||
|
URL payoutIconURL = ClassLoader.getSystemResource("buttons/wallet-pay.png");
|
||||||
|
ImageIcon payOutIcon = new ImageIcon(payoutIconURL);
|
||||||
|
JLabel payOutLabel = new JLabel(payOutIcon);
|
||||||
|
payOutLabel.setToolTipText("Payout for all address list");
|
||||||
|
payOutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
|
payOutLabel.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
System.out.println("boom");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.add(payOutLabel);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.ethereum.gui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.CompoundBorder;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* www.ethereumJ.com
|
||||||
|
* User: Roman Mandeleil
|
||||||
|
* Created on: 17/05/14 12:00
|
||||||
|
*/
|
||||||
|
public class WalletWindow extends JFrame {
|
||||||
|
|
||||||
|
|
||||||
|
public WalletWindow() {
|
||||||
|
|
||||||
|
java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png");
|
||||||
|
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||||
|
Image img = kit.createImage(url);
|
||||||
|
this.setIconImage(img);
|
||||||
|
setTitle("Ethereum Wallet");
|
||||||
|
setSize(490, 370);
|
||||||
|
setLocation(215, 280);
|
||||||
|
setBackground(Color.WHITE);
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
Container contentPane = this.getContentPane();
|
||||||
|
contentPane.setLayout(new FlowLayout());
|
||||||
|
contentPane.setBackground(Color.WHITE);
|
||||||
|
|
||||||
|
WalletAddressPanel panel1 = new WalletAddressPanel();
|
||||||
|
WalletAddressPanel panel2 = new WalletAddressPanel();
|
||||||
|
WalletAddressPanel panel3 = new WalletAddressPanel();
|
||||||
|
WalletAddressPanel panel4 = new WalletAddressPanel();
|
||||||
|
WalletSumPanel panel5 = new WalletSumPanel();
|
||||||
|
|
||||||
|
contentPane.add(panel1);
|
||||||
|
contentPane.add(panel2);
|
||||||
|
contentPane.add(panel3);
|
||||||
|
contentPane.add(panel4);
|
||||||
|
contentPane.add(panel5);
|
||||||
|
|
||||||
|
URL addAddressIconURL = ClassLoader.getSystemResource("buttons/add-address.png");
|
||||||
|
ImageIcon addAddressIcon = new ImageIcon(addAddressIconURL);
|
||||||
|
JLabel addAddressLabel = new JLabel(addAddressIcon);
|
||||||
|
addAddressLabel.setToolTipText("Add new address");
|
||||||
|
addAddressLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||||
|
addAddressLabel.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
System.out.println("boom");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
contentPane.add(addAddressLabel);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,12 +55,8 @@ public class BlocksMessage extends Message {
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
for (Block blockData : this.getBlockDataList()) {
|
for (Block blockData : this.getBlockDataList()) {
|
||||||
sb.append(" ").append(blockData.toString()).append("\n");
|
sb.append(" ").append(blockData.toFlatString()).append("\n");
|
||||||
|
|
||||||
List<Transaction> transactions = blockData.getTransactionsList();
|
|
||||||
for (Transaction transactionData : transactions) {
|
|
||||||
sb.append("[").append(transactionData).append("]\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return "Blocks Message [\n" + sb.toString() + " ]";
|
return "Blocks Message [\n" + sb.toString() + " ]";
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
Loading…
Reference in New Issue