浏览代码

merged transaction classes

yauhenip 6 年前
父节点
当前提交
1a598701f8

+ 13
- 0
.idea/libraries/Maven__bouncycastle_bcprov_jdk15_136.xml 查看文件

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: bouncycastle:bcprov-jdk15:136">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

+ 13
- 0
.idea/libraries/Maven__org_ow2_util_bundles_bouncycastle_java5_136_1_0_0.xml 查看文件

@@ -0,0 +1,13 @@
1
+<component name="libraryTable">
2
+  <library name="Maven: org.ow2.util.bundles:bouncycastle-java5-136:1.0.0">
3
+    <CLASSES>
4
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0.jar!/" />
5
+    </CLASSES>
6
+    <JAVADOC>
7
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0-javadoc.jar!/" />
8
+    </JAVADOC>
9
+    <SOURCES>
10
+      <root url="jar://$MAVEN_REPOSITORY$/org/ow2/util/bundles/bouncycastle-java5-136/1.0.0/bouncycastle-java5-136-1.0.0-sources.jar!/" />
11
+    </SOURCES>
12
+  </library>
13
+</component>

.idea/libraries/Maven__org_springframework_spring_context_5_0_7_RELEASE 2.xml → .idea/libraries/Maven__org_springframework_spring_context_5_0_7_RELEASE2.xml 查看文件


.idea/libraries/Maven__org_springframework_spring_core_5_0_7_RELEASE 2.xml → .idea/libraries/Maven__org_springframework_spring_core_5_0_7_RELEASE2.xml 查看文件


.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_7_RELEASE 2.xml → .idea/libraries/Maven__org_springframework_spring_jdbc_5_0_7_RELEASE2.xml 查看文件


+ 190
- 167
.idea/workspace.xml 查看文件

@@ -2,107 +2,28 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="0383ce44-5350-49d0-b7c8-5715e7ae7969" name="Default" comment="">
5
-      <change afterPath="$PROJECT_DIR$/.idea/.name" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
8
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__antlr_antlr_2_7_7.xml" afterDir="false" />
9
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml" afterDir="false" />
10
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml" afterDir="false" />
11
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_bluecatcode_guava_guava_19_0_extended_1_1_0.xml" afterDir="false" />
12
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml" afterDir="false" />
13
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml" afterDir="false" />
14
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_6.xml" afterDir="false" />
15
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_6.xml" afterDir="false" />
16
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_6.xml" afterDir="false" />
17
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_6.xml" afterDir="false" />
18
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_6.xml" afterDir="false" />
19
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml" afterDir="false" />
20
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml" afterDir="false" />
21
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_google_guava_guava_19_0.xml" afterDir="false" />
22
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml" afterDir="false" />
23
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml" afterDir="false" />
24
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__com_zaxxer_HikariCP_2_7_9.xml" afterDir="false" />
25
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__commons_codec_commons_codec_1_4.xml" afterDir="false" />
26
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__dom4j_dom4j_1_6_1.xml" afterDir="false" />
27
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml" afterDir="false" />
28
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__javax_transaction_javax_transaction_api_1_2.xml" afterDir="false" />
29
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml" afterDir="false" />
30
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__junit_junit_4_12.xml" afterDir="false" />
31
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_46.xml" afterDir="false" />
32
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_11.xml" afterDir="false" />
33
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_11.xml" afterDir="false" />
34
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml" afterDir="false" />
35
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml" afterDir="false" />
36
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml" afterDir="false" />
37
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml" afterDir="false" />
38
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml" afterDir="false" />
39
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml" afterDir="false" />
40
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml" afterDir="false" />
41
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_13.xml" afterDir="false" />
42
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml" afterDir="false" />
43
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml" afterDir="false" />
44
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml" afterDir="false" />
45
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hibernate_common_hibernate_commons_annotations_5_0_1_Final.xml" afterDir="false" />
46
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hibernate_hibernate_core_5_2_17_Final.xml" afterDir="false" />
47
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hibernate_javax_persistence_hibernate_jpa_2_1_api_1_0_2_Final.xml" afterDir="false" />
48
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_10_Final.xml" afterDir="false" />
49
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_javassist_javassist_3_22_0_GA.xml" afterDir="false" />
50
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_jboss_jandex_2_0_3_Final.xml" afterDir="false" />
51
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml" afterDir="false" />
52
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml" afterDir="false" />
53
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml" afterDir="false" />
54
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml" afterDir="false" />
55
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml" afterDir="false" />
56
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml" afterDir="false" />
57
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml" afterDir="false" />
58
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_3_RELEASE.xml" afterDir="false" />
59
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_3_RELEASE.xml" afterDir="false" />
60
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_3_RELEASE.xml" afterDir="false" />
61
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_0_3_RELEASE.xml" afterDir="false" />
62
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_0_3_RELEASE.xml" afterDir="false" />
63
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_0_3_RELEASE.xml" afterDir="false" />
64
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_3_RELEASE.xml" afterDir="false" />
65
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_3_RELEASE.xml" afterDir="false" />
66
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_3_RELEASE.xml" afterDir="false" />
67
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_3_RELEASE.xml" afterDir="false" />
68
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_3_RELEASE.xml" afterDir="false" />
69
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_3_RELEASE.xml" afterDir="false" />
70
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_3_RELEASE.xml" afterDir="false" />
71
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_8_RELEASE.xml" afterDir="false" />
72
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_0_8_RELEASE.xml" afterDir="false" />
73
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_aop_5_0_7_RELEASE.xml" afterDir="false" />
74
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_aspects_5_0_7_RELEASE.xml" afterDir="false" />
75
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_beans_5_0_7_RELEASE.xml" afterDir="false" />
76
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_context_5_0_7_RELEASE.xml" afterDir="false" />
77
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_core_5_0_7_RELEASE.xml" afterDir="false" />
78
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_expression_5_0_7_RELEASE.xml" afterDir="false" />
79
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_jcl_5_0_7_RELEASE.xml" afterDir="false" />
80
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_jdbc_5_0_7_RELEASE.xml" afterDir="false" />
81
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_orm_5_0_7_RELEASE.xml" afterDir="false" />
82
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_test_5_0_7_RELEASE.xml" afterDir="false" />
83
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_tx_5_0_7_RELEASE.xml" afterDir="false" />
84
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_web_5_0_7_RELEASE.xml" afterDir="false" />
85
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_7_RELEASE.xml" afterDir="false" />
86
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml" afterDir="false" />
87
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml" afterDir="false" />
88
-      <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
89
-      <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
90
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
5
+      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__bouncycastle_bcprov_jdk15_136.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_ow2_util_bundles_bouncycastle_java5_136_1_0_0.xml" afterDir="false" />
7
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java" afterDir="false" />
8
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java" afterDir="false" />
9
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java" afterDir="false" />
10
+      <change afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Transaction.class" afterDir="false" />
11
+      <change afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/TransactionInput.class" afterDir="false" />
12
+      <change afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/TransactionOutput.class" afterDir="false" />
91 13
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
92
-      <change beforePath="$PROJECT_DIR$/application.log" beforeDir="false" afterPath="$PROJECT_DIR$/application.log" afterDir="false" />
93
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/ProcessLoader.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/ProcessLoader.java" afterDir="false" />
94
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/CoinRepository.java" beforeDir="false" />
14
+      <change beforePath="$PROJECT_DIR$/0.1.iml" beforeDir="false" afterPath="$PROJECT_DIR$/0.1.iml" afterDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
95 16
       <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" afterDir="false" />
