diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Block.java b/ethereumj-core/src/main/java/org/ethereum/core/Block.java index 41b4a45a..c8fcd397 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Block.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Block.java @@ -244,6 +244,7 @@ public class Block { // [parent_hash, uncles_hash, coinbase, state_root, tx_trie_root, // difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp, // extradata, nonce] + @Override public String toString() { if (!parsed) parseRLP(); @@ -271,10 +272,37 @@ public class Block { toStringBuff.append( tx.toString() ); } - 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(); } diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsole.java b/ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsoleWindow.java similarity index 93% rename from ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsole.java rename to ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsoleWindow.java index 209b8c1b..fbeff685 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsole.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/ConnectionConsoleWindow.java @@ -26,7 +26,7 @@ import org.fife.ui.rtextarea.RTextScrollPane; * Project Home: http://fifesoft.com/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; @@ -39,8 +39,8 @@ public class ConnectionConsole extends JFrame implements PeerListener{ * TRACE (start/end method) */ - public ConnectionConsole() { - final ConnectionConsole thisConsole = this; + public ConnectionConsoleWindow() { + final ConnectionConsoleWindow thisConsole = this; java.net.URL url = ClassLoader.getSystemResource("ethereum-icon.png"); Toolkit kit = Toolkit.getDefaultToolkit(); @@ -95,7 +95,7 @@ public class ConnectionConsole extends JFrame implements PeerListener{ // Start all Swing applications on the EDT. SwingUtilities.invokeLater(new Runnable() { public void run() { - new ConnectionConsole().setVisible(true); + new ConnectionConsoleWindow().setVisible(true); } }); } diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableMain.java b/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableWindow.java similarity index 94% rename from ethereumj-core/src/main/java/org/ethereum/gui/PeersTableMain.java rename to ethereumj-core/src/main/java/org/ethereum/gui/PeersTableWindow.java index 367d7579..169f08cd 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableMain.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/PeersTableWindow.java @@ -20,7 +20,7 @@ import javax.swing.table.TableCellRenderer; * User: Roman Mandeleil * Created on: 25/04/14 07:11 */ -public class PeersTableMain extends JFrame{ +public class PeersTableWindow extends JFrame{ // Instance attributes used in this example private JPanel topPanel; @@ -28,7 +28,7 @@ public class PeersTableMain extends JFrame{ private JScrollPane scrollPane; // Constructor of main frame - public PeersTableMain() { + public PeersTableWindow() { // Set the frame characteristics setTitle("Ethereum Peers"); setSize(355, 300); @@ -75,7 +75,7 @@ public class PeersTableMain extends JFrame{ public static void main(String args[]) { - PeersTableMain mainFrame = new PeersTableMain(); + PeersTableWindow mainFrame = new PeersTableWindow(); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/ToolBar.java b/ethereumj-core/src/main/java/org/ethereum/gui/ToolBar.java index 1bbe2b05..95055393 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/ToolBar.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/ToolBar.java @@ -80,7 +80,7 @@ public class ToolBar extends JFrame { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { - new ConnectionConsole().setVisible(true); + new ConnectionConsoleWindow().setVisible(true); } }); } @@ -97,7 +97,7 @@ public class ToolBar extends JFrame { peersToggle.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - PeersTableMain mainFrame = new PeersTableMain(); + PeersTableWindow mainFrame = new PeersTableWindow(); mainFrame.setVisible( true ); // mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } @@ -128,6 +128,13 @@ public class ToolBar extends JFrame { walletToggle.setBorderPainted(false); walletToggle.setFocusPainted(false); 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(logToggle); diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/WalletAddressPanel.java b/ethereumj-core/src/main/java/org/ethereum/gui/WalletAddressPanel.java new file mode 100644 index 00000000..6d279d38 --- /dev/null +++ b/ethereumj-core/src/main/java/org/ethereum/gui/WalletAddressPanel.java @@ -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); + } +} diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/WalletSumPanel.java b/ethereumj-core/src/main/java/org/ethereum/gui/WalletSumPanel.java new file mode 100644 index 00000000..ff949d18 --- /dev/null +++ b/ethereumj-core/src/main/java/org/ethereum/gui/WalletSumPanel.java @@ -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); + } +} diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/WalletWindow.java b/ethereumj-core/src/main/java/org/ethereum/gui/WalletWindow.java new file mode 100644 index 00000000..cff8526a --- /dev/null +++ b/ethereumj-core/src/main/java/org/ethereum/gui/WalletWindow.java @@ -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); + + } +} diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/BlocksMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/message/BlocksMessage.java index 2453a22c..9086f774 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/message/BlocksMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/message/BlocksMessage.java @@ -55,12 +55,8 @@ public class BlocksMessage extends Message { StringBuffer sb = new StringBuffer(); for (Block blockData : this.getBlockDataList()) { - sb.append(" ").append(blockData.toString()).append("\n"); + sb.append(" ").append(blockData.toFlatString()).append("\n"); - List transactions = blockData.getTransactionsList(); - for (Transaction transactionData : transactions) { - sb.append("[").append(transactionData).append("]\n"); - } } return "Blocks Message [\n" + sb.toString() + " ]"; } diff --git a/ethereumj-core/src/main/resources/buttons/add-address.png b/ethereumj-core/src/main/resources/buttons/add-address.png new file mode 100644 index 00000000..ba9206b8 Binary files /dev/null and b/ethereumj-core/src/main/resources/buttons/add-address.png differ diff --git a/ethereumj-core/src/main/resources/buttons/wallet-pay.png b/ethereumj-core/src/main/resources/buttons/wallet-pay.png new file mode 100644 index 00000000..7b195817 Binary files /dev/null and b/ethereumj-core/src/main/resources/buttons/wallet-pay.png differ