id
stringlengths
36
36
text
stringlengths
1
1.25M
669391f0-02e9-416e-9e73-ee0133e5f7e0
public Object_ReferenceArray(Object_PrimitiveFields[] arr) { array = arr; }
232254cb-2e79-488b-9a38-57ac17c3547e
public void AssignFieldsThroughUserInput() { String userInput = null; System.out.println("Please select values for the fields, or Exit:"); Scanner in = new Scanner(System.in); System.out.println("array:"); int i = 0; while(i < array.length) { try { System.out.print("Object_PrimitiveArray [" + i + "] "); // Get field value from user Object_PrimitiveFields obj = new Object_PrimitiveFields(); obj.AssignFieldsThroughUserInput(); array[i] = obj; i++; } catch(NumberFormatException e) { if(userInput.equalsIgnoreCase("exit")) System.exit(0); else { System.out.println("Not a valid answer. Please try again."); } } } }
fca88e13-14a3-43f6-81b0-3776d687bba2
public ObjectInspector() { }
8fd77a60-271a-4eba-bc30-edf72558191c
public void inspect(Object obj, boolean recursive) { Vector objectsToInspect = new Vector(); Vector arrayObjectsToInspect = new Vector(); Vector superclassObjectsToInspect = new Vector(); Class ObjClass = obj.getClass(); System.out.println("Doing object inspection of : " + obj + " (recursive = "+recursive+")"); //inspect the current class String declaringClassName = inspectDeclaringClassName(obj, ObjClass); System.out.println("Declaring class: " + declaringClassName); String immediateSuperclassName = inspectImmediateSuperclass(obj, ObjClass, superclassObjectsToInspect); System.out.println("Immediate super class: " + immediateSuperclassName); System.out.println("Implemented interfaces:"); inspectImplementedInterfaces(obj, ObjClass, objectsToInspect); System.out.println("Methods:"); this.inspectMethods(obj, ObjClass); System.out.println("Constructors:"); this.inspectConstructors(obj, ObjClass); System.out.println("Fields:"); inspectFields(obj, ObjClass,objectsToInspect, arrayObjectsToInspect, recursive); if(!superclassObjectsToInspect.isEmpty()) //inspectSuperClass(superclassObjectsToInspect, recursive); if(recursive) inspectFieldClasses( obj, ObjClass, objectsToInspect, recursive); inspectArrayValueClasses(arrayObjectsToInspect, recursive); }
929049db-25dc-4d72-9129-9f14f9c6d6f1
public String inspectDeclaringClassName(Object obj, Class ObjClass) { Class declaringClass = ObjClass.getDeclaringClass(); if(declaringClass == null) { return "None"; } else { return declaringClass.getCanonicalName().toString(); } }
7c3583bf-fd05-4eda-a055-e8859baedbff
public String inspectImmediateSuperclass(Object obj, Class ObjClass, Vector superclassObjectsToInspect) { Class superClass = ObjClass.getSuperclass(); if(superClass == null) { return "None"; } else { superclassObjectsToInspect.addElement(superClass); return superClass.getCanonicalName().toString(); } }
172f82d9-af50-4219-841a-fec55bf58db8
private void inspectSuperClass(Vector superclassObjectsToInspect, boolean recursive) { if(superclassObjectsToInspect.size() > 0 ) System.out.println("---- Inspecting Super Classes ----"); Enumeration e = superclassObjectsToInspect.elements(); while(e.hasMoreElements()) { Class s = (Class) e.nextElement(); System.out.println("Inspecting Superclass: " + s.getName()); try { System.out.println("******************"); inspect( s, recursive); System.out.println("******************"); } catch(Exception exp) { exp.printStackTrace(); } } }
929109bb-c997-4334-b680-0b30f7f371f6
public void inspectImplementedInterfaces(Object obj, Class ObjClass, Vector objectsToInspect) { Class[] interfaces = ObjClass.getInterfaces(); for(Class currentInterface : interfaces) { System.out.println("\t" + currentInterface.getCanonicalName()); //TODO: Add the inspected interfaces to objects to inspect } }
e4417fe9-c761-451d-9de5-b380d6b79ea3
private void inspectMethods(Object obj, Class ObjClass) { Method[] methods = ObjClass.getDeclaredMethods(); if(methods.length < 1) return; for(Method currentMethod : methods) { currentMethod.setAccessible(true); System.out.println("\tInspecting method " + currentMethod.getName() + ":"); // Exceptions -------------------// Class[] exceptionsThrown = currentMethod.getExceptionTypes(); if(exceptionsThrown.length == 0) { System.out.println("\t\tNo Exceptions thrown"); } else { System.out.println("\t\tExceptions thrown:"); for(Class exceptionType : exceptionsThrown) { System.out.println("\t\t\t" + exceptionType.getCanonicalName()); } } // Parameters --------------------// Class[] parameterTypes = currentMethod.getParameterTypes(); if(parameterTypes.length == 0) { System.out.println("\t\tNo Parameters"); } else { System.out.println("\t\tParameter types:"); for(Class parameter : parameterTypes ) { System.out.println("\t\t\t" + parameter.getSimpleName()); } } // Return types ----------------// Class returnType = currentMethod.getReturnType(); System.out.println("\t\tReturn type is " + returnType.getCanonicalName()); // The modifiers ----------------// int modifier = currentMethod.getModifiers(); System.out.println("\t\tModifier: " + Modifier.toString(modifier)); } }
0bb13ad7-eeea-4d3c-8b7d-ca79b16d252d
private void inspectConstructors(Object obj, Class ObjClass) { Constructor[] constructors = ObjClass.getConstructors(); int i = 1; if(constructors.length < 1) return; for(Constructor currentConstructor : constructors) { currentConstructor.setAccessible(true); System.out.println("\tInspecting constructor " + i++ + ":"); // Parameters --------------------// Class[] parameterTypes = currentConstructor.getParameterTypes(); if(parameterTypes.length == 0) { System.out.println("\t\tNo Parameters"); } else { System.out.println("\t\tParameter types:"); for(Class parameter : parameterTypes ) { System.out.println("\t\t\t" + parameter.getSimpleName()); } } // The modifiers ----------------// int modifier = currentConstructor.getModifiers(); System.out.println("\t\tModifiers: " + Modifier.toString(modifier)); } }
a9fba8ed-c331-44db-8a3b-ec2ff63cbf07
private void inspectFields(Object obj,Class ObjClass,Vector objectsToInspect, Vector arrayObjectsToInspect, boolean recursive) { if(ObjClass.getDeclaredFields().length >= 1) { Field[] fields = ObjClass.getDeclaredFields(); for(Field f : fields) { f.setAccessible(true); if(! f.getType().isPrimitive() && !f.getType().isArray()) { objectsToInspect.addElement( f ); } // Name ----// System.out.println("\tField: " + f.getName()); // Type ----// System.out.println("\t\tType: " + f.getType().getName()); // The modifiers ----// int modifier = f.getModifiers(); System.out.println("\t\tModifiers: " + Modifier.toString(modifier)); // Value ---// try { if(! f.getType().isPrimitive() && !recursive && !f.getType().isArray()) { System.out.println("\t\tValue: " + f.get(obj).hashCode()); } else if(! f.getType().isPrimitive() && recursive && !f.getType().isArray()) { System.out.println("\t\tValue: To be inspected recursively"); } else if(f.getType().isArray()) { String indentationString = "\t\t"; System.out.println(indentationString + "Values: "); handleArray(f.get(obj), arrayObjectsToInspect, arrayObjectsToInspect, indentationString, recursive); } else { System.out.println("\t\tValue: " + f.get(obj)); } } catch(IllegalAccessException e) { System.out.println("When getting objects from fields: " + e); return; } } } if(ObjClass.getSuperclass() != null) inspectFields(obj, ObjClass.getSuperclass() , objectsToInspect, arrayObjectsToInspect, recursive); }
7deabaa1-e35b-4186-a3aa-e87eb9e3c68c
private void handleArray(Object arrObj, Vector objectsToInspect, Vector arrayObjectsToInspect, String indentationString, boolean rec) { boolean isPrimitive = false; if(arrObj == null) return; isPrimitive = arrObj.getClass().getComponentType().isPrimitive(); int length = Array.getLength(arrObj); for (int i = 0; i < length; i ++) { Object item = Array.get(arrObj, i); if(item == null) { System.out.println(indentationString + "\t" + i + ") null"); } else if(isPrimitive) { System.out.println(indentationString + "\t" + i + ") "+ item); } // Recursively handle arrays which have more than 1 dimension else if(item.getClass().isArray()) { System.out.println(indentationString + "\t" + i + ")"); handleArray(item, objectsToInspect, arrayObjectsToInspect, indentationString + "\t", rec); } // The values of array are objects, and each one needs to be recursively inspected else if(rec) { System.out.println(indentationString + "\t" + i + ") to be inspected recursively"); arrayObjectsToInspect.addElement(item); } // The values of the array are objects, but they do not need to be recursively inspected else { System.out.println(indentationString + "\t" + i + ") " + item.hashCode()); } } }
32f18d21-3edc-4330-8039-942dc495b03b
private void inspectArrayValueClasses(Vector objectsToInspect,boolean recursive) { if(objectsToInspect.size() > 0 ) { System.out.println("---- Inspecting Array Value Classes ----"); } Enumeration e = objectsToInspect.elements(); while(e.hasMoreElements()) { Object arrayValue = e.nextElement(); //Class classObj = arrayValue.getClass(); if(arrayValue == null) { System.out.println("\t" + arrayValue + " cannot be inspected, because object is null."); } else { System.out.println("Inspecting Array Value: " ); try { System.out.println("******************"); inspect( (Object)arrayValue , recursive); System.out.println("******************"); } catch(Exception exp) { exp.printStackTrace(); } } } }
4f6887aa-ad80-476e-8ec9-6bf3b00902da
private void inspectFieldClasses(Object obj,Class ObjClass, Vector objectsToInspect, boolean recursive) { if(objectsToInspect.size() > 0 ) System.out.println("---- Inspecting Field Classes ----"); Enumeration e = objectsToInspect.elements(); while(e.hasMoreElements()) { Field f = (Field) e.nextElement(); try { if(f.get(obj) == null) { System.out.println("\t" + f.getName() + " cannot be inspected, because object is null."); } else { System.out.println("Inspecting Field: " + f.getName()); try { System.out.println("******************"); inspect( f.get(obj) , recursive); System.out.println("******************"); } catch(Exception exp) { exp.printStackTrace(); } } } catch(IllegalAccessException ex) { System.out.println(e); return; } } }
ea453733-376d-4e70-97ff-bb903be964bf
public ObjectCreator() { createdObject = null; }
e9a4bc2d-3395-4ee2-9098-21bbb3844cc1
public Object getCreatedObject() { return createdObject; }
4f46c2c0-2af1-40a3-b739-a1324c253874
public void runObjectCreationUserQuery() { String userInput = null; boolean done = false; System.out.println("Please select type of object you'd like to create, or Exit:"); for(AvailableObjectsToCreate option : AvailableObjectsToCreate.values()) { System.out.println(option.ordinal() + ") " + option); } Scanner in = new Scanner(System.in); while(!done) { System.out.print("> "); userInput = in.nextLine(); try { // Get type of object user wants to create int selection = Integer.parseInt(userInput); if(selection < 0 || selection > AvailableObjectsToCreate.values().length) { throw new NumberFormatException(); } System.out.println("Creating " + AvailableObjectsToCreate.values()[selection].toString() + " object..."); createdObject = CreateObject(selection); System.out.println("Object created successfully."); done = true; } catch(NumberFormatException e) { if(userInput.equalsIgnoreCase("exit")) System.exit(0); else System.out.println("Not a valid answer. Please try again."); } } }
7e4581ba-31d1-44d9-bb23-7b3328ee28e3
public Object CreateObject(int selection) { Class c = null; Constructor constructor = null; Object o = null; try { c = Class.forName(AvailableObjectsToCreate.values()[selection].toString()); constructor = c.getConstructor(null); o = constructor.newInstance(null); Method m = c.getMethod("AssignFieldsThroughUserInput", null); m.invoke(o, null); } catch(ClassNotFoundException e) { System.out.println(e + "Could not get class object"); System.exit(0); } catch (InstantiationException e) { System.out.println(e + "Could instantiate object"); System.exit(0); } catch (NoSuchMethodException e) { System.out.println(e + "Could not get object constructor"); System.exit(0); } catch(IllegalAccessException e) { System.out.println(e + "Could not access method to assign values"); System.exit(0); } catch(InvocationTargetException e) { System.out.println(e + "Could not invoke method to assign values"); System.exit(0); } return o; }
276ad68a-ce11-4bd1-8f56-eab86b521528
public static void main(String[] args) { if(args.length < 2 || args.length > 3) { System.out.println("Usage: Main <Serializer or Deserializer> port [serverIP]"); } String state = args[0]; int serverPort = Integer.parseInt(args[1]); if(state.equalsIgnoreCase("Serializer")) { boolean continueToSend = true; Socket client = null; Scanner scanner = new Scanner(System.in); while(continueToSend ) { // Create object ObjectCreator oc = new ObjectCreator(); oc.runObjectCreationUserQuery(); // Serialize object Serializer s = new Serializer(); try { s.serialize(oc.getCreatedObject()); } catch(ObjectToSerializeWasNullException e) { System.out.println("Could not serialize object, because it was null"); System.exit(0); } Document doc = s.getDoc(); // Send object String serverName = args[2]; try { System.out.println("Connecting to " + serverName + " on port " + serverPort); client = new Socket(serverName, serverPort); System.out.println("Just connected to " + client.getRemoteSocketAddress()); OutputStream outToServer = client.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(outToServer ); oos.writeObject(doc); oos.flush(); System.out.println("Object was sent."); }catch(IOException e) { e.printStackTrace(); } while(true) { System.out.println("Send another object? [Y or N]"); String answer = scanner.nextLine(); if(answer.equalsIgnoreCase("y")) { continueToSend = true; break; } else if(answer.equalsIgnoreCase("n")) { continueToSend = false; break; } else { System.out.println("Sorry, that was not a valid response. Please try again."); } } } System.out.println("Closed the connection."); try { client.close(); }catch(IOException e) { e.printStackTrace(); } } else if(state.equalsIgnoreCase("Deserializer")) { Thread t = new Server(serverPort); t.start(); } }
0acf7a49-c71c-4b6b-a8e9-a40989624213
public Object_PrimitiveArray() { array = new int[3]; }
55958466-3706-4177-87ef-c749ef3f3d13
public Object_PrimitiveArray(int[] arr) { array = arr; }
a0f68c1b-4b2e-4ab8-8cbe-7ea6a7f7a355
public void AssignFieldsThroughUserInput() { String userInput = null; System.out.println("Please select values for the fields, or Exit:"); Scanner in = new Scanner(System.in); System.out.println("array:"); int i = 0; while(i < array.length) { try { System.out.print("int [" + i + "] = "); userInput = in.nextLine(); int selection = Integer.parseInt(userInput); array[i] = selection; i++; } catch(NumberFormatException e) { if(userInput.equalsIgnoreCase("exit")) System.exit(0); else { System.out.println("Not a valid answer. Please try again."); } } } }
98835b36-c565-4e38-82b6-9e97d9dc5738
public Object_ReferenceFields(){}
bda5176f-cbfc-428a-88dd-24e76ad786ce
public Object_ReferenceFields(Object_PrimitiveFields a, Object_PrimitiveFields b) { object1 = a; object2 = b; }
5c1ee33e-2e49-4f8a-b1d5-e35adde4d857
public void AssignFieldsThroughUserInput() { String userInput = null; System.out.println("Please select values for the fields, or Exit:"); Scanner in = new Scanner(System.in); Class c = this.getClass(); Field[] declaredFields = c.getDeclaredFields(); int i = 0; while(i < declaredFields.length) { System.out.print(declaredFields[i].getType() + " " + declaredFields[i].getName()); System.out.println(); try { // Get field value from user Object_PrimitiveFields obj = new Object_PrimitiveFields(); obj.AssignFieldsThroughUserInput(); declaredFields[i].setAccessible(true); declaredFields[i].set(this, obj); i++; } catch(NumberFormatException e) { if(userInput.equalsIgnoreCase("exit")) System.exit(0); else System.out.println("Not a valid answer. Please try again."); } catch(IllegalAccessException e) { System.out.println("Cannot access the field."); System.exit(0); } } }
7beb51da-b17e-4200-b12c-e85234431d25
public Object deserialize(Document doc) { obj_registry = new IdentityHashMap<Long, Object>(); // reset Object obj = null; Element root = doc.getRootElement(); List<Element> objElemList = root.getChildren("object"); // Place object elements in a registry for(Element objElem : objElemList) { Long id = null; String className = null; try { id = objElem.getAttribute("id").getLongValue(); className = objElem.getAttribute("class").getValue(); //Get instance of object Class c = Class.forName(className); Object newObj = null; if(c.isArray()) { newObj = Array.newInstance(c.getComponentType(), Integer.parseInt(objElem.getAttributeValue("length"))); } else { Constructor con = c.getConstructor(null); newObj = con.newInstance(null); } obj_registry.put(id, newObj); } catch(DataConversionException e) { System.out.println("Could not convert id of object to integer."); System.exit(0); } catch(ClassNotFoundException e) { System.out.println("Could not get class of obj elem."); System.exit(0); } catch(NoSuchMethodException e) { System.out.println("Could not get the constructor of the elem."); System.exit(0); } catch(InstantiationException e) { System.out.println("Could not instantiate the obj."); System.exit(0); } catch(IllegalAccessException e) { System.out.println("Could not use the constructor."); System.exit(0); } catch(InvocationTargetException e) { System.out.println("Invocation exception."); System.exit(0); } } // Assign fields for(Element objElem : objElemList) { Long id = null; Object registryObj = null; try { id = objElem.getAttribute("id").getLongValue(); registryObj = this.obj_registry.get(id); if(registryObj.getClass().isArray()) { int arrayLength = Integer.parseInt(objElem.getAttributeValue("length")); Class cType = registryObj.getClass().getComponentType(); List<Element> arrayValues = objElem.getChildren(); if(cType.isPrimitive()) { for (int i = 0; i < arrayLength; i ++) { Object item = Array.get(registryObj, i); Object o = getPrimitiveFieldValue(arrayValues.get(i).getContent(0), cType); Array.set(registryObj, i, o); } } else { for (int i = 0; i < arrayLength; i ++) { Object item = Array.get(registryObj, i); Object key = getPrimitiveFieldValue(arrayValues.get(i).getContent(0), long.class); Object o = this.obj_registry.get(key); Array.set(registryObj, i, o); } } } else { // Get fields of object List<Element> fieldElemList = objElem.getChildren("field"); for(Element fieldElem : fieldElemList) { String attrName = fieldElem.getAttributeValue("name"); Field field = registryObj.getClass().getDeclaredField(attrName); field.setAccessible(true); if(fieldIsPrimitive(fieldElem)) { fieldElem.getChild("value"); field.set(registryObj, getPrimitiveFieldValue(fieldElem.getChild("value").getContent().get(0), field.getType())); } // Field has an object reference else { String objRef = fieldElem.getChild("reference").getContent().get(0).getValue(); Long objRefId = Long.parseLong(objRef); field.set(registryObj, this.obj_registry.get(objRefId)); } } } } catch(DataConversionException e) { System.out.println("Could not convert id of object to integer."); System.exit(0); } catch(NoSuchFieldException e) { System.out.println("No Such field exception."); System.exit(0); } catch(IllegalAccessException e) { System.out.println("Field not accessed"); System.exit(0); } } Long key = 0l; obj = this.obj_registry.get(key); return obj; }
1b045173-ff32-4ac4-b812-2a373155026c
private Object getPrimitiveFieldValue(Content content, Class classType) { Object primitiveToReturn = null; if(classType.equals(int.class)) primitiveToReturn = Integer.parseInt(content.getValue()); else if(classType.equals(short.class)) primitiveToReturn = Short.parseShort(content.getValue()); else if(classType.equals(byte.class)) primitiveToReturn = Byte.parseByte(content.getValue()); else if(classType.equals(long.class)) primitiveToReturn = Long.parseLong(content.getValue()); else if(classType.equals(float.class)) primitiveToReturn = Float.parseFloat(content.getValue()); else if(classType.equals(double.class)) primitiveToReturn = Double.parseDouble(content.getValue()); else if(classType.equals(char.class)) primitiveToReturn = new Character(content.getValue().charAt(0)); return primitiveToReturn; }
1901d023-cb6c-4a9d-a51d-1828ccd48409
private boolean fieldIsPrimitive(Element fieldElem) { return fieldElem.getChild("value") != null; }
087602c9-a22b-4729-9361-f845c745edfa
public static ArrayList<String[]> parseWIFtext(String walletText){ ArrayList<String[]> keyAddressPairs = new ArrayList<String[]>(); String trimedInputString = walletText.trim(); String[] lines = trimedInputString.split("\n"); for (String line : lines) { String trimedLine = line.trim(); if(trimedLine.equals("") || trimedLine.charAt(0)=='#'){ continue; } String trimedLineWithoutTabs = trimedLine.replace('\t', ' '); String privKeyWIF = trimedLineWithoutTabs.split(" ")[0]; String address = BtcUtils.getb58AddressFromb58PrivKey(privKeyWIF); keyAddressPairs.add(new String[]{privKeyWIF,address}); } return keyAddressPairs; }
6c50a764-618f-4c4d-85ac-4c562ed16843
public AddessesDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); }
5ded3e40-de82-4685-8887-b44495cfbf5e
public void setTableModel(TableModel model) { jTable1.setModel(model); jTable1.getColumnModel().getColumn(0).setPreferredWidth(200); }
c84919e4-8cc3-49c8-9bab-b48c8b6b8637
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Bitcoin PrivateKey QR - Addresses"); jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 781, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents
ff97f5da-f36f-42f4-b323-ca4c0e352514
@Override public boolean isCellEditable(int row, int column){ return false; }
99c4f32e-b44f-4bba-87a4-d76f9834b692
public void setContents(ArrayList<String[]> listOfArrayRows){ for (String[] row : listOfArrayRows) { this.addRow(row); } }
fb2a9ed1-4dcc-4285-93c7-1b5d2e0f8dbf
public AppWindow() { initComponents(); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); }
dc4fdb09-b777-4c7f-bb23-b6a698a06ee0
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("BitcoinPrivatekeyQR"); jLabel1.setFont(jLabel1.getFont()); jLabel1.setText("Enter your private keys, one per line"); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); jButton1.setText("Show all QR codes"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setFont(jButton2.getFont()); jButton2.setText("View addresses"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(0, 0, Short.MAX_VALUE)))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 420, Short.MAX_VALUE) .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap()) ); jButton2.getAccessibleContext().setAccessibleName("View addresses"); pack(); }// </editor-fold>//GEN-END:initComponents
99258740-da78-4d16-86fd-976f8b816391
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); }
05863915-ef56-4c2b-a041-64bbdfff44e7
public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); }
a0a368b9-1acc-4cf7-977a-90ca9a861546
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed //TODO: move this stuff to its own class JDialog AllQRCodesWindow = new JDialog(this, true); JPanel jpanelContainer = new JPanel(); jpanelContainer.setLayout(new BoxLayout(jpanelContainer, BoxLayout.PAGE_AXIS)); String keysRawString = jTextArea1.getText(); ArrayList<String[]> keyAddressPairs = WIFParser.parseWIFtext(keysRawString); for (String[] stringskeyAddressPair : keyAddressPairs) { try { //TODO: format this stuff with html and a different layout. Check example here: // http://docs.oracle.com/javase/tutorial/uiswing/components/html.html File file = QRCode.from( stringskeyAddressPair[0]).withSize(200, 200).file(); BufferedImage bufferedImage = ImageIO.read(file); JPanel singleAddressPanel = new JPanel(); singleAddressPanel.setLayout(new BoxLayout(singleAddressPanel, BoxLayout.LINE_AXIS)); singleAddressPanel.add(new JLabel(new ImageIcon(bufferedImage))); singleAddressPanel.add(new JLabel(stringskeyAddressPair[0])); jpanelContainer.add(singleAddressPanel); } catch (IOException e) { System.out.println("Error generating QR code"); } } AllQRCodesWindow.getContentPane().add(jpanelContainer); AllQRCodesWindow.pack(); AllQRCodesWindow.setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed
57c20f18-74f3-44b1-adef-981a3302f84b
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String keysRawString = jTextArea1.getText(); ArrayList<String[]> keyAddressPairs = WIFParser.parseWIFtext(keysRawString); ReadOnlyTableModel model = new ReadOnlyTableModel(); model.setColumnIdentifiers(new String[]{"Private Key", "Address"}); model.setContents(keyAddressPairs); addessesDialog.setTableModel(model); addessesDialog.setVisible(true); }//GEN-LAST:event_jButton2ActionPerformed
b16e8613-3a68-4749-8d08-5eea9f5ea207
public static void main(String args[]) { /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AppWindow().setVisible(true); } }); }
1b9fb1cc-568c-46f2-a18e-708ee0ff0be7
public void run() { new AppWindow().setVisible(true); }
9f0a9a5f-a6d9-4eab-9619-fa46324c37a6
public static String getb58AddressFromb58PrivKey(String privKey){ try { NetworkParameters networkParameters = NetworkParameters.prodNet(); DumpedPrivateKey dumpedPrivateKey = new DumpedPrivateKey(null, privKey); ECKey eCKey = dumpedPrivateKey.getKey(); Address address = eCKey.toAddress(networkParameters); return address.toString(); } catch (AddressFormatException e) { return "error"; } }
81cb53c2-afe1-408b-923f-a5e971cc0b10
public static String getHexFromb58(String b58String){ try { return Base58.decodeToBigInteger(b58String).toString(16); } catch (AddressFormatException ex) { return "ERROR CONVERTING TO HEX"; } }
b45eaff3-1a5d-4289-8bf5-25dc5de3c2dc
public BtcUtilsTest(String testName) { super(testName); }
26182ee3-9673-4eb9-b95e-61387ff33151
@Override protected void setUp() throws Exception { super.setUp(); }
bc07b52f-1472-4dd9-b147-cf5a193d7a4a
@Override protected void tearDown() throws Exception { super.tearDown(); }
827b794f-8e7f-4a56-8458-af628a9314b9
public void testGetb58AddressFromb58PrivKey() { String privKString = "5J8wBGJxiXMyPp3oJ3ffw8CvAYgPyV6tAYDHga22tjqGnkEhKLE"; System.out.println("Private Key: " + privKString); String result = BtcUtils.getb58AddressFromb58PrivKey(privKString); System.out.println("Adress: " + result); assertEquals(result, "1FZKaok8PeybVQhVcBLVfL21rHKBMntMaE"); // TODO review the generated test code and remove the default call to fail. //fail("The test case is a prototype."); }
a4cfe735-8cfd-48c3-ba63-8e0eb0b31cbf
public void testBase58ToHex(){ String b58ProvKeyExample = "5JrjYMTFcUpu6W64FeE2sjUdWhEUUG3WxtJquPkSq43kdAJn2YH"; String hexProvKeyExample = BtcUtils.getHexFromb58(b58ProvKeyExample); System.out.println("hex:" + hexProvKeyExample); assertEquals("808940ee2a9ecb23501e191f76d14e4a1f0f9a4bbccdfcfac655d81bb72f0b4b9f50743a72", hexProvKeyExample); }
86136c6b-e78b-447a-8368-85adc236cf2b
public long getId() { return id; }
62344edd-0fdd-435f-a9ce-fb446d0c2041
public long getHeaderId() { return headerId; }
6d54cd4a-3750-4cbb-ae91-371666c92d96
public String getComment() { return comment; }
0a47657c-5029-431f-972b-c9d6430e1ed0
public void setComment(String val) { comment=val; }
f3861eb8-f040-4009-ba86-ecf8c73adf8c
public int getQuantity() { return qty; }
8b75b9f3-cf77-4a00-8dff-c69315b7d1cc
public void setQuantity(int val) { qty=val; }
44bace16-4975-4c60-8ebd-cd61fd7165f9
public Calendar getUpdated() { return updated; }
2b8bf452-106d-4121-8473-b3278fbc6833
public void setUpdated(Calendar cal) { updated=cal; }
1871823c-735c-4395-88ce-98c41d530a2f
public long getId() { return id; }
c3306860-75dc-4a30-be5c-9235afa593ed
public long getCustId() { return custId; }
17e37a17-3201-4188-ad38-4aa48f51b008
public void setCustId(long id) { this.custId = id; }
d5155577-f850-4923-899d-0d40b150bcce
public String getComment() { return comment; }
a3f7751f-ce86-4773-b98f-a96a92b7ae79
public void setComment(String val) { comment=val; }
720bfa20-5a2c-4cf4-bcf0-1c6988d9429e
public Calendar getUpdated() { return updated; }
fb028f71-c60c-4f48-906a-e1761eaf40df
public void setUpdated(Calendar cal) { updated=cal; }
0eaea2ee-7539-4cb4-a214-2bbe9b510a67
public List<OrderRow> getRows() { return rows; }
8f18386d-9695-4052-abf2-bd48c4ce77b2
public void setRows(List<OrderRow> items) { rows=items; }
4082b459-1d4a-4c46-a6c5-8178a0bf24aa
public ScopedEntityManager(EntityManager delegate, String emName, long ownerId) { this.delegate = delegate; this.ownerId=ownerId; this.emName=emName; this.tsCreated=System.currentTimeMillis(); }
c5e7b5a6-ca7d-4b95-ad39-b15941f82a1f
@Override public void close() { if (ownerId>0) { //System.out.println(" is managed, do lazyClose"); } else { //System.out.println(" is not managed, do immediateClose"); lazyClose(); } }
a64daabc-e64b-432e-bb30-a864f2826463
protected void lazyClose() { //System.out.println("emLazyClose "+this.ownerId); try { // auto-rollback if TX was started and is still open if (getTransaction().isActive()) getTransaction().rollback(); } catch (Exception ex) { } // nothing we can do, silent fail if (listener != null) { try { listener.lazilyClosed(this); } catch(Exception ex) { } } attributes=null; delegate.close(); }
667c83f2-8559-45a8-88b3-bc96a347a7d9
@Override public void persist(Object object) { delegate.persist(object); }
bc848e9d-5234-4c3a-8a97-8c4f9cc6dc5e
@Override public <T> T merge(T entity) { return delegate.merge(entity); }
8d572b2f-0715-4d94-bc01-95d8ed4cff75
@Override public void remove(Object object) { delegate.remove(object); }
70e66d15-de4f-4b78-b9bf-385012708150
@Override public <T> T find(Class<T> entityClass, Object primaryKey) { return delegate.find(entityClass, primaryKey); }
64003c7b-6cb7-48ad-8f05-e1bd9485d1a6
@Override public <T> T getReference(Class<T> entityClass, Object primaryKey) { return delegate.getReference(entityClass, primaryKey); }
340f4976-142f-42d1-b5d9-4936d465dc05
@Override public void flush() { delegate.flush(); }
c61ff63e-23dc-4a86-8220-49d80ff1ce72
@Override public void setFlushMode(FlushModeType flushModeType) { delegate.setFlushMode(flushModeType); }
2171d98b-38ff-482e-a5f8-2fc0ff40214b
@Override public FlushModeType getFlushMode() { return delegate.getFlushMode(); }
5ce1e578-4565-49c2-86cf-d651699e2424
@Override public void lock(Object object, LockModeType lockModeType) { delegate.lock(object, lockModeType); }
2d737dbc-589d-46cf-b1c8-b43c3ceb1266
@Override public void refresh(Object object) { delegate.refresh(object); }
31d3f630-0c3d-4f40-ae7a-4d12dbd94487
@Override public void clear() { delegate.clear(); }
b5313100-5a06-4281-8e2b-417b36e7fbed
@Override public boolean contains(Object object) { return delegate.contains(object); }
63c99a2a-ba4e-4228-a609-d0c20508622c
@Override public Query createQuery(String string) { return delegate.createQuery(string); }
d12617b4-624f-4054-9cab-aca32ffe829d
@Override public Query createNamedQuery(String string) { return delegate.createNamedQuery(string); }
08a17cf4-3094-4136-96e3-ea58123c5a13
@Override public Query createNativeQuery(String string) { return delegate.createNativeQuery(string); }
ba33d056-1eb3-46ec-a86e-2b875387a756
@Override public Query createNativeQuery(String string, String string0) { return delegate.createNativeQuery(string, string0); }
4e10ced5-5306-481c-8a68-87fab132e7b4
@Override @SuppressWarnings( "rawtypes" ) public Query createNativeQuery(String string, Class aClass) { return delegate.createNativeQuery(string, aClass); }
aff57093-7fc4-4291-a490-a2b147de8fcc
@Override public void joinTransaction() { delegate.joinTransaction(); }
75d33640-8dc8-42a3-bcfc-ebfdc75076db
@Override public EntityTransaction getTransaction() { return delegate.getTransaction(); }
e3f98b62-f559-413c-9027-837a12607c61
@Override public Object getDelegate() { return delegate.getDelegate(); }
70c1d998-5a44-48be-8460-51f59381ca66
@Override public boolean isOpen() { return delegate.isOpen(); }
16783c30-e9a2-4afc-9160-01697ce1c5a7
@Override public <T>T find(Class<T> entityClass, Object primaryKey, Map<String,Object> props) { return delegate.find(entityClass, primaryKey, props); }
3bb5a1d4-4778-4e43-9a25-1bc71d73f002
@Override public <T>T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode) { return delegate.find(entityClass, primaryKey, lockMode); }
a02e66a7-da5a-4167-b67f-cbb703af4cef
@Override public <T>T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String,Object> props) { return delegate.find(entityClass, primaryKey, lockMode, props); }
853733a0-9bab-492a-bb6b-fd2db18349b8
@Override public void lock(Object entity, LockModeType lockMode, Map<String,Object> props) { delegate.lock(entity, lockMode, props); }
0103dbb6-95f7-4425-b59b-2c030cee51a5
@Override public void refresh(Object entity, Map<String,Object> props) { delegate.refresh(entity, props); }
dbeae0d1-eb79-4658-97e3-7dc82562c4ef
@Override public void refresh(Object entity, LockModeType lockMode) { delegate.refresh(entity, lockMode); }
e3ca9d12-65bc-4689-a5f8-85917fb7ecaf
@Override public void refresh(Object entity, LockModeType lockMode, Map<String,Object> props) { delegate.refresh(entity, lockMode, props); }
1fdf934d-2768-4f2d-a71d-5e1a0feac404
@Override public void detach(Object entity) { delegate.detach(entity); }
01b25385-18c8-4fa1-ba98-00f0b07f4de3
@Override public LockModeType getLockMode(Object entity) { return delegate.getLockMode(entity); }
ab19b294-7794-47c8-bdeb-9217fe0ddee8
@Override public void setProperty(String propertyName, Object value) { delegate.setProperty(propertyName, value); }