96
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Coin.java" beforeDir="false" />
17
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java" afterDir="false" />
97 18
       <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java" afterDir="false" />
98
-      <change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
99
-      <change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" />
19
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java" afterDir="false" />
100 20
       <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/ProcessLoader.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/ProcessLoader.class" afterDir="false" />
101
-      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/Repositories/CoinRepository.class" beforeDir="false" />
102 21
       <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Block.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Block.class" afterDir="false" />
103
-      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Coin.class" beforeDir="false" />
22
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Blockchain.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Blockchain.class" afterDir="false" />
104 23
       <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Wallet.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/model/Wallet.class" afterDir="false" />
24
+      <change beforePath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/Encryption.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/buecoin01/utility/Encryption.class" afterDir="false" />
105 25
     </list>
26
+    <ignored path="$PROJECT_DIR$/target/" />
106 27
     <option name="TRACKING_ENABLED" value="true" />
107 28
     <option name="SHOW_DIALOG" value="false" />
108 29
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -111,41 +32,55 @@
111 32
   </component>
112 33
   <component name="FileEditorManager">
113 34
     <leaf>
114
-      <file leaf-file-name="Application.java" pinned="false" current-in-tab="true">
115
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java">
35
+      <file leaf-file-name="Wallet.java" pinned="false" current-in-tab="false">
36
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java">
116 37
           <provider selected="true" editor-type-id="text-editor">
117
-            <state relative-caret-position="75">
118
-              <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
38
+            <state relative-caret-position="870">
39
+              <caret line="133" column="30" selection-start-line="133" selection-start-column="30" selection-end-line="133" selection-end-column="30" />
119 40
             </state>
120 41
           </provider>
121 42
         </entry>
122 43
       </file>
123
-      <file leaf-file-name="application.properties" pinned="false" current-in-tab="false">
124
-        <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
44
+      <file leaf-file-name="Encryption.java" pinned="false" current-in-tab="false">
45
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java">
125 46
           <provider selected="true" editor-type-id="text-editor">
126
-            <state relative-caret-position="150">
127
-              <caret line="10" column="31" selection-start-line="10" selection-start-column="31" selection-end-line="10" selection-end-column="31" />
47
+            <state relative-caret-position="-26">
48
+              <caret line="18" column="49" selection-start-line="18" selection-start-column="49" selection-end-line="18" selection-end-column="49" />
49
+              <folding>
50
+                <element signature="imports" expanded="true" />
51
+                <element signature="e#1724#1725#0" expanded="true" />
52
+              </folding>
53
+            </state>
54
+          </provider>
55
+        </entry>
56
+      </file>
57
+      <file leaf-file-name="Block.java" pinned="false" current-in-tab="true">
58
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
59
+          <provider selected="true" editor-type-id="text-editor">
60
+            <state relative-caret-position="1200">
61
+              <caret line="94" column="5" lean-forward="true" selection-start-line="94" selection-start-column="5" selection-end-line="94" selection-end-column="5" />
128 62
             </state>
129 63
           </provider>
130 64
         </entry>
131 65
       </file>
132
-      <file leaf-file-name="ProcessLoader.java" pinned="false" current-in-tab="false">
133
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/ProcessLoader.java">
66
+      <file leaf-file-name="Blockchain.java" pinned="false" current-in-tab="false">
67
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java">
134 68
           <provider selected="true" editor-type-id="text-editor">
135
-            <state relative-caret-position="293">
136
-              <caret line="26" column="71" selection-start-line="26" selection-start-column="71" selection-end-line="26" selection-end-column="71" />
69
+            <state relative-caret-position="347">
70
+              <caret line="34" selection-start-line="34" selection-end-line="34" />
137 71
               <folding>
138 72
                 <element signature="imports" expanded="true" />
73
+                <element signature="e#1854#1855#0" expanded="true" />
139 74
               </folding>
140 75
             </state>
141 76
           </provider>
142 77
         </entry>
143 78
       </file>
144
-      <file leaf-file-name="Block.java" pinned="false" current-in-tab="false">
145
-        <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
79
+      <file leaf-file-name="pom.xml" pinned="false" current-in-tab="false">
80
+        <entry file="file://$PROJECT_DIR$/pom.xml">
146 81
           <provider selected="true" editor-type-id="text-editor">
147
-            <state relative-caret-position="1046">
148
-              <caret line="78" selection-start-line="78" selection-end-line="78" />
82
+            <state relative-caret-position="990">
83
+              <caret line="66" column="19" selection-start-line="66" selection-start-column="19" selection-end-line="66" selection-end-column="19" />
149 84
             </state>
150 85
           </provider>
151 86
         </entry>
@@ -155,6 +90,14 @@
155 90
   <component name="Git.Settings">
156 91
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
157 92
   </component>
93
+  <component name="IdeDocumentHistory">
94
+    <option name="CHANGED_PATHS">
95
+      <list>
96
+        <option value="$PROJECT_DIR$/.idea/workspace.xml" />
97
+        <option value="$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java" />
98
+      </list>
99
+    </option>
100
+  </component>
158 101
   <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
159 102
   <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
160 103
   <component name="JsGulpfileManager">
@@ -170,7 +113,6 @@
170 113
       <foldersAlwaysOnTop value="true" />
171 114
     </navigator>
172 115
     <panes>
173
-      <pane id="AndroidView" />
174 116
       <pane id="ProjectPane">
175 117
         <subPane>
176 118
           <expand>
@@ -232,43 +174,19 @@
232 174
               <item name="CryptoCoin" type="462c0819:PsiDirectoryNode" />
233 175
               <item name="src" type="462c0819:PsiDirectoryNode" />
234 176
               <item name="main" type="462c0819:PsiDirectoryNode" />
235
-              <item name="resources" type="462c0819:PsiDirectoryNode" />
236
-            </path>
237
-            <path>
238
-              <item name="0.1" type="b2602c69:ProjectViewProjectNode" />
239
-              <item name="CryptoCoin" type="462c0819:PsiDirectoryNode" />
240
-              <item name="src" type="462c0819:PsiDirectoryNode" />
241
-              <item name="test" type="462c0819:PsiDirectoryNode" />
242
-            </path>
243
-            <path>
244
-              <item name="0.1" type="b2602c69:ProjectViewProjectNode" />
245
-              <item name="CryptoCoin" type="462c0819:PsiDirectoryNode" />
246
-              <item name="src" type="462c0819:PsiDirectoryNode" />
247
-              <item name="test" type="462c0819:PsiDirectoryNode" />
248
-              <item name="java" type="462c0819:PsiDirectoryNode" />
249
-            </path>
250
-            <path>
251
-              <item name="0.1" type="b2602c69:ProjectViewProjectNode" />
252
-              <item name="CryptoCoin" type="462c0819:PsiDirectoryNode" />
253
-              <item name="src" type="462c0819:PsiDirectoryNode" />
254
-              <item name="test" type="462c0819:PsiDirectoryNode" />
255 177
               <item name="java" type="462c0819:PsiDirectoryNode" />
256 178
               <item name="buecoin01" type="462c0819:PsiDirectoryNode" />
179
+              <item name="utility" type="462c0819:PsiDirectoryNode" />
257 180
             </path>
258 181
           </expand>
259 182
           <select />
260 183
         </subPane>
261 184
       </pane>
262
-      <pane id="PackagesPane" />
263 185
       <pane id="Scope" />
186
+      <pane id="AndroidView" />
187
+      <pane id="PackagesPane" />
264 188
     </panes>
265 189
   </component>
266
-  <component name="PropertiesComponent">
267
-    <property name="RequestMappingsPanelOrder0" value="0" />
268
-    <property name="RequestMappingsPanelOrder1" value="1" />
269
-    <property name="RequestMappingsPanelWidth0" value="75" />
270
-    <property name="RequestMappingsPanelWidth1" value="75" />
271
-  </component>
272 190
   <component name="RunDashboard">
273 191
     <option name="ruleStates">
274 192
       <list>
@@ -363,11 +281,10 @@
363 281
     <servers />
364 282
   </component>
365 283
   <component name="TimeTrackingManager">
366
-    <option name="totallyTimeSpent" value="27000" />
284
+    <option name="totallyTimeSpent" value="220000" />
367 285
   </component>
368 286
   <component name="ToolWindowManager">
369
-    <frame x="0" y="0" width="1280" height="800" extended-state="0" />
370
-    <editor active="true" />
287
+    <frame x="0" y="23" width="1440" height="812" extended-state="6" />
371 288
     <layout>
372 289
       <window_info anchor="right" id="Palette" />
373 290
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
@@ -381,23 +298,23 @@
381 298
       <window_info id="UI Designer" />
382 299
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
383 300
       <window_info anchor="bottom" id="TODO" order="6" />
384
-      <window_info anchor="bottom" id="Messages" weight="0.32905984" />
301
+      <window_info anchor="bottom" id="Messages" />
385 302
       <window_info anchor="right" id="Palette&#9;" />
386 303
       <window_info id="Image Layers" />
387 304
       <window_info anchor="bottom" id="Java Enterprise" />
388 305
       <window_info anchor="right" id="Capture Analysis" />
306
+      <window_info anchor="bottom" id="Run" order="2" weight="0.37062937" />
389 307
       <window_info anchor="bottom" id="Version Control" />
390
-      <window_info anchor="bottom" id="Run" order="2" weight="0.32905984" />
391
-      <window_info anchor="bottom" id="Terminal" />
392
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24959612" />
308
+      <window_info anchor="bottom" id="Spring" />
309
+      <window_info anchor="bottom" id="Terminal" visible="true" weight="0.32867134" />
310
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
311
+      <window_info anchor="right" id="Bean Validation" />
393 312
       <window_info id="Web" side_tool="true" />
394 313
       <window_info anchor="right" id="Theme Preview" />
395 314
       <window_info id="Favorites" side_tool="true" />
396
-      <window_info anchor="right" id="Bean Validation" />
397 315
       <window_info anchor="bottom" id="Find" order="1" />
398 316
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
399 317
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
400
-      <window_info anchor="bottom" id="Spring" />
401 318
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
402 319
       <window_info anchor="bottom" id="Message" order="0" />
403 320
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
@@ -407,36 +324,137 @@
407 324
     <option name="myLimit" value="2678400000" />
408 325
   </component>
409 326
   <component name="editorHistoryManager">
327
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/ProcessLoader.java">
328
+      <provider selected="true" editor-type-id="text-editor">
329
+        <state relative-caret-position="345">
330
+          <caret line="31" column="11" lean-forward="true" selection-start-line="31" selection-start-column="11" selection-end-line="31" selection-end-column="11" />
331
+        </state>
332
+      </provider>
333
+    </entry>
334
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Coin.java">
335
+      <provider selected="true" editor-type-id="text-editor">
336
+        <state relative-caret-position="75">
337
+          <caret line="5" column="19" lean-forward="true" selection-start-line="5" selection-start-column="19" selection-end-line="5" selection-end-column="19" />
338
+        </state>
339
+      </provider>
340
+    </entry>
341
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/CoinRepository.java">
342
+      <provider selected="true" editor-type-id="text-editor">
343
+        <state relative-caret-position="105">
344
+          <caret line="10" column="17" selection-start-line="10" selection-start-column="17" selection-end-line="10" selection-end-column="17" />
345
+        </state>
346
+      </provider>
347
+    </entry>
348
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
349
+      <provider selected="true" editor-type-id="text-editor">
350
+        <state relative-caret-position="567">
351
+          <caret line="50" selection-start-line="50" selection-end-line="50" />
352
+        </state>
353
+      </provider>
354
+    </entry>
410 355
     <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java">
411 356
       <provider selected="true" editor-type-id="text-editor">
412
-        <state relative-caret-position="360">
413
-          <caret line="24" column="29" selection-start-line="24" selection-start-column="29" selection-end-line="24" selection-end-column="29" />
357
+        <state relative-caret-position="1695">
358
+          <caret line="123" column="30" selection-start-line="123" selection-start-column="30" selection-end-line="123" selection-end-column="30" />
359
+        </state>
360
+      </provider>
361
+    </entry>
362
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Transaction.java">
363
+      <provider selected="true" editor-type-id="text-editor">
364
+        <state relative-caret-position="318">
365
+          <caret line="117" column="26" selection-start-line="117" selection-start-column="26" selection-end-line="117" selection-end-column="26" />
414 366
           <folding>
415
-            <element signature="e#581#582#0" expanded="true" />
416
-            <element signature="e#621#622#0" expanded="true" />
417
-            <element signature="e#653#654#0" expanded="true" />
367
+            <element signature="imports" expanded="true" />
418 368
           </folding>
419 369
         </state>
420 370
       </provider>
421 371
     </entry>
422
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/CoinRepository.java">
372
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionInput.java">
423 373
       <provider selected="true" editor-type-id="text-editor">
424
-        <state relative-caret-position="45">
425
-          <caret line="3" column="26" selection-start-line="3" selection-start-column="26" selection-end-line="3" selection-end-column="26" />
374
+        <state relative-caret-position="120">
375
+          <caret line="8" column="10" selection-start-line="8" selection-start-column="10" selection-end-line="8" selection-end-column="10" />
376
+          <folding>
377
+            <element signature="e#237#238#0" expanded="true" />
378
+            <element signature="e#299#300#0" expanded="true" />
379
+            <element signature="e#556#557#0" expanded="true" />
380
+            <element signature="e#598#599#0" expanded="true" />
381
+            <element signature="e#668#669#0" expanded="true" />
382
+            <element signature="e#730#731#0" expanded="true" />
383
+            <element signature="e#772#773#0" expanded="true" />
384
+            <element signature="e#799#800#0" expanded="true" />
385
+            <element signature="e#850#851#0" expanded="true" />
386
+            <element signature="e#882#883#0" expanded="true" />
387
+          </folding>
426 388
         </state>
427 389
       </provider>
428 390
     </entry>
429
-    <entry file="file://$PROJECT_DIR$/src/test/java/com/buecoin01/ApplicationTests.java">
391
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/TransactionOutput.java">
430 392
       <provider selected="true" editor-type-id="text-editor">
431
-        <state relative-caret-position="90">
432
-          <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
393
+        <state relative-caret-position="314">
394
+          <caret line="25" column="38" selection-start-line="25" selection-start-column="38" selection-end-line="25" selection-end-column="38" />
395
+          <folding>
396
+            <element signature="e#651#652#0" expanded="true" />
397
+            <element signature="e#676#677#0" expanded="true" />
398
+            <element signature="e#712#713#0" expanded="true" />
399
+            <element signature="e#740#741#0" expanded="true" />
400
+            <element signature="e#813#814#0" expanded="true" />
401
+            <element signature="e#868#869#0" expanded="true" />
402
+            <element signature="e#912#913#0" expanded="true" />
403
+            <element signature="e#943#944#0" expanded="true" />
404
+            <element signature="e#971#972#0" expanded="true" />
405
+            <element signature="e#1012#1013#0" expanded="true" />
406
+            <element signature="e#1046#1047#0" expanded="true" />
407
+            <element signature="e#1092#1093#0" expanded="true" />
408
+            <element signature="e#1134#1135#0" expanded="true" />
409
+            <element signature="e#1204#1205#0" expanded="true" />
410
+            <element signature="e#1266#1267#0" expanded="true" />
411
+            <element signature="e#717#718#0" expanded="true" />
412
+            <element signature="e#762#763#0" expanded="true" />
413
+          </folding>
433 414
         </state>
434 415
       </provider>
435 416
     </entry>
436
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
417
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/utility/Encryption.java">
437 418
       <provider selected="true" editor-type-id="text-editor">
438
-        <state relative-caret-position="1046">
439
-          <caret line="78" selection-start-line="78" selection-end-line="78" />
419
+        <state relative-caret-position="-26">
420
+          <caret line="18" column="49" selection-start-line="18" selection-start-column="49" selection-end-line="18" selection-end-column="49" />
421
+          <folding>
422
+            <element signature="imports" expanded="true" />
423
+            <element signature="e#1724#1725#0" expanded="true" />
424
+          </folding>
425
+        </state>
426
+      </provider>
427
+    </entry>
428
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Blockchain.java">
429
+      <provider selected="true" editor-type-id="text-editor">
430
+        <state relative-caret-position="347">
431
+          <caret line="34" selection-start-line="34" selection-end-line="34" />
432
+          <folding>
433
+            <element signature="imports" expanded="true" />
434
+            <element signature="e#1854#1855#0" expanded="true" />
435
+          </folding>
436
+        </state>
437
+      </provider>
438
+    </entry>
439
+    <entry file="file://$PROJECT_DIR$/pom.xml">
440
+      <provider selected="true" editor-type-id="text-editor">
441
+        <state relative-caret-position="990">
442
+          <caret line="66" column="19" selection-start-line="66" selection-start-column="19" selection-end-line="66" selection-end-column="19" />
443
+        </state>
444
+      </provider>
445
+    </entry>
446
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Wallet.java">
447
+      <provider selected="true" editor-type-id="text-editor">
448
+        <state relative-caret-position="870">
449
+          <caret line="133" column="30" selection-start-line="133" selection-start-column="30" selection-end-line="133" selection-end-column="30" />
450
+        </state>
451
+      </provider>
452
+    </entry>
453
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Repositories/CoinRepository.java" />
454
+    <entry file="file://$PROJECT_DIR$/src/test/java/com/buecoin01/ApplicationTests.java">
455
+      <provider selected="true" editor-type-id="text-editor">
456
+        <state relative-caret-position="90">
457
+          <caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
440 458
         </state>
441 459
       </provider>
442 460
     </entry>
@@ -457,20 +475,25 @@
457 475
         </state>
458 476
       </provider>
459 477
     </entry>
460
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Coin.java">
478
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Coin.java" />
479
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java">
461 480
       <provider selected="true" editor-type-id="text-editor">
462 481
         <state relative-caret-position="75">
463
-          <caret line="5" column="13" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
482
+          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
464 483
         </state>
465 484
       </provider>
466 485
     </entry>
467 486
     <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
468
-      <provider selected="true" editor-type-id="text-editor" />
487
+      <provider selected="true" editor-type-id="text-editor">
488
+        <state relative-caret-position="3616">
489
+          <caret line="752" column="7" selection-start-line="752" selection-start-column="7" selection-end-line="752" selection-end-column="7" />
490
+        </state>
491
+      </provider>
469 492
     </entry>
470
-    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/Application.java">
493
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/buecoin01/model/Block.java">
471 494
       <provider selected="true" editor-type-id="text-editor">
472
-        <state relative-caret-position="75">
473
-          <caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
495
+        <state relative-caret-position="1200">
496
+          <caret line="94" column="5" lean-forward="true" selection-start-line="94" selection-start-column="5" selection-end-line="94" selection-end-column="5" />
474 497
         </state>
475 498
       </provider>
476 499
     </entry>

+ 2
- 0
0.1.iml 查看文件

@@ -105,5 +105,7 @@
105 105
     <orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.7.RELEASE" level="project" />
106 106
     <orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.0.7.RELEASE" level="project" />
107 107
     <orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.5.1" level="project" />
108
+    <orderEntry type="library" name="Maven: org.ow2.util.bundles:bouncycastle-java5-136:1.0.0" level="project" />
109
+    <orderEntry type="library" name="Maven: bouncycastle:bcprov-jdk15:136" level="project" />
108 110
   </component>
109 111
 </module>

+ 5
- 0
pom.xml 查看文件

@@ -59,6 +59,11 @@
59 59
 			<artifactId>spring-boot-starter-test</artifactId>
60 60
 			<scope>test</scope>
61 61
 		</dependency>
62
+        <dependency>
63
+            <groupId>org.ow2.util.bundles</groupId>
64
+            <artifactId>bouncycastle-java5-136</artifactId>
65
+            <version>1.0.0</version>
66
+        </dependency>
62 67
 	</dependencies>
63 68
 
64 69
 	<build>

+ 24
- 8
src/main/java/com/buecoin01/model/Block.java 查看文件

@@ -5,6 +5,7 @@ import com.buecoin01.utility.Encryption;
5 5
 
6 6
 import javax.persistence.*;
7 7
 import java.time.LocalDateTime;
8
+import java.util.ArrayList;
8 9
 
9 10
 
10 11
 @Entity
@@ -20,7 +21,9 @@ public class Block {
20 21
     @Column
21 22
     private String hash;
22 23
     private String previousHash;
23
-    private String data;
24
+    //private String data;
25
+    public String merkleRoot;
26
+    public ArrayList<Transaction> transactions = new ArrayList<>();
24 27
     private LocalDateTime timeStamp;
25 28
     private int nonce;
26 29
 
@@ -29,8 +32,8 @@ public class Block {
29 32
 
30 33
     public Block(String previousHash, LocalDateTime time, int nonce) {
31 34
         this.timeStamp = time;
32
-        this.hash = previousHash;
33
-        this.nonce = nonce;
35
+        this.previousHash = previousHash;
36
+        this.hash = calculateHash();
34 37
     }
35 38
 
36 39
     public String getHash() {
@@ -41,9 +44,9 @@ public class Block {
41 44
         return previousHash;
42 45
     }
43 46
 
44
-    public String getData() {
45
-        return data;
46
-    }
47
+//    public String getData() {
48
+//        return data;
49
+//    }
47 50
 
48 51
     public LocalDateTime getTimeStamp() {
49 52
         return timeStamp;
@@ -54,7 +57,7 @@ public class Block {
54 57
                   previousHash +
55 58
                         timeStamp.toString() +
56 59
                         Integer.toString(nonce) +
57
-                        data);
60
+                        merkleRoot);
58 61
     }
59 62
 
60 63
     public long getId() {
@@ -76,5 +79,18 @@ public class Block {
76 79
         System.out.println("You have been awarded 1 Zip!");
77 80
     }
78 81
 
79
-
82
+    //add transactions to this block
83
+    public boolean addTransaction(Transaction transaction){
84
+        //process transaction and check if valid, unless block is genesis block then ignore
85
+        if (transaction == null) return false;
86
+        if (previousHash != "0"){
87
+            if (!(transaction.processTransaction())){
88
+                System.out.println("Transaction failed to process. Discarded.");
89
+                return false;
90
+            }
91
+        }
92
+        transactions.add(transaction);
93
+        System.out.println("Transaction Successfully added to the Block!");
94
+        return true;
95
+    }
80 96
 }

+ 38
- 2
src/main/java/com/buecoin01/model/Blockchain.java 查看文件

@@ -2,14 +2,42 @@ package com.buecoin01.model;
2 2
 
3 3
 import com.buecoin01.model.Block;
4 4
 import com.buecoin01.utility.Encryption;
5
+import com.buecoin01.utility.TransactionOutput;
5 6
 import com.google.gson.GsonBuilder;
6 7
 
7
-import java.util.ArrayList;
8
-import java.util.List;
8
+import java.security.Security;
9
+import java.util.*;
9 10
 
10 11
 public class Blockchain {
11 12
     private static List<Block> blockchain = new ArrayList<>();
13
+    private static Map<String, TransactionOutput> UTXOs = new HashMap<>();
14
+    public static float minimumTransaction = 0.1f;
12 15
     private static int difficulty = 5;
16
+    public static Wallet walletA;
17
+    public static Wallet walletB;
18
+    //public static Transaction genesisTransaction;
19
+
20
+    public static void main(String[] args) {
21
+        //Setup Bouncey castle as a Security Provider
22
+        Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
23
+
24
+        //Create the new wallets
25
+        walletA = new Wallet();
26
+        walletB = new Wallet();
27
+
28
+        //Test public and private keys
29
+        System.out.println("Private and public keys:");
30
+        System.out.println(Encryption.getStringFromKey(walletA.getPrivateKey()));
31
+        System.out.println(Encryption.getStringFromKey(walletA.getPublicKey()));
32
+        //Create a test transaction from WalletA to walletB
33
+        Transaction transaction = new Transaction(walletA.getPublicKey(), walletB.getPublicKey(), 5, null);
34
+        transaction.generateSignature(walletA.getPrivateKey());
35
+
36
+        //Verify the signature works and verify it from the public key
37
+        System.out.println("Is signature verified");
38
+        System.out.println(transaction.verifySignature());
39
+
40
+    }
13 41
 
14 42
     public String chainToJson() {
15 43
         return new GsonBuilder()
@@ -18,6 +46,14 @@ public class Blockchain {
18 46
                 .toJson(blockchain);
19 47
     }
20 48
 
49
+    public static Map<String, TransactionOutput> getUTXOs() {
50
+        return UTXOs;
51
+    }
52
+
53
+    public static void setUTXOs(Map<String, TransactionOutput> UTXOs) {
54
+        Blockchain.UTXOs = UTXOs;
55
+    }
56
+
21 57
     public static List<Block> getBlockchain() {
22 58
         return blockchain;
23 59
     }

+ 120
- 0
src/main/java/com/buecoin01/model/Transaction.java 查看文件

@@ -0,0 +1,120 @@
1
+package com.buecoin01.model;
2
+
3
+import com.buecoin01.utility.Encryption;
4
+import com.buecoin01.utility.TransactionInput;
5
+import com.buecoin01.utility.TransactionOutput;
6
+
7
+import java.security.PrivateKey;
8
+import java.security.PublicKey;
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+public class Transaction {
13
+    private String transactionId; //hash of the transaction
14
+    private PublicKey sender;
15
+    private PublicKey reciepient;
16
+    private String senderName;
17
+    private String reciepientName;
18
+    private float value;
19
+    private byte[] signature;
20
+
21
+    private List<TransactionInput> inputs = new ArrayList<>();
22
+    private List<TransactionOutput> outputs = new ArrayList<>();
23
+
24
+    private static int sequence = 0; //how many transactions have been generated
25
+
26
+    public Transaction(PublicKey from, PublicKey to, float value, ArrayList<TransactionInput> inputs) {
27
+        this.sender = from;
28
+        this.reciepient = to;
29
+        this.value = value;
30
+        this.inputs = inputs;
31
+    }
32
+
33
+    //generating transactionId
34
+    private String calculateHash() {
35
+        sequence++; //increasing tho avoid identical hash codes
36
+        return Encryption.applySha256(
37
+                Encryption.getStringFromKey(sender) +
38
+                       Encryption.getStringFromKey(reciepient) +
39
+                       Float.toString(value) + sequence
40
+                       );
41
+    }
42
+
43
+    //Sign all the data that should not be tempered
44
+    public void generateSignature(PrivateKey privateKey) {
45
+        String data = Encryption.getStringFromKey(sender) + Encryption.getStringFromKey(reciepient) + Float.toString(value);
46
+        signature = Encryption.applyECDSASig(privateKey, data);
47
+    }
48
+
49
+    //Verify the data we signed hasn't been tampered with
50
+    public boolean verifySignature() {
51
+        String data = Encryption.getStringFromKey(sender) + Encryption.getStringFromKey(reciepient) + Float.toString(value);
52
+        return Encryption.verifyECDSASig(sender, data, signature);
53
+    }
54
+
55
+    //Check if transaction can be created
56
+    public boolean processTransaction() {
57
+        if (!verifySignature()) {
58
+            System.out.println("Transaction Signature failed to verify");
59
+            return false;
60
+        }
61
+
62
+        //gather transaction inputs to make sure they're unspent
63
+        for (TransactionInput i : inputs) {
64
+           i.setUTXO(Blockchain.getUTXOs().get(i.getTransactionOutputId()));
65
+
66
+        }
67
+        //check if transaction is valid
68
+        if(getInputsValue()< Blockchain.minimumTransaction){
69
+            System.out.println("Transaction Input to small: " + getInputsValue());
70
+            return false;
71
+        }
72
+        //add outputs to Unspent list
73
+        for (TransactionOutput o : outputs){
74
+            Blockchain.getUTXOs().put(o.getId(),o);
75
+        }
76
+        //remove transaction inputs from UXTO lists as spent
77
+        for(TransactionInput i :inputs){
78
+            if(i.getUTXO() == null) continue; // if Transaction cant be found, skip
79
+            Blockchain.getUTXOs().remove(i.getUTXO().getId());
80
+        }
81
+        return true;
82
+    }
83
+
84
+        // returns sum of inputs(UXTOs) values
85
+    public float getInputsValue(){
86
+        float total = 0;
87
+        for(TransactionInput i : inputs){
88
+            if(i.getUTXO() == null) continue; // if Transaction cant be found, skip
89
+            total= total + i.getUTXO().getValue();
90
+        }
91
+        return total;
92
+    }
93
+
94
+    public float getOutPutsValue(){
95
+        float total = 0;
96
+        for(TransactionOutput o : outputs){
97
+            total = total + o.getValue();
98
+        }
99
+        return total;
100
+    }
101
+    // tacks in array of transactions and returns a merkle root
102
+    public static  String getMerkleRoot(ArrayList<Transaction> transactions){
103
+        int count = transactions.size();
104
+        ArrayList<String> previousTreeLayer = new ArrayList<>();
105
+        for(Transaction transaction: transactions){
106
+            previousTreeLayer.add(transaction.transactionId);
107
+        }
108
+        ArrayList<String> treeLayer = previousTreeLayer;
109
+        while(count > 1){
110
+            treeLayer = new ArrayList<>();
111
+            for(int i = 1; i < previousTreeLayer.size();i++){
112
+             treeLayer.add(Encryption.applySha256(previousTreeLayer.get(i-1)) + previousTreeLayer.get(i));
113
+            }
114
+            count = treeLayer.size();
115
+            previousTreeLayer = treeLayer;
116
+        }
117
+        String merkleRoot = (treeLayer.size() == 1) ? treeLayer.get(0) : "";
118
+        return merkleRoot;
119
+    }
120
+}

+ 75
- 0
src/main/java/com/buecoin01/model/Wallet.java 查看文件

@@ -1,9 +1,21 @@
1 1
 package com.buecoin01.model;
2 2
 
3
+import com.buecoin01.utility.TransactionInput;
4
+import com.buecoin01.utility.TransactionOutput;
5
+
3 6
 import javax.persistence.*;
7
+import java.security.*;
8
+import java.security.spec.ECGenParameterSpec;
9
+import java.util.ArrayList;
10
+import java.util.HashMap;
11
+import java.util.Map;
4 12
 
5 13
 @Entity
6 14
 public class Wallet {
15
+
16
+    private PrivateKey privateKey;
17
+    private PublicKey publicKey;
18
+    public HashMap<String, TransactionOutput> UTXOs = new HashMap<>(); // only UTXOs owned by this wallet
7 19
     @Id
8 20
     @Column(name = "id")
9 21
     @GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -31,8 +43,17 @@ public class Wallet {
31 43
     }
32 44
 
33 45
     public Wallet() {
46
+        generateKeyPair();
47
+    }
48
+
49
+    public PrivateKey getPrivateKey() {
50
+        return privateKey;
51
+    }
34 52
 
53
+    public PublicKey getPublicKey() {
54
+        return publicKey;
35 55
     }
56
+
36 57
     public long getAmount() {
37 58
         return amount;
38 59
     }
@@ -58,4 +79,58 @@ public class Wallet {
58 79
     public void setId(long id) {
59 80
         this.id = id;
60 81
     }
82
+
83
+    public void generateKeyPair() {
84
+        try {
85
+            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA","BC");
86
+            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
87
+            ECGenParameterSpec ecSpec = new ECGenParameterSpec("prime192v1");
88
+
89
+            keyGen.initialize(ecSpec, random);
90
+            KeyPair keyPair = keyGen.generateKeyPair();
91
+            privateKey = keyPair.getPrivate();
92
+            publicKey = keyPair.getPublic();
93
+        } catch(Exception e) {
94
+            throw new RuntimeException(e);
95
+        }
96
+    }
97
+    //returns balance and store the UTXO's owned by this wallet in this.UXTOs
98
+    public float getBalance(){
99
+        float total = 0;
100
+        for (Map.Entry<String, TransactionOutput> item: Blockchain.getUTXOs().entrySet()){
101
+            TransactionOutput UTXO = item.getValue();
102
+            if (UTXO.isMine(publicKey)){ //if output belongs to me (if coins belong to me)
103
+                UTXOs.put(UTXO.getId(), UTXO);   // add it to our list of unspent transaction
104
+                total = total + UTXO.getValue();
105
+
106
+            }
107
+        }
108
+        return total;
109
+    }
110
+
111
+    //generates and returns a new transaction from this wallet
112
+
113
+
114
+    public Transaction sendFunds(PublicKey _recipient, float value){
115
+        if(getBalance() < value) {  //gather balance and check funds
116
+            System.out.println("Not Enough Funds. Transaction Discarded.");
117
+            return null;
118
+       }
119
+
120
+       // create arraylist of inputs
121
+        ArrayList<TransactionInput> inputs = new ArrayList<>();
122
+        float total = 0;
123
+        for(Map.Entry<String, TransactionOutput> item: UTXOs.entrySet()){
124
+            TransactionOutput UTXO = item.getValue();
125
+            total= total + UTXO.getValue();
126
+            inputs.add(new TransactionInput(UTXO.getId()));
127
+            if (total > value) break;
128
+        }
129
+        Transaction newTransaction = new Transaction(publicKey, _recipient,value, inputs);
130
+        newTransaction.generateSignature(privateKey);
131
+        for (TransactionInput input : inputs){
132
+            UTXOs.remove(input.getTransactionOutputId());
133
+        }
134
+        return newTransaction;
135
+    }
61 136
 }

+ 38
- 0
src/main/java/com/buecoin01/utility/Encryption.java 查看文件

@@ -3,6 +3,11 @@ package com.buecoin01.utility;
3 3
 import com.google.common.hash.Hashing;
4 4
 
5 5
 import java.nio.charset.StandardCharsets;
6
+import java.security.Key;
7
+import java.security.PrivateKey;
8
+import java.security.PublicKey;
9
+import java.security.Signature;
10
+import java.util.Base64;
6 11
 
7 12
 public class Encryption {
8 13
     public static String applySha256(String input) {
@@ -14,4 +19,37 @@ public class Encryption {
14 19
     public static String createTarget(int difficulty) {
15 20
         return new String(new char[difficulty]).replace('\0', '0');
16 21
     }
22
+
23
+    //Apply ECDSA Signature and return result as bytes
24
+    public static byte[] applyECDSASig(PrivateKey privateKey, String input) {
25
+        Signature dsa;
26
+        byte[] realSig;
27
+        try {
28
+            dsa = Signature.getInstance("ECDSA","BC");
29
+            dsa.initSign(privateKey);
30
+            byte[] strByte = input.getBytes();
31
+            dsa.update(strByte);
32
+            realSig = dsa.sign();
33
+        } catch (Exception e) {
34
+            throw new RuntimeException(e);
35
+        }
36
+        return realSig;
37
+    }
38
+
39
+    //Verify a String Signature
40
+    public static boolean verifyECDSASig(PublicKey publicKey, String data, byte[] signature) {
41
+        try {
42
+            Signature ecdsaVerify = Signature.getInstance("ECDSA", "BC");
43
+            ecdsaVerify.initVerify(publicKey);
44
+            ecdsaVerify.update(data.getBytes());
45
+            return  ecdsaVerify.verify(signature);
46
+        } catch (Exception e) {
47
+            throw new RuntimeException(e);
48
+        }
49
+    }
50
+
51
+    //Return encoded string from a key
52
+    public static String getStringFromKey(Key key) {
53
+        return Base64.getEncoder().encodeToString(key.getEncoded());
54
+    }
17 55
 }

+ 30
- 0
src/main/java/com/buecoin01/utility/TransactionInput.java 查看文件

@@ -0,0 +1,30 @@
1
+package com.buecoin01.utility;
2
+
3
+
4
+//This class will be used to reference TransactionOutputs that have not yet been spent.
5
+//The transactionOutputId will be used to find the relevant TransactionOutput, allowing miners to check your ownership.
6
+public class TransactionInput {
7
+    private String transactionOutputId;
8
+   // private TransactionOutput UTXO; // UTXO means Unspent Transaction Outputs
9
+   private TransactionOutput UTXO;
10
+
11
+    public TransactionInput(String transactionOutputId) {
12
+        this.transactionOutputId = transactionOutputId;
13
+    }
14
+
15
+    public String getTransactionOutputId() {
16
+        return transactionOutputId;
17
+    }
18
+
19
+    public void setTransactionOutputId(String transactionOutputId) {
20
+        this.transactionOutputId = transactionOutputId;
21
+    }
22
+
23
+    public TransactionOutput getUTXO() {
24
+        return UTXO;
25
+    }
26
+
27
+    public void setUTXO(TransactionOutput UTXO) {
28
+        this.UTXO = UTXO;
29
+    }
30
+}

+ 54
- 0
src/main/java/com/buecoin01/utility/TransactionOutput.java 查看文件

@@ -0,0 +1,54 @@
1
+package com.buecoin01.utility;
2
+
3
+import java.security.PublicKey;
4
+
5
+public class TransactionOutput {
6
+    private String id;
7
+    private PublicKey reciepient; //new owner of the coins
8
+    private float value; //the amount of coins they own
9
+    private String parentTransactionId;
10
+
11
+    public TransactionOutput(PublicKey reciepient, float value, String parentTransactionId) {
12
+        this.reciepient = reciepient;
13
+        this.value = value;
14
+        this.parentTransactionId = parentTransactionId;
15
+        this.id = Encryption.applySha256(Encryption.getStringFromKey(reciepient)+Float.toString(value)+parentTransactionId);
16
+    }
17
+
18
+    public String getId() {
19
+        return id;
20
+    }
21
+
22
+    public void setId(String id) {
23
+        this.id = id;
24
+    }
25
+
26
+    public PublicKey getReciepient() {
27
+        return reciepient;
28
+    }
29
+
30
+    public void setReciepient(PublicKey reciepient) {
31
+        this.reciepient = reciepient;
32
+    }
33
+
34
+    public float getValue() {
35
+        return value;
36
+    }
37
+
38
+    public void setValue(float value) {
39
+        this.value = value;
40
+    }
41
+
42
+    public String getParentTransactionId() {
43
+        return parentTransactionId;
44
+    }
45
+
46
+    public void setParentTransactionId(String parentTransactionId) {
47
+        this.parentTransactionId = parentTransactionId;
48
+    }
49
+
50
+    //Check if coin belongs to publicKey
51
+    public boolean isMine(PublicKey publicKey) {
52
+        return publicKey == reciepient;
53
+    }
54
+}

二进制
target/classes/com/buecoin01/model/Blockchain.class 查看文件


二进制
target/classes/com/buecoin01/model/Transaction.class 查看文件


二进制
target/classes/com/buecoin01/utility/Encryption.class 查看文件


二进制
target/classes/com/buecoin01/utility/TransactionInput.class 查看文件


二进制
target/classes/com/buecoin01/utility/TransactionOutput.class 查看文